configstore

package
v0.0.0-...-732aecd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2014 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

APIEndpoint holds information about an API endpoint.

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.
	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"`
	StateServers []string               `json:"state-servers" yaml:"state-servers"`
	CACert       string                 `json:"ca-cert" yaml:"ca-cert"`
	Config       map[string]interface{} `json:"bootstrap-config,omitempty" yaml:"bootstrap-config,omitempty"`
}

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.
	// It return ErrAlreadyExists if the
	// information has already been created.
	CreateInfo(envName string) (EnvironInfo, error)
}

Storage stores environment configuration data.

func Default

func Default() (Storage, error)

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

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 on demand.

func NewMem

func NewMem() Storage

NewMem returns a ConfigStorage implementation that stores configuration in memory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL