Documentation

Index

Constants

View Source
const (
	CurrentEnvironmentFilename = "current-environment"
	CurrentSystemFilename      = "current-system"
)

Variables

View Source
var ErrNoEnvironmentSpecified = errors.New("no environment specified")

    ErrNoEnvironmentSpecified is returned by commands that operate on an environment if there is no current environment, no environment has been explicitly specified, and there is no default environment.

    View Source
    var ErrNoSystemSpecified = errors.New("no system specified")

      ErrNoSystemSpecified is returned by commands that operate on a system if there is no current system, no system has been explicitly specified, and there is no default system.

      Functions

      func BootstrapContext

      func BootstrapContext(cmdContext *cmd.Context) environs.BootstrapContext

        BootstrapContext returns a new BootstrapContext constructed from a command Context.

        func BootstrapContextNoVerify

        func BootstrapContextNoVerify(cmdContext *cmd.Context) environs.BootstrapContext

          BootstrapContextNoVerify returns a new BootstrapContext constructed from a command Context where the validation of credentials is false.

          func ConnectionInfoForName

          func ConnectionInfoForName(envName string) (configstore.EnvironInfo, error)

            ConnectionInfoForName reads the environment information for the named environment (envName) and returns it.

            func CurrentConnectionName

            func CurrentConnectionName() (name string, is_system bool, err error)

              CurrentConnectionName looks at both the current environment file and the current system file to determine which is active. The name of the current environment or system is returned along with a boolean to express whether the name refers to a system or environment.

              func GetDefaultEnvironment

              func GetDefaultEnvironment() (string, error)

                GetDefaultEnvironment returns the name of the Juju default environment. There is simple ordering for the default environment. Firstly check the JUJU_ENV environment variable. If that is set, it gets used. If it isn't set, look in the $JUJU_HOME/current-environment file. If neither are available, read environments.yaml and use the default environment therein. If no default is specified in the environments file, an empty string is returned. Not having a default environment specified is not an error.

                func GetEnvironmentVersion

                func GetEnvironmentVersion(client EnvironmentGetter) (version.Number, error)

                  GetEnvironmentVersion retrieves the environment's agent-version value from an API client.

                  func ReadCurrentEnvironment

                  func ReadCurrentEnvironment() (string, error)

                    Read the file $JUJU_HOME/current-environment and return the value stored there. If the file doesn't exist an empty string is returned and no error.

                    func ReadCurrentSystem

                    func ReadCurrentSystem() (string, error)

                      Read the file $JUJU_HOME/current-system and return the value stored there. If the file doesn't exist an empty string is returned and no error.

                      func SetCurrentEnvironment

                      func SetCurrentEnvironment(context *cmd.Context, environmentName string) error

                        SetCurrentEnvironment writes out the current environment file and writes a standard message to the command context.

                        func SetCurrentSystem

                        func SetCurrentSystem(context *cmd.Context, systemName string) error

                          SetCurrentSystem writes out the current system file and writes a standard message to the command context.

                          func Wrap

                          func Wrap(c EnvironCommand) cmd.Command

                            Wrap wraps the specified EnvironCommand, returning a Command that proxies to each of the EnvironCommand methods.

                            func WrapSystem

                            func WrapSystem(c SystemCommand) cmd.Command

                              Wrap wraps the specified SystemCommand, returning a Command that proxies to each of the SystemCommand methods.

                              func WriteCurrentEnvironment

                              func WriteCurrentEnvironment(envName string) error

                                Write the envName to the file $JUJU_HOME/current-environment file.

                                func WriteCurrentSystem

                                func WriteCurrentSystem(systemName string) error

                                  Write the systemName to the file $JUJU_HOME/current-system file.

                                  Types

                                  type ConnectionWriter

                                  type ConnectionWriter interface {
                                  	Write() error
                                  	SetAPICredentials(configstore.APICredentials)
                                  	SetAPIEndpoint(configstore.APIEndpoint)
                                  	SetBootstrapConfig(map[string]interface{})
                                  	Location() string
                                  }

                                    ConnectionWriter defines the methods needed to write information about a given connection. This is a subset of the methods in the interface defined in configstore.EnvironInfo.

                                    type EnvCommandBase

                                    type EnvCommandBase struct {
                                    	cmd.CommandBase
                                    	// contains filtered or unexported fields
                                    }

                                      EnvCommandBase is a convenience type for embedding in commands that wish to implement EnvironCommand.

                                      func (*EnvCommandBase) CompatVersion

                                      func (c *EnvCommandBase) CompatVersion() int

                                        CompatVersion returns the minimum CLI version that this command should be compatible with.

                                        func (*EnvCommandBase) Config

                                        func (c *EnvCommandBase) Config(store configstore.Storage, client EnvironmentGetter) (*config.Config, error)

                                          Config returns the configuration for the environment; obtaining bootstrap information from the API if necessary. If callers already have an active client API connection, it will be used. Otherwise, a new API connection will be used if necessary.

                                          func (*EnvCommandBase) ConnectionCredentials

                                          func (c *EnvCommandBase) ConnectionCredentials() (configstore.APICredentials, error)

                                            ConnectionCredentials returns the credentials used to connect to the API for the specified environment.

                                            func (*EnvCommandBase) ConnectionEndpoint

                                            func (c *EnvCommandBase) ConnectionEndpoint(refresh bool) (configstore.APIEndpoint, error)

                                              ConnectionEndpoint returns the end point information used to connect to the API for the specified environment.

                                              func (*EnvCommandBase) ConnectionName

                                              func (c *EnvCommandBase) ConnectionName() string

                                                ConnectionName returns the name of the connection if there is one. It is possible that the name of the connection is empty if the connection information is supplied through command line arguments or environment variables.

                                                func (*EnvCommandBase) ConnectionWriter

                                                func (c *EnvCommandBase) ConnectionWriter() (ConnectionWriter, error)

                                                  ConnectionWriter returns an instance that is able to be used to record information about the connection. When the connection is determined through either command line parameters or environment variables, an error is returned.

                                                  func (*EnvCommandBase) NewAPIClient

                                                  func (c *EnvCommandBase) NewAPIClient() (*api.Client, error)

                                                  func (*EnvCommandBase) NewAPIRoot

                                                  func (c *EnvCommandBase) NewAPIRoot() (api.Connection, error)

                                                  func (*EnvCommandBase) NewEnvironmentGetter

                                                  func (c *EnvCommandBase) NewEnvironmentGetter() (EnvironmentGetter, error)

                                                    NewEnvironmentGetter returns a new object which implements the EnvironmentGetter interface.

                                                    func (*EnvCommandBase) SetEnvName

                                                    func (c *EnvCommandBase) SetEnvName(envName string)

                                                    type EnvironCommand

                                                    type EnvironCommand interface {
                                                    	cmd.Command
                                                    
                                                    	// SetEnvName is called prior to the wrapped command's Init method
                                                    	// with the active environment name. The environment name is guaranteed
                                                    	// to be non-empty at entry of Init.
                                                    	SetEnvName(envName string)
                                                    }

                                                      EnvironCommand extends cmd.Command with a SetEnvName method.

                                                      type EnvironmentGetter

                                                      type EnvironmentGetter interface {
                                                      	EnvironmentGet() (map[string]interface{}, error)
                                                      	Close() error
                                                      }

                                                      type ServerFile

                                                      type ServerFile struct {
                                                      	Addresses []string `yaml:"addresses"`
                                                      	CACert    string   `yaml:"ca-cert,omitempty"`
                                                      	Username  string   `yaml:"username"`
                                                      	Password  string   `yaml:"password"`
                                                      }

                                                        ServerFile describes the information that is needed for a user to connect to an api server.

                                                        type SysCommandBase

                                                        type SysCommandBase struct {
                                                        	cmd.CommandBase
                                                        	// contains filtered or unexported fields
                                                        }

                                                          SysCommandBase is a convenience type for embedding in commands that wish to implement SystemCommand.

                                                          func (*SysCommandBase) ConnectionCredentials

                                                          func (c *SysCommandBase) ConnectionCredentials() (configstore.APICredentials, error)

                                                            ConnectionCredentials returns the credentials used to connect to the API for the specified system.

                                                            func (*SysCommandBase) ConnectionEndpoint

                                                            func (c *SysCommandBase) ConnectionEndpoint() (configstore.APIEndpoint, error)

                                                              ConnectionEndpoint returns the endpoint details used to connect to the API for the specified system.

                                                              func (*SysCommandBase) ConnectionInfo

                                                              func (c *SysCommandBase) ConnectionInfo() (configstore.EnvironInfo, error)

                                                                ConnectionInfo returns the environ info from the cached config store.

                                                                func (*SysCommandBase) NewEnvironmentManagerAPIClient

                                                                func (c *SysCommandBase) NewEnvironmentManagerAPIClient() (*environmentmanager.Client, error)

                                                                  NewEnvironmentManagerAPIClient returns an API client for the EnvironmentManager on the current system using the current credentials.

                                                                  func (*SysCommandBase) NewSystemManagerAPIClient

                                                                  func (c *SysCommandBase) NewSystemManagerAPIClient() (*systemmanager.Client, error)

                                                                    NewSystemManagerAPIClient returns an API client for the SystemManager on the current system using the current credentials.

                                                                    func (*SysCommandBase) NewUserManagerAPIClient

                                                                    func (c *SysCommandBase) NewUserManagerAPIClient() (*usermanager.Client, error)

                                                                      NewUserManagerAPIClient returns an API client for the UserManager on the current system using the current credentials.

                                                                      func (*SysCommandBase) SetSystemName

                                                                      func (c *SysCommandBase) SetSystemName(systemName string)

                                                                        SetSystemName records the current environment name in the SysCommandBase

                                                                        func (*SysCommandBase) SystemName

                                                                        func (c *SysCommandBase) SystemName() string

                                                                          SystemName returns the name of the system or environment used to determine that API end point.

                                                                          type SystemCommand

                                                                          type SystemCommand interface {
                                                                          	cmd.Command
                                                                          
                                                                          	// SetSystemName is called prior to the wrapped command's Init method with
                                                                          	// the active system name. The system name is guaranteed to be non-empty
                                                                          	// at entry of Init.
                                                                          	SetSystemName(systemName string)
                                                                          
                                                                          	// SystemName returns the name of the system or environment used to
                                                                          	// determine that API end point.
                                                                          	SystemName() string
                                                                          }

                                                                            SystemCommand is intended to be a base for all commands that need to operate on systems as opposed to environments.