jujuclient

package
v0.0.0-...-2608902 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JujuAccountsPath

func JujuAccountsPath() string

JujuAccountsPath is the location where accounts information is expected to be found.

func JujuBootstrapConfigPath

func JujuBootstrapConfigPath() string

JujuBootstrapConfigPath is the location where bootstrap config is expected to be found.

func JujuControllersPath

func JujuControllersPath() string

JujuControllersPath is the location where controllers information is expected to be found.

func JujuCredentialsPath

func JujuCredentialsPath() string

JujuCredentialsPath is the location where controllers information is expected to be found.

func JujuModelsPath

func JujuModelsPath() string

JujuModelsPath is the location where models information is expected to be found.

func NewTokenStore

func NewTokenStore() *ussologin.FileTokenStore

NewTokenStore returns a FileTokenStore for storing the USSO oauth token

func ParseAccounts

func ParseAccounts(data []byte) (map[string]*ControllerAccounts, error)

ParseAccounts parses the given YAML bytes into accounts metadata.

func ParseBootstrapConfig

func ParseBootstrapConfig(data []byte) (map[string]BootstrapConfig, error)

ParseBootstrapConfig parses the given YAML bytes into bootstrap config metadata.

func ParseControllers

func ParseControllers(data []byte) (map[string]ControllerDetails, error)

ParseControllers parses the given YAML bytes into controllers metadata.

func ParseModels

func ParseModels(data []byte) (map[string]ControllerAccountModels, error)

ParseModels parses the given YAML bytes into models metadata.

func ReadAccountsFile

func ReadAccountsFile(file string) (map[string]*ControllerAccounts, error)

ReadAccountsFile loads all accounts defined in a given file. If the file is not found, it is not an error.

func ReadBootstrapConfigFile

func ReadBootstrapConfigFile(file string) (map[string]BootstrapConfig, error)

ReadBootstrapConfigFile loads all bootstrap configurations defined in a given file. If the file is not found, it is not an error.

func ReadControllersFile

func ReadControllersFile(file string) (map[string]ControllerDetails, error)

ReadControllersFile loads all controllers defined in a given file. If the file is not found, it is not an error.

func ReadCredentialsFile

func ReadCredentialsFile(file string) (map[string]cloud.CloudCredential, error)

ReadCredentialsFile loads all credentials defined in a given file. If the file is not found, it is not an error.

func ReadModelsFile

func ReadModelsFile(file string) (map[string]ControllerAccountModels, error)

ReadModelsFile loads all models defined in a given file. If the file is not found, it is not an error.

func ValidateAccountDetails

func ValidateAccountDetails(details AccountDetails) error

ValidateModelDetails ensures that given account details are valid.

func ValidateAccountName

func ValidateAccountName(name string) error

ValidateAccountName validates the given account name.

func ValidateBootstrapConfig

func ValidateBootstrapConfig(cfg BootstrapConfig) error

ValidateBootstrapConfig validates the given boostrap config.

func ValidateControllerDetails

func ValidateControllerDetails(details ControllerDetails) error

ValidateControllerDetails ensures that given controller details are valid.

func ValidateControllerName

func ValidateControllerName(name string) error

ValidateControllerName validates the given controller name.

func ValidateModelDetails

func ValidateModelDetails(details ModelDetails) error

ValidateModelDetails ensures that given model details are valid.

func ValidateModelName

func ValidateModelName(name string) error

ValidateModelName validates the given model name.

func WriteAccountsFile

func WriteAccountsFile(controllerAccounts map[string]*ControllerAccounts) error

WriteAccountsFile marshals to YAML details of the given accounts and writes it to the accounts file.

func WriteBootstrapConfigFile

func WriteBootstrapConfigFile(configs map[string]BootstrapConfig) error

WriteBootstrapConfigFile marshals to YAML details of the given bootstrap configurations and writes it to the bootstrap config file.

func WriteControllersFile

func WriteControllersFile(controllers map[string]ControllerDetails) error

WriteControllersFile marshals to YAML details of the given controllers and writes it to the controllers file.

func WriteCredentialsFile

func WriteCredentialsFile(credentials map[string]cloud.CloudCredential) error

WriteCredentialsFile marshals to YAML details of the given credentials and writes it to the credentials file.

func WriteModelsFile

func WriteModelsFile(models map[string]ControllerAccountModels) error

WriteModelsFile marshals to YAML details of the given models and writes it to the models file.

Types

type AccountDetails

type AccountDetails struct {
	// User is the username for the account.
	User string `yaml:"user"`

	// Password is the password for the account.
	Password string `yaml:"password,omitempty"`

	// Macaroon is a time-limited macaroon that may be
	// used to log in. This string is the JSON-encoding
	// of a gopkg.in/macaroon.v1.Macaroon.
	Macaroon string `yaml:"macaroon,omitempty"`
}

AccountDetails holds details of an account.

type AccountGetter

type AccountGetter interface {
	// AllAccounts gets all accounts for the specified controller.
	//
	// If there is no controller with the specified name, or
	// no accounts cached for the controller, an error satisfying
	// errors.IsNotFound will be returned.
	AllAccounts(controllerName string) (map[string]AccountDetails, error)

	// CurrentAccount returns the name of the current account for
	// the specified controller. If there is no current account
	// for the controller, an error satisfying errors.IsNotFound
	// is returned.
	CurrentAccount(controllerName string) (string, error)

	// AccountByName returns the account with the specified controller
	// and account names. If there exists no account with the specified
	// names, an error satisfying errors.IsNotFound will be returned.
	AccountByName(controllerName, accountName string) (*AccountDetails, error)
}

AccountGetter gets accounts.

type AccountModels

type AccountModels struct {
	// Models is the collection of models for the account. This should
	// be treated as a cache only, and not the complete set of models
	// for the account.
	Models map[string]ModelDetails `yaml:"models"`

	// CurrentModel is the name of the active model for the account.
	CurrentModel string `yaml:"current-model,omitempty"`
}

AccountModels stores per-account model information.

type AccountRemover

type AccountRemover interface {
	// RemoveAccount removes the account with the given controller and account
	// names from the accounts collection. If there is no account with the
	// specified names, an errors satisfying errors.IsNotFound will be
	// returned.
	RemoveAccount(controllerName, accountName string) error
}

AccountRemover removes accounts.

type AccountStore

type AccountStore interface {
	AccountUpdater
	AccountRemover
	AccountGetter
}

AccountStore is an amalgamation of AccountUpdater, AccountRemover, and AccountGetter.

type AccountUpdater

type AccountUpdater interface {
	// UpdateAccount adds the given account to the account collection.
	//
	// If the account does not already exist, it will be added.
	// Otherwise, it will be overwritten with the new details.
	//
	// It is currently not permitted to create multiple account entries
	// for a controller; doing so will result in an error satisfying
	// errors.IsAlreadyExists.
	UpdateAccount(controllerName, accountName string, details AccountDetails) error

	// SetCurrentAccount sets the name of the current account for
	// the specified controller. If there exists no account with
	// the specified names, an error satisfing errors.IsNotFound
	// will be returned.
	SetCurrentAccount(controllerName, accountName string) error
}

AccountUpdater stores account details.

type BootstrapConfig

type BootstrapConfig struct {
	// Config is the base configuration for the provider. This should
	// be updated with the region, endpoint and credentials.
	Config map[string]interface{} `yaml:"config"`

	// Credential is the name of the credential used to bootstrap.
	//
	// This will be empty if an auto-detected credential was used.
	Credential string `yaml:"credential,omitempty"`

	// Cloud is the name of the cloud to create the Juju controller in.
	Cloud string `yaml:"cloud"`

	// CloudRegion is the name of the region of the cloud to create
	// the Juju controller in. This will be empty for clouds without
	// regions.
	CloudRegion string `yaml:"region,omitempty"`

	// CloudEndpoint is the location of the primary API endpoint to
	// use when communicating with the cloud.
	CloudEndpoint string `yaml:"endpoint,omitempty"`

	// CloudStorageEndpoint is the location of the API endpoint to use
	// when communicating with the cloud's storage service. This will
	// be empty for clouds that have no cloud-specific API endpoint.
	CloudStorageEndpoint string `yaml:"storage-endpoint,omitempty"`
}

BootstrapConfig holds the configuration used to bootstrap a controller.

This includes all non-sensitive information required to regenerate the bootstrap configuration. A reference to the credential used will be stored, rather than the credential itself.

type BootstrapConfigGetter

type BootstrapConfigGetter interface {
	// BootstrapConfigForController gets bootstrap config for the named
	// controller.
	BootstrapConfigForController(string) (*BootstrapConfig, error)
}

BootstrapConfigGetter gets bootstrap config.

type BootstrapConfigStore

type BootstrapConfigStore interface {
	BootstrapConfigUpdater
	BootstrapConfigGetter
}

BootstrapConfigStore is an amalgamation of BootstrapConfigUpdater and BootstrapConfigGetter.

type BootstrapConfigUpdater

type BootstrapConfigUpdater interface {
	// UpdateBootstrapConfig adds the given bootstrap config to the
	// bootstrap config collection for the controller with the given
	// name.
	//
	// If the bootstrap config does not already exist, it will be added.
	// Otherwise, it will be overwritten with the new value.
	UpdateBootstrapConfig(controller string, cfg BootstrapConfig) error
}

BootstrapConfigUpdater stores bootstrap config.

type ClientStore

ClientStore is an amalgamation of AccountStore, BootstrapConfigStore, ControllerStore, CredentialStore, and ModelStore.

func NewFileClientStore

func NewFileClientStore() ClientStore

NewFileClientStore returns a new filesystem-based client store that manages files in $XDG_DATA_HOME/juju.

type ControllerAccountModels

type ControllerAccountModels struct {
	// AccountModels is the collection of account-models for the
	// controller.
	AccountModels map[string]*AccountModels `yaml:"accounts"`
}

ControllerAccountModels stores per-controller account-model information.

type ControllerAccounts

type ControllerAccounts struct {
	// Accounts is the collection of accounts for the controller.
	Accounts map[string]AccountDetails `yaml:"accounts"`

	// CurrentAccount is the name of the active account for the controller.
	CurrentAccount string `yaml:"current-account,omitempty"`
}

ControllerAccounts stores per-controller account information.

type ControllerDetails

type ControllerDetails struct {
	// UnresolvedAPIEndpoints 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.
	UnresolvedAPIEndpoints []string `yaml:"unresolved-api-endpoints,flow"`

	// ControllerUUID is the unique ID for the controller.
	ControllerUUID string `yaml:"uuid"`

	// APIEndpoints holds a list of API addresses. It may not be
	// current, and it will be empty if the environment has not been
	// bootstrapped.
	APIEndpoints []string `yaml:"api-endpoints,flow"`

	// CACert is a security certificate for this controller.
	CACert string `yaml:"ca-cert"`
}

ControllerDetails holds the details needed to connect to a controller.

type ControllerGetter

type ControllerGetter interface {
	// AllControllers gets all controllers.
	AllControllers() (map[string]ControllerDetails, error)

	// ControllerByName returns the controller with the specified name.
	// If there exists no controller with the specified name, an error
	// satisfying errors.IsNotFound will be returned.
	ControllerByName(controllerName string) (*ControllerDetails, error)
}

ControllerGetter gets controllers.

type ControllerRemover

type ControllerRemover interface {
	// RemoveController removes the controller with the given name from the
	// controllers collection. Any other controllers with matching UUIDs
	// will also be removed.
	//
	// Removing controllers will remove all information related to those
	// controllers (models, accounts, bootstrap config.)
	RemoveController(controllerName string) error
}

ControllerRemover removes controllers.

type ControllerStore

type ControllerStore interface {
	ControllerUpdater
	ControllerRemover
	ControllerGetter
}

ControllerStore is an amalgamation of ControllerUpdater, ControllerRemover, and ControllerGetter.

type ControllerUpdater

type ControllerUpdater interface {
	// UpdateController adds the given controller to the controller
	// collection.
	//
	// If the controller does not already exist, it will be added.
	// Otherwise, it will be overwritten with the new details.
	UpdateController(controllerName string, details ControllerDetails) error
}

ControllerUpdater stores controller details.

type CredentialGetter

type CredentialGetter interface {
	// CredentialForCloud gets credentials for the named cloud.
	CredentialForCloud(string) (*cloud.CloudCredential, error)

	// AllCredentials gets all credentials.
	AllCredentials() (map[string]cloud.CloudCredential, error)
}

CredentialGetter gets credentials.

type CredentialStore

type CredentialStore interface {
	CredentialGetter
	CredentialUpdater
}

CredentialStore is an amalgamation of CredentialsUpdater, and CredentialsGetter.

func NewFileCredentialStore

func NewFileCredentialStore() CredentialStore

NewFileCredentialStore returns a new filesystem-based credentials store that manages credentials in $XDG_DATA_HOME/juju.

type CredentialUpdater

type CredentialUpdater interface {
	// UpdateCredential adds the given credentials to the credentials
	// collection.
	//
	// If the cloud or credential name does not already exist, it will be added.
	// Otherwise, it will be overwritten with the new details.
	UpdateCredential(cloudName string, details cloud.CloudCredential) error
}

CredentialUpdater stores credentials.

type ModelDetails

type ModelDetails struct {
	// ModelUUID is the unique ID for the model.
	ModelUUID string `yaml:"uuid"`
}

ModelDetails holds details of a model.

type ModelGetter

type ModelGetter interface {
	// AllModels gets all models for the specified controller and
	// account.
	//
	// If there is no controller or account with the specified
	// names, or no models cached for the controller and account,
	// an error satisfying errors.IsNotFound will be returned.
	AllModels(controllerName, accountName string) (map[string]ModelDetails, error)

	// CurrentModel returns the name of the current model for
	// the specified controller and account. If there is no current
	// model for the controller and account, an error satisfying
	// errors.IsNotFound is returned.
	CurrentModel(controllerName, accountName string) (string, error)

	// ModelByName returns the model with the specified controller,
	// account, and model names. If there exists no model with the
	// specified names, an error satisfying errors.IsNotFound will
	// be returned.
	ModelByName(controllerName, accountName, modelName string) (*ModelDetails, error)
}

ModelGetter gets models.

type ModelRemover

type ModelRemover interface {
	// RemoveModel removes the model with the given controller, account,
	// and model names from the models collection. If there is no model
	// with the specified names, an errors satisfying errors.IsNotFound
	// will be returned.
	RemoveModel(controllerName, accountName, modelName string) error
}

ModelRemover removes models.

type ModelStore

type ModelStore interface {
	ModelUpdater
	ModelRemover
	ModelGetter
}

ModelStore is an amalgamation of ModelUpdater, ModelRemover, and ModelGetter.

type ModelUpdater

type ModelUpdater interface {
	// UpdateModel adds the given model to the model collection.
	//
	// If the model does not already exist, it will be added.
	// Otherwise, it will be overwritten with the new details.
	UpdateModel(controllerName, accountName, modelName string, details ModelDetails) error

	// SetCurrentModel sets the name of the current model for
	// the specified controller and account. If there exists no
	// model with the specified names, an error satisfing
	// errors.IsNotFound will be returned.
	SetCurrentModel(controllerName, accountName, modelName string) error
}

ModelUpdater stores model details.

type RegistrationInfo

type RegistrationInfo struct {
	// User is the user name to log in as.
	User string

	// Addrs contains the "host:port" addresses of the Juju
	// controller.
	Addrs []string

	// SecretKey contains the secret key to use when encrypting
	// and decrypting registration requests and responses.
	SecretKey []byte
}

RegistrationInfo contains the user/controller registration information printed by "juju add-user", and consumed by "juju register".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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