Пример #1
0
func (c *RemoveUserCommand) Run(_ *cmd.Context) error {
	client, err := juju.NewUserManagerClient(c.EnvName)
	if err != nil {
		return err
	}
	defer client.Close()
	return client.RemoveUser(c.User)
}
Пример #2
0
}

type ChangePasswordAPI interface {
	SetPassword(username, password string) error
	Close() error
}

type EnvironInfoCredsWriter interface {
	Write() error
	SetAPICredentials(creds configstore.APICredentials)
	APICredentials() configstore.APICredentials
	Location() string
}

var getChangePasswordAPI = func(c *UserChangePasswordCommand) (ChangePasswordAPI, error) {
	return juju.NewUserManagerClient(c.EnvName)
}

var getEnvironInfo = func(c *UserChangePasswordCommand) (EnvironInfoCredsWriter, error) {
	store, err := configstore.Default()
	if err != nil {
		return nil, err
	}
	return store.ReadInfo(c.EnvName)
}

func (c *UserChangePasswordCommand) Run(ctx *cmd.Context) error {
	var err error
	if c.Password != "" && c.Generate {
		return fmt.Errorf("You need to choose a password or generate one")
	}