Example #1
0
// NewDefaultsCommandForTest returns a defaultsCommand with the api provided as specified.
func NewDefaultsCommandForTest(api defaultsCommandAPI, store jujuclient.ClientStore) cmd.Command {
	cmd := &defaultsCommand{
		api: api,
	}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(cmd)
}
Example #2
0
File: list.go Project: bac/juju
func NewListCommand() cmd.Command {
	return modelcmd.WrapController(&listCommand{
		infoCommandBase: infoCommandBase{
			clock: clock.WallClock,
		},
	})
}
Example #3
0
// NewGrantCommandForTest returns a GrantCommand with the api provided as specified.
func NewGrantCommandForTest(api GrantModelAPI, store jujuclient.ClientStore) (cmd.Command, *GrantCommand) {
	cmd := &grantCommand{
		api: api,
	}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(cmd), &GrantCommand{cmd}
}
Example #4
0
func NewShowUserCommandForTest(api UserInfoAPI, store jujuclient.ClientStore) cmd.Command {
	cmd := &infoCommand{infoCommandBase: infoCommandBase{
		clock: clock.WallClock,
		api:   api}}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(cmd)
}
Example #5
0
// NewEnableDestroyControllerCommandForTest returns a enableDestroyController with the
// function used to open the API connection mocked out.
func NewEnableDestroyControllerCommandForTest(api removeBlocksAPI, store jujuclient.ClientStore) cmd.Command {
	c := &enableDestroyController{
		api: api,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c)
}
Example #6
0
// NewRevokeCommandForTest returns an revokeCommand with the api provided as specified.
func NewRevokeCommandForTest(api RevokeModelAPI, store jujuclient.ClientStore) (cmd.Command, *RevokeCommand) {
	cmd := &revokeCommand{
		api: api,
	}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(cmd), &RevokeCommand{cmd}
}
Example #7
0
// NewModelsCommandForTest returns a EnvironmentsCommand with the API
// and userCreds provided as specified.
func NewModelsCommandForTest(modelAPI ModelManagerAPI, sysAPI ModelsSysAPI, userCreds *configstore.APICredentials) cmd.Command {
	return modelcmd.WrapController(&environmentsCommand{
		modelAPI:  modelAPI,
		sysAPI:    sysAPI,
		userCreds: userCreds,
	})
}
Example #8
0
// NewCreateModelCommandForTest returns a CreateModelCommand with
// the api provided as specified.
func NewCreateModelCommandForTest(api CreateEnvironmentAPI, parser func(interface{}) (interface{}, error)) (cmd.Command, *CreateModelCommand) {
	c := &createModelCommand{
		api:          api,
		configParser: parser,
	}
	return modelcmd.WrapController(c), &CreateModelCommand{c}
}
Example #9
0
// NewChangePasswordCommand returns a ChangePasswordCommand with the api
// and writer provided as specified.
func NewChangePasswordCommandForTest(api ChangePasswordAPI, writer EnvironInfoCredsWriter) (cmd.Command, *ChangePasswordCommand) {
	c := &changePasswordCommand{
		api:    api,
		writer: writer,
	}
	return modelcmd.WrapController(c), &ChangePasswordCommand{c}
}
Example #10
0
func (s *MigrateSuite) runCommand(c *gc.C, args ...string) (*cmd.Context, error) {
	cmd := &migrateCommand{
		api: s.api,
	}
	cmd.SetClientStore(s.store)
	return testing.RunCommand(c, modelcmd.WrapController(cmd), args...)
}
Example #11
0
func NewUpdateCredentialCommandForTest(testStore jujuclient.ClientStore, api credentialAPI) cmd.Command {
	c := &updateCredentialCommand{
		api: api,
	}
	c.SetClientStore(testStore)
	return modelcmd.WrapController(c)
}
Example #12
0
// NewListBlocksCommandForTest returns a ListBlocksCommand with the controller
// endpoint mocked out.
func NewListBlocksCommandForTest(api listBlocksAPI, apierr error, store jujuclient.ClientStore) cmd.Command {
	c := &listBlocksCommand{
		api:    api,
		apierr: apierr,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c)
}
Example #13
0
// NewListCommand returns a ListCommand with the api provided as specified.
func NewListCommandForTest(api UserInfoAPI) cmd.Command {
	c := &listCommand{
		infoCommandBase: infoCommandBase{
			api: api,
		},
	}
	return modelcmd.WrapController(c)
}
Example #14
0
// NewEnableCommand returns a EnableCommand with the api provided as
// specified.
func NewEnableCommandForTest(api disenableUserAPI) (cmd.Command, *DisenableUserBase) {
	c := &enableCommand{
		disenableUserBase{
			api: api,
		},
	}
	return modelcmd.WrapController(c), &DisenableUserBase{&c.disenableUserBase}
}
Example #15
0
// NewUseModelCommandForTest returns a UseModelCommand with the
// API and userCreds provided as specified.
func NewUseModelCommandForTest(api UseModelAPI, userCreds *configstore.APICredentials, endpoint *configstore.APIEndpoint) (cmd.Command, *UseModelCommand) {
	c := &useModelCommand{
		api:       api,
		userCreds: userCreds,
		endpoint:  endpoint,
	}
	return modelcmd.WrapController(c), &UseModelCommand{c}
}
Example #16
0
// NewListModelsCommandForTest returns a ListModelsCommand with the API
// and userCreds provided as specified.
func NewListModelsCommandForTest(modelAPI ModelManagerAPI, sysAPI ModelsSysAPI, store jujuclient.ClientStore) cmd.Command {
	c := &modelsCommand{
		modelAPI: modelAPI,
		sysAPI:   sysAPI,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c)
}
Example #17
0
// NewLoginCommand returns a LoginCommand with the api
// and writer provided as specified.
func NewLoginCommandForTest(
	newLoginAPI func(juju.NewAPIConnectionParams) (LoginAPI, error),
	store jujuclient.ClientStore,
) (cmd.Command, *LoginCommand) {
	c := &loginCommand{newLoginAPI: newLoginAPI}
	c.SetClientStore(store)
	return modelcmd.WrapController(c), &LoginCommand{c}
}
Example #18
0
func initTestControllerCommand(c *gc.C, store jujuclient.ClientStore, args ...string) (cmd.Command, *testControllerCommand, error) {
	cmd := new(testControllerCommand)
	cmd.SetClientStore(store)
	wrapped := modelcmd.WrapController(cmd)
	if err := cmdtesting.InitCommand(wrapped, args); err != nil {
		return nil, nil, err
	}
	return wrapped, cmd, nil
}
Example #19
0
// NewDefaultsCommandForTest returns a defaultsCommand with the api provided as specified.
func NewDefaultsCommandForTest(apiRoot api.Connection, dAPI defaultsCommandAPI, cAPI cloudAPI, store jujuclient.ClientStore) cmd.Command {
	cmd := &defaultsCommand{
		newAPIRoot:     func() (api.Connection, error) { return apiRoot, nil },
		newDefaultsAPI: func(caller base.APICallCloser) defaultsCommandAPI { return dAPI },
		newCloudAPI:    func(caller base.APICallCloser) cloudAPI { return cAPI },
	}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(cmd)
}
Example #20
0
// NewAddModelCommand returns a command to add a model.
func NewAddModelCommand() cmd.Command {
	return modelcmd.WrapController(&addModelCommand{
		newAddModelAPI: func(caller base.APICallCloser) AddModelAPI {
			return modelmanager.NewClient(caller)
		},
		newCloudAPI: func(caller base.APICallCloser) CloudAPI {
			return cloudapi.NewClient(caller)
		},
	})
}
Example #21
0
// NewListCommand returns a ListCommand with the api provided as specified.
func NewListCommandForTest(api UserInfoAPI, modelAPI modelUsersAPI, store jujuclient.ClientStore, clock clock.Clock) cmd.Command {
	c := &listCommand{
		infoCommandBase: infoCommandBase{
			clock: clock,
			api:   api,
		},
		modelUserAPI: modelAPI,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c)
}
Example #22
0
File: login.go Project: kat-co/juju
// NewLoginCommand returns a new cmd.Command to handle "juju login".
func NewLoginCommand() cmd.Command {
	return modelcmd.WrapController(&loginCommand{
		newLoginAPI: func(args juju.NewAPIConnectionParams) (LoginAPI, ConnectionAPI, error) {
			api, err := juju.NewAPIConnection(args)
			if err != nil {
				return nil, nil, errors.Trace(err)
			}
			return usermanager.NewClient(api), api, nil
		},
	})
}
Example #23
0
File: destroy.go Project: bac/juju
// NewDestroyCommand returns a command to destroy a controller.
func NewDestroyCommand() cmd.Command {
	// Even though this command is all about destroying a controller we end up
	// needing environment endpoints so we can fall back to the client destroy
	// environment method. This shouldn't really matter in practice as the
	// user trying to take down the controller will need to have access to the
	// controller environment anyway.
	return modelcmd.WrapController(
		&destroyCommand{},
		modelcmd.WrapControllerSkipControllerFlags,
		modelcmd.WrapControllerSkipDefaultController,
	)
}
Example #24
0
File: kill.go Project: kat-co/juju
// wrapKillCommand provides the common wrapping used by tests and
// the default NewKillCommand above.
func wrapKillCommand(kill *killCommand, apiOpen modelcmd.APIOpener, clock clock.Clock) cmd.Command {
	if apiOpen == nil {
		apiOpen = modelcmd.OpenFunc(kill.JujuCommandBase.NewAPIRoot)
	}
	openStrategy := modelcmd.NewTimeoutOpener(apiOpen, clock, 10*time.Second)
	return modelcmd.WrapController(
		kill,
		modelcmd.WrapControllerSkipControllerFlags,
		modelcmd.WrapControllerSkipDefaultController,
		modelcmd.WrapControllerAPIOpener(openStrategy),
	)
}
Example #25
0
// NewChangePasswordCommand returns a ChangePasswordCommand with the api
// and writer provided as specified.
func NewChangePasswordCommandForTest(
	newAPIConnection func(juju.NewAPIConnectionParams) (api.Connection, error),
	api ChangePasswordAPI,
	store jujuclient.ClientStore,
) (cmd.Command, *ChangePasswordCommand) {
	c := &changePasswordCommand{
		newAPIConnection: newAPIConnection,
		api:              api,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c), &ChangePasswordCommand{c}
}
Example #26
0
// NewDefaultsCommand wraps defaultsCommand with sane model settings.
func NewDefaultsCommand() cmd.Command {
	defaultsCmd := &defaultsCommand{
		newCloudAPI: func(caller base.APICallCloser) cloudAPI {
			return cloudapi.NewClient(caller)
		},
		newDefaultsAPI: func(caller base.APICallCloser) defaultsCommandAPI {
			return modelmanager.NewClient(caller)
		},
	}
	defaultsCmd.newAPIRoot = defaultsCmd.NewAPIRoot
	return modelcmd.WrapController(defaultsCmd)
}
Example #27
0
// NewAddModelCommandForTest returns a AddModelCommand with
// the api provided as specified.
func NewAddModelCommandForTest(
	api CreateModelAPI,
	store jujuclient.ClientStore,
	credentialStore jujuclient.CredentialStore,
) (cmd.Command, *AddModelCommand) {
	c := &addModelCommand{
		api:             api,
		credentialStore: credentialStore,
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c), &AddModelCommand{c}
}
Example #28
0
File: enableha.go Project: bac/juju
func newEnableHACommand() cmd.Command {
	haCommand := &enableHACommand{}
	haCommand.newHAClientFunc = func() (MakeHAClient, error) {
		root, err := haCommand.NewAPIRoot()
		if err != nil {
			return nil, errors.Annotate(err, "cannot get API connection")
		}

		// NewClient does not return an error, so we'll return nil
		return highavailability.NewClient(root), nil
	}
	return modelcmd.WrapController(haCommand)
}
Example #29
0
// NewAddModelCommandForTest returns a AddModelCommand with
// the api provided as specified.
func NewAddModelCommandForTest(
	apiRoot api.Connection,
	api AddModelAPI,
	cloudAPI CloudAPI,
	store jujuclient.ClientStore,
) (cmd.Command, *AddModelCommand) {
	c := &addModelCommand{
		apiRoot: apiRoot,
		newAddModelAPI: func(caller base.APICallCloser) AddModelAPI {
			return api
		},
		newCloudAPI: func(base.APICallCloser) CloudAPI {
			return cloudAPI
		},
	}
	c.SetClientStore(store)
	return modelcmd.WrapController(c), &AddModelCommand{c}
}
Example #30
0
// NewDestroyCommandForTest returns a DestroyCommand with the controller and
// client endpoints mocked out.
func NewDestroyCommandForTest(
	api destroyControllerAPI,
	clientapi destroyClientAPI,
	store jujuclient.ClientStore,
	apierr error,
) cmd.Command {
	cmd := &destroyCommand{
		destroyCommandBase: destroyCommandBase{
			api:       api,
			clientapi: clientapi,
			apierr:    apierr,
		},
	}
	cmd.SetClientStore(store)
	return modelcmd.WrapController(
		cmd,
		modelcmd.WrapControllerSkipControllerFlags,
		modelcmd.WrapControllerSkipDefaultController,
	)
}