Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = func() (Storage, error) {
	return NewDisk(osenv.JujuHome())
}

    Default returns disk-based environment config storage rooted at JujuHome.

    View Source
    var DefaultAdminUsername = "admin"

      DefaultAdminUsername is used as the username to connect as in the absense of any explicit username being defined in the config store.

      View Source
      var ErrEnvironInfoAlreadyExists = errors.New("environment info already exists")

      Functions

      This section is empty.

      Types

      type APICredentials

      type APICredentials struct {
      	// User holds the name of the user to connect as.
      	User     string
      	Password string
      }

        APICredentials hold credentials for connecting to an API endpoint.

        type APIEndpoint

        type APIEndpoint struct {
        	// APIAddress holds a list of API addresses. It may not be
        	// current, and it will be empty if the environment has not been
        	// bootstrapped.
        	Addresses []string
        
        	// Hostnames holds a list of API addresses which may contain
        	// unresolved hostnames. It's used to compare more recent API
        	// addresses before resolving hostnames to determine if the cached
        	// addresses have changed and therefore perform (a possibly slow)
        	// local DNS resolution before comparing them against Addresses.
        	Hostnames []string
        
        	// CACert holds the CA certificate that
        	// signed the API server's key.
        	CACert string
        
        	// EnvironUUID holds the UUID for the environment we are connecting to.
        	// This may be empty if the environment has not been bootstrapped.
        	EnvironUUID string
        
        	// ServerUUID holds the UUID for the server environment. This may be empty
        	// if the server is old and not sending the server uuid in the login
        	// repsonse.
        	ServerUUID string
        }

          APIEndpoint holds information about an API endpoint.

          type CacheFile

          type CacheFile struct {
          	// Server maps the name of the server to the server-uuid
          	Server map[string]ServerUser `yaml:"server-user"`
          	// ServerData is a map of server-uuid to the data for that server.
          	ServerData map[string]ServerData `yaml:"server-data"`
          	// Environment maps the local name of the environment to the details
          	// for that environment
          	Environment map[string]EnvironmentData `yaml:"environment"`
          }

            CacheFile represents the YAML structure of the file $JUJU_HOME/environments/cache.yaml

            type EnvironInfo

            type EnvironInfo interface {
            	// Initialized returns whether the environment information has
            	// been initialized. It will return true for EnvironInfo instances
            	// that have been created but not written.
            	Initialized() bool
            
            	// BootstrapConfig returns the configuration attributes
            	// that an environment will be bootstrapped with.
            	BootstrapConfig() map[string]interface{}
            
            	// APIEndpoint returns the current API endpoint information.
            	APIEndpoint() APIEndpoint
            
            	// APICredentials returns the current API credentials.
            	APICredentials() APICredentials
            
            	// SetBootstrapConfig sets the configuration attributes
            	// to be used for bootstrapping.
            	// This method may only be called on an EnvironInfo
            	// obtained using ConfigStorage.CreateInfo.
            	SetBootstrapConfig(map[string]interface{})
            
            	// SetAPIEndpoint sets the API endpoint information
            	// currently associated with the environment.
            	SetAPIEndpoint(APIEndpoint)
            
            	// SetAPICreds sets the API credentials currently
            	// associated with the environment.
            	SetAPICredentials(APICredentials)
            
            	// Location returns the location of the source of the environment
            	// information in a human readable format.
            	Location() string
            
            	// Write writes the current information to persistent storage. A
            	// subsequent call to ConfigStorage.ReadInfo can retrieve it. After this
            	// call succeeds, Initialized will return true.
            	// It return ErrAlreadyExists if the EnvironInfo is not yet Initialized
            	// and the EnvironInfo has been written before.
            	Write() error
            
            	// Destroy destroys the information associated with
            	// the environment.
            	Destroy() error
            }

              EnvironInfo holds information associated with an environment.

              type EnvironInfoData

              type EnvironInfoData struct {
              	User            string
              	Password        string
              	EnvironUUID     string                 `json:"environ-uuid,omitempty" yaml:"environ-uuid,omitempty"`
              	ServerUUID      string                 `json:"server-uuid,omitempty" yaml:"server-uuid,omitempty"`
              	StateServers    []string               `json:"state-servers" yaml:"state-servers"`
              	ServerHostnames []string               `json:"server-hostnames,omitempty" yaml:"server-hostnames,omitempty"`
              	CACert          string                 `json:"ca-cert" yaml:"ca-cert"`
              	Config          map[string]interface{} `json:"bootstrap-config,omitempty" yaml:"bootstrap-config,omitempty"`
              }

                EnvironInfoData is the serialisation structure for the original JENV file.

                type EnvironmentData

                type EnvironmentData struct {
                	User            string `yaml:"user"`
                	EnvironmentUUID string `yaml:"env-uuid"`
                	ServerUUID      string `yaml:"server-uuid"`
                }

                  EnvironmentData represents a single environment running in a Juju Environment Server.

                  type ServerData

                  type ServerData struct {
                  	APIEndpoints    []string `yaml:"api-endpoints"`
                  	ServerHostnames []string `yaml:"server-hostnames,omitempty"`
                  	CACert          string   `yaml:"ca-cert"`
                  	// Identities is a mapping of full username to credentials.
                  	Identities      map[string]string      `yaml:"identities"`
                  	BootstrapConfig map[string]interface{} `yaml:"bootstrap-config,omitempty"`
                  }

                    ServerData holds the end point details for the API servers running in the state server environment.

                    type ServerUser

                    type ServerUser struct {
                    	ServerUUID string `yaml:"server-uuid"`
                    	User       string `yaml:"user"`
                    }

                      ServerUser represents a user on a server, but not an environment on that server. Used for server based commands like login, list and use.

                      type Storage

                      type Storage interface {
                      	// ReadInfo reads information associated with
                      	// the environment with the given name.
                      	// If there is no such information, it will
                      	// return an errors.NotFound error.
                      	ReadInfo(envName string) (EnvironInfo, error)
                      
                      	// CreateInfo creates some uninitialized information associated
                      	// with the environment with the given name.
                      	CreateInfo(envName string) EnvironInfo
                      
                      	// List returns a slice of existing environment names that the Storage
                      	// knows about.
                      	List() ([]string, error)
                      
                      	// ListSystems returns a slice of existing server names that the Storage
                      	// knows about.
                      	ListSystems() ([]string, error)
                      }

                        Storage stores environment and server configuration data.

                        func NewDisk

                        func NewDisk(dir string) (Storage, error)

                          NewDisk returns a ConfigStorage implementation that stores configuration in the given directory. The parent of the directory must already exist; the directory itself is created if it doesn't already exist.

                          func NewMem

                          func NewMem() Storage

                            NewMem returns a ConfigStorage implementation that stores configuration in memory.