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