Documentation
¶
Index ¶
- func IsQualifiedModelName(name string) bool
- func JoinOwnerModelName(owner names.UserTag, modelName string) string
- func JujuAccountsPath() string
- func JujuBootstrapConfigPath() string
- func JujuControllersPath() string
- func JujuCredentialsPath() string
- func JujuModelsPath() string
- func NewTokenStore() *ussologin.FileTokenStore
- func ParseAccounts(data []byte) (map[string]AccountDetails, error)
- func ParseBootstrapConfig(data []byte) (map[string]BootstrapConfig, error)
- func ParseModels(data []byte) (map[string]*ControllerModels, error)
- func ReadAccountsFile(file string) (map[string]AccountDetails, error)
- func ReadBootstrapConfigFile(file string) (map[string]BootstrapConfig, error)
- func ReadCredentialsFile(file string) (map[string]cloud.CloudCredential, error)
- func ReadModelsFile(file string) (map[string]*ControllerModels, error)
- func SplitModelName(name string) (string, names.UserTag, error)
- func ValidateAccountDetails(details AccountDetails) error
- func ValidateBootstrapConfig(cfg BootstrapConfig) error
- func ValidateControllerDetails(details ControllerDetails) error
- func ValidateControllerName(name string) error
- func ValidateModelDetails(details ModelDetails) error
- func ValidateModelName(name string) error
- func WriteAccountsFile(controllerAccounts map[string]AccountDetails) error
- func WriteBootstrapConfigFile(configs map[string]BootstrapConfig) error
- func WriteControllersFile(controllers *Controllers) error
- func WriteCredentialsFile(credentials map[string]cloud.CloudCredential) error
- func WriteModelsFile(models map[string]*ControllerModels) error
- type AccountDetails
- type AccountGetter
- type AccountRemover
- type AccountStore
- type AccountUpdater
- type BootstrapConfig
- type BootstrapConfigGetter
- type BootstrapConfigStore
- type BootstrapConfigUpdater
- type ClientStore
- type ControllerDetails
- type ControllerGetter
- type ControllerModels
- type ControllerRemover
- type ControllerStore
- type ControllerUpdater
- type Controllers
- type CredentialGetter
- type CredentialStore
- type CredentialUpdater
- type ModelDetails
- type ModelGetter
- type ModelRemover
- type ModelStore
- type ModelUpdater
- type RegistrationInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsQualifiedModelName ¶
IsQualifiedModelName returns true if the provided model name is qualified with an owner. The name is assumed to be either a valid qualified model name, or a valid unqualified model name.
func JoinOwnerModelName ¶
JoinOwnerModelName returns a model name qualified with the model owner.
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]AccountDetails, 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 ParseModels ¶
func ParseModels(data []byte) (map[string]*ControllerModels, error)
ParseModels parses the given YAML bytes into models metadata.
func ReadAccountsFile ¶
func ReadAccountsFile(file string) (map[string]AccountDetails, 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 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]*ControllerModels, error)
ReadModelsFile loads all models defined in a given file. If the file is not found, it is not an error.
func SplitModelName ¶
SplitModelName splits a qualified model name into the model and owner name components.
func ValidateAccountDetails ¶
func ValidateAccountDetails(details AccountDetails) error
ValidateModelDetails ensures that given account details are valid.
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 ¶
ValidateControllerName validates the given controller name.
func ValidateModelDetails ¶
func ValidateModelDetails(details ModelDetails) error
ValidateModelDetails ensures that given model details are valid.
func ValidateModelName ¶
ValidateModelName validates the given model name.
func WriteAccountsFile ¶
func WriteAccountsFile(controllerAccounts map[string]AccountDetails) 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 *Controllers) 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]*ControllerModels) 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"`
// LastKnownAccess is the last known access level for the account.
LastKnownAccess string `yaml:"last-known-access,omitempty"`
}
AccountDetails holds details of an account.
type AccountGetter ¶
type AccountGetter interface {
// AccountByName returns the account associated with the given
// controller name. If no associated account exists, an error
// satisfying errors.IsNotFound will be returned.
AccountDetails(controllerName string) (*AccountDetails, error)
}
AccountGetter gets accounts.
type AccountRemover ¶
type AccountRemover interface {
// RemoveAccount removes the account associated with the given controller.
// If there is no associated account with the
// specified names, an errors satisfying errors.IsNotFound will be
// returned.
RemoveAccount(controllerName 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 updates the account associated with the
// given controller.
UpdateAccount(controllerName string, details AccountDetails) error
}
AccountUpdater stores account details.
type BootstrapConfig ¶
type BootstrapConfig struct {
// ControllerConfig is the controller configuration.
ControllerConfig controller.Config `yaml:"controller-config"`
// Config is the complete configuration for the provider.
Config map[string]interface{} `yaml:"model-config"`
// ControllerModelUUID is the controller model UUID.
ControllerModelUUID string `yaml:"controller-model-uuid"`
// 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"`
// CloudType is the type of the cloud to create the Juju controller in.
CloudType string `yaml:"type"`
// 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"`
// CloudIdentityEndpoint is the location of the API endpoint to use
// when communicating with the cloud's identity service. This will
// be empty for clouds that have no identity-specific API endpoint.
CloudIdentityEndpoint string `yaml:"identity-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 storage-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 ¶
type ClientStore interface {
AccountStore
BootstrapConfigStore
ControllerStore
CredentialStore
ModelStore
}
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 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"`
// Cloud is the name of the cloud that this controller runs in.
Cloud string `yaml:"cloud"`
// CloudRegion is the name of the cloud region that this controller
// runs in. This will be empty for clouds without regions.
CloudRegion string `yaml:"region,omitempty"`
// AgentVersion is the version of the agent running on this controller.
// While this isn't strictly needed to connect to a controller, it is used
// in formatting show-controller output where this struct is also used.
AgentVersion string `yaml:"agent-version,omitempty"`
// ControllerMachineCount represents the number of controller machines
// It is cached here so under normal usage list-controllers
// does not need to hit the server.
ControllerMachineCount int `yaml:"controller-machine-count"`
// ActiveControllerMachineCount represents the number of controller machines
// and which are active in the HA cluster.
// It is cached here so under normal usage list-controllers
// does not need to hit the server.
ActiveControllerMachineCount int `yaml:"active-controller-machine-count"`
// ModelCount is the number of models to which a user has access.
// It is cached here so under normal usage list-controllers
// does not need to hit the server.
ModelCount *int `yaml:"model-count,omitempty"`
// MachineCount is the number of machines in all models to
// which a user has access. It is cached here so under normal
// usage list-controllers does not need to hit the server.
MachineCount *int `yaml:"machine-count,omitempty"`
}
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)
// CurrentController returns the name of the current controller.
// If there is no current controller, an error satisfying
// errors.IsNotFound will be returned.
CurrentController() (string, error)
}
ControllerGetter gets controllers.
type ControllerModels ¶
type ControllerModels struct {
// Models is the collection of models for the account, indexed
// by model name. This should be treated as a cache only, and
// not the complete set of models for the account.
Models map[string]ModelDetails `yaml:"models,omitempty"`
// CurrentModel is the name of the active model for the account.
CurrentModel string `yaml:"current-model,omitempty"`
}
ControllerModels stores per-controller account-model information.
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 {
// AddController adds the given controller to the controller
// collection.
//
// Where UpdateController is concerned with the controller name,
// AddController uses the controller UUID and will not add a
// duplicate even if the name is different.
AddController(controllerName string, details ControllerDetails) error
// UpdateController updates the given controller in the controller
// collection.
//
// If a controller of controllerName exists it will be overwritten
// with the new details.
UpdateController(controllerName string, details ControllerDetails) error
// SetCurrentController sets the name of the current controller.
// If there exists no controller with the specified name, an error
// satisfying errors.IsNotFound will be returned.
SetCurrentController(controllerName string) error
}
ControllerUpdater stores controller details.
type Controllers ¶
type Controllers struct {
// Controllers is the collection of controllers known to the client.
Controllers map[string]ControllerDetails `yaml:"controllers"`
// CurrentController is the name of the active controller.
CurrentController string `yaml:"current-controller,omitempty"`
}
Controllers stores per-client controller information.
func ParseControllers ¶
func ParseControllers(data []byte) (*Controllers, error)
ParseControllers parses the given YAML bytes into controllers metadata.
func ReadControllersFile ¶
func ReadControllersFile(file string) (*Controllers, error)
ReadControllersFile loads all controllers defined in a given file. If the file is not found, it is not an error.
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 as a map
// from model name to its details.
//
// If there is no controller with the specified
// name, or no models cached for the controller and account,
// an error satisfying errors.IsNotFound will be returned.
AllModels(controllerName string) (map[string]ModelDetails, error)
// CurrentModel returns the name of the current model for
// the specified controller. If there is no current
// model for the controller, an error satisfying
// errors.IsNotFound is returned.
CurrentModel(controllerName string) (string, error)
// ModelByName returns the model with the specified controller,
// and model name. If a model with the specified name does not
// exist, an error satisfying errors.IsNotFound will be
// returned.
ModelByName(controllerName, 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, 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, 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 satisfying
// errors.IsNotFound will be returned.
SetCurrentModel(controllerName, 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
// ControllerName contains the name that the controller has for the
// caller of "juju add-user" that will be used to suggest a name for
// the caller of "juju register".
ControllerName string
}
RegistrationInfo contains the user/controller registration information printed by "juju add-user", and consumed by "juju register".