Exemplo n.º 1
0
// NewEnvironmentsCommand returns a EnvironmentsCommand with the API and userCreds
// provided as specified.
func NewEnvironmentsCommand(envAPI EnvironmentsEnvAPI, sysAPI EnvironmentsSysAPI, userCreds *configstore.APICredentials) cmd.Command {
	return envcmd.WrapSystem(&environmentsCommand{
		envAPI:    envAPI,
		sysAPI:    sysAPI,
		userCreds: userCreds,
	})
}
Exemplo n.º 2
0
// NewCreateEnvironmentCommand returns a CreateEnvironmentCommand with the api provided as specified.
func NewCreateEnvironmentCommand(api CreateEnvironmentAPI, parser func(interface{}) (interface{}, error)) (cmd.Command, *CreateEnvironmentCommand) {
	c := &createEnvironmentCommand{
		api:          api,
		configParser: parser,
	}
	return envcmd.WrapSystem(c), &CreateEnvironmentCommand{c}
}
Exemplo n.º 3
0
// NewChangePasswordCommand returns a ChangePasswordCommand with the api
// and writer provided as specified.
func NewChangePasswordCommand(api ChangePasswordAPI, writer EnvironInfoCredsWriter) (cmd.Command, *ChangePasswordCommand) {
	c := &changePasswordCommand{
		api:    api,
		writer: writer,
	}
	return envcmd.WrapSystem(c), &ChangePasswordCommand{c}
}
Exemplo n.º 4
0
// NewUseEnvironmentCommand returns a UseEnvironmentCommand with the API and
// userCreds provided as specified.
func NewUseEnvironmentCommand(api UseEnvironmentAPI, userCreds *configstore.APICredentials, endpoint *configstore.APIEndpoint) (cmd.Command, *UseEnvironmentCommand) {
	c := &useEnvironmentCommand{
		api:       api,
		userCreds: userCreds,
		endpoint:  endpoint,
	}
	return envcmd.WrapSystem(c), &UseEnvironmentCommand{c}
}
Exemplo n.º 5
0
// NewEnableCommand returns a EnableCommand with the api provided as
// specified.
func NewEnableCommand(api disenableUserAPI) (cmd.Command, *DisenableUserBase) {
	c := &enableCommand{
		disenableUserBase{
			api: api,
		},
	}
	return envcmd.WrapSystem(c), &DisenableUserBase{&c.disenableUserBase}
}
Exemplo n.º 6
0
// NewListCommand returns a ListCommand with the api provided as specified.
func NewListCommand(api UserInfoAPI) cmd.Command {
	c := &listCommand{
		infoCommandBase: infoCommandBase{
			api: api,
		},
	}
	return envcmd.WrapSystem(c)
}
Exemplo n.º 7
0
// NewSuperCommand creates the system supercommand and registers the
// subcommands that it supports.
func NewSuperCommand() cmd.Command {
	systemCmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "system",
		Doc:         commandDoc,
		UsagePrefix: "juju",
		Purpose:     "manage systems",
	})

	systemCmd.Register(&ListCommand{})
	systemCmd.Register(&LoginCommand{})
	systemCmd.Register(&DestroyCommand{})
	systemCmd.Register(&KillCommand{apiDialerFunc: juju.NewAPIFromName})
	systemCmd.Register(envcmd.WrapSystem(&EnvironmentsCommand{}))
	systemCmd.Register(envcmd.WrapSystem(&CreateEnvironmentCommand{}))
	systemCmd.Register(envcmd.WrapSystem(&RemoveBlocksCommand{}))
	systemCmd.Register(envcmd.WrapSystem(&UseEnvironmentCommand{}))

	return systemCmd
}
Exemplo n.º 8
0
// NewSuperCommand creates the user supercommand and registers the subcommands
// that it supports.
func NewSuperCommand() cmd.Command {
	usercmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "user",
		Doc:         userCommandDoc,
		UsagePrefix: "juju",
		Purpose:     userCommandPurpose,
	})
	usercmd.Register(envcmd.WrapSystem(&AddCommand{}))
	usercmd.Register(envcmd.WrapSystem(&ChangePasswordCommand{}))
	usercmd.Register(envcmd.WrapSystem(&CredentialsCommand{}))
	usercmd.Register(envcmd.WrapSystem(&InfoCommand{}))
	usercmd.Register(envcmd.WrapSystem(&DisableCommand{}))
	usercmd.Register(envcmd.WrapSystem(&EnableCommand{}))
	usercmd.Register(envcmd.WrapSystem(&ListCommand{}))
	return usercmd
}
Exemplo n.º 9
0
func newEnableCommand() cmd.Command {
	return envcmd.WrapSystem(&enableCommand{})
}
Exemplo n.º 10
0
func newUseEnvironmentCommand() cmd.Command {
	return envcmd.WrapSystem(&useEnvironmentCommand{})
}
Exemplo n.º 11
0
func newDisableCommand() cmd.Command {
	return envcmd.WrapSystem(&disableCommand{})
}
Exemplo n.º 12
0
func (s *SystemCommandSuite) TestWrapWithoutFlags(c *gc.C) {
	cmd := new(testSystemCommand)
	wrapped := envcmd.WrapSystem(cmd, envcmd.SystemSkipFlags)
	err := cmdtesting.InitCommand(wrapped, []string{"-s", "testsys"})
	c.Assert(err, gc.ErrorMatches, "flag provided but not defined: -s")
}
Exemplo n.º 13
0
func (s *createSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command := system.NewCreateEnvironmentCommand(s.fake)
	return testing.RunCommand(c, envcmd.WrapSystem(command), args...)
}
Exemplo n.º 14
0
func newCreateEnvironmentCommand() cmd.Command {
	return envcmd.WrapSystem(&createEnvironmentCommand{})
}
Exemplo n.º 15
0
func (s *CredentialsCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command := envcmd.WrapSystem(&user.CredentialsCommand{})
	return testing.RunCommand(c, command, args...)
}
Exemplo n.º 16
0
func (s *UserAddCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	addCommand := envcmd.WrapSystem(user.NewAddCommand(s.mockAPI))
	return testing.RunCommand(c, addCommand, args...)
}
Exemplo n.º 17
0
func newInfoCommand() cmd.Command {
	return envcmd.WrapSystem(&infoCommand{})
}
Exemplo n.º 18
0
// NewRemoveBlocksCommand returns a RemoveBlocksCommand with the function used
// to open the API connection mocked out.
func NewRemoveBlocksCommand(api removeBlocksAPI) cmd.Command {
	return envcmd.WrapSystem(&removeBlocksCommand{
		api: api,
	})
}
Exemplo n.º 19
0
// NewListBlocksCommand returns a ListBlocksCommand with the systemmanager
// endpoint mocked out.
func NewListBlocksCommand(api listBlocksAPI, apierr error) cmd.Command {
	return envcmd.WrapSystem(&listBlocksCommand{
		api:    api,
		apierr: apierr,
	})
}
Exemplo n.º 20
0
func NewCredentialsCommand() (cmd.Command, *CredentialsCommand) {
	c := &credentialsCommand{}
	return envcmd.WrapSystem(c), &CredentialsCommand{c}
}
Exemplo n.º 21
0
func NewInfoCommand(api UserInfoAPI) cmd.Command {
	return envcmd.WrapSystem(&infoCommand{
		infoCommandBase: infoCommandBase{
			api: api,
		}})
}
Exemplo n.º 22
0
func NewAddCommand(api AddUserAPI) (cmd.Command, *AddCommand) {
	c := &addCommand{api: api}
	return envcmd.WrapSystem(c), &AddCommand{c}
}
Exemplo n.º 23
0
func (s *UseEnvironmentSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command := system.NewUseEnvironmentCommand(s.api, &s.creds, &s.endpoint)
	return testing.RunCommand(c, envcmd.WrapSystem(command), args...)
}
Exemplo n.º 24
0
func (s *ChangePasswordCommandSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	changePasswordCommand := envcmd.WrapSystem(user.NewChangePasswordCommand(s.mockAPI, s.mockEnvironInfo))
	return testing.RunCommand(c, changePasswordCommand, args...)
}
Exemplo n.º 25
0
func newEnvironmentsCommand() cmd.Command {
	return envcmd.WrapSystem(&environmentsCommand{})
}
Exemplo n.º 26
0
func newAddCommand() cmd.Command {
	return envcmd.WrapSystem(&addCommand{})
}
Exemplo n.º 27
0
func initTestSystemCommand(c *gc.C, args ...string) (*testSystemCommand, error) {
	cmd := new(testSystemCommand)
	wrapped := envcmd.WrapSystem(cmd)
	return cmd, cmdtesting.InitCommand(wrapped, args)
}
Exemplo n.º 28
0
func newListBlocksCommand() cmd.Command {
	return envcmd.WrapSystem(&listBlocksCommand{})
}
Exemplo n.º 29
0
func newRemoveBlocksCommand() cmd.Command {
	return envcmd.WrapSystem(&removeBlocksCommand{})
}
Exemplo n.º 30
0
func newCredentialsCommand() cmd.Command {
	return envcmd.WrapSystem(&credentialsCommand{})
}