Esempio 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,
	})
}
Esempio 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}
}
Esempio 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}
}
Esempio 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}
}
Esempio 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}
}
Esempio 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)
}
Esempio 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
}
Esempio 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
}
Esempio n. 9
0
func newEnableCommand() cmd.Command {
	return envcmd.WrapSystem(&enableCommand{})
}
Esempio n. 10
0
func newUseEnvironmentCommand() cmd.Command {
	return envcmd.WrapSystem(&useEnvironmentCommand{})
}
Esempio n. 11
0
func newDisableCommand() cmd.Command {
	return envcmd.WrapSystem(&disableCommand{})
}
Esempio 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")
}
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...)
}
Esempio n. 14
0
func newCreateEnvironmentCommand() cmd.Command {
	return envcmd.WrapSystem(&createEnvironmentCommand{})
}
Esempio 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...)
}
Esempio 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...)
}
Esempio n. 17
0
func newInfoCommand() cmd.Command {
	return envcmd.WrapSystem(&infoCommand{})
}
Esempio 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,
	})
}
Esempio 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,
	})
}
Esempio n. 20
0
func NewCredentialsCommand() (cmd.Command, *CredentialsCommand) {
	c := &credentialsCommand{}
	return envcmd.WrapSystem(c), &CredentialsCommand{c}
}
Esempio n. 21
0
func NewInfoCommand(api UserInfoAPI) cmd.Command {
	return envcmd.WrapSystem(&infoCommand{
		infoCommandBase: infoCommandBase{
			api: api,
		}})
}
Esempio n. 22
0
func NewAddCommand(api AddUserAPI) (cmd.Command, *AddCommand) {
	c := &addCommand{api: api}
	return envcmd.WrapSystem(c), &AddCommand{c}
}
Esempio 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...)
}
Esempio 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...)
}
Esempio n. 25
0
func newEnvironmentsCommand() cmd.Command {
	return envcmd.WrapSystem(&environmentsCommand{})
}
Esempio n. 26
0
func newAddCommand() cmd.Command {
	return envcmd.WrapSystem(&addCommand{})
}
Esempio 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)
}
Esempio n. 28
0
func newListBlocksCommand() cmd.Command {
	return envcmd.WrapSystem(&listBlocksCommand{})
}
Esempio n. 29
0
func newRemoveBlocksCommand() cmd.Command {
	return envcmd.WrapSystem(&removeBlocksCommand{})
}
Esempio n. 30
0
func newCredentialsCommand() cmd.Command {
	return envcmd.WrapSystem(&credentialsCommand{})
}