View Source
const CurrentEnvironmentFilename = "current-environment"


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.


    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 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

                Read the file $JUJU_HOME/current-environment and return the value stored there. If the file doesn't exist, or there is a problem reading the file, an empty string is returned.

                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 WriteCurrentEnvironment

                  func WriteCurrentEnvironment(envName string) error

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


                    type ConnectionWriter

                    type ConnectionWriter interface {
                    	Write() error
                    	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 {
                      	// contains filtered or unexported fields

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

                        func (*EnvCommandBase) Config

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

                        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.State, error)

                                func (*EnvCommandBase) SetEnvName

                                func (c *EnvCommandBase) SetEnvName(envName string)

                                type EnvironCommand

                                type EnvironCommand interface {
                                	// 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)