juju: github.com/juju/juju/jujuclient Index | Files | Directories

package jujuclient

import "github.com/juju/juju/jujuclient"

Index

Package Files

accounts.go bootstrapconfig.go controllers.go credentials.go file.go interface.go mem.go models.go oauth.go registration.go validation.go

func IsQualifiedModelName Uses

func IsQualifiedModelName(name string) bool

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 Uses

func JoinOwnerModelName(owner names.UserTag, modelName string) string

JoinOwnerModelName returns a model name qualified with the model owner.

func JujuAccountsPath Uses

func JujuAccountsPath() string

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

func JujuBootstrapConfigPath Uses

func JujuBootstrapConfigPath() string

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

func JujuControllersPath Uses

func JujuControllersPath() string

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

func JujuCookiePath Uses

func JujuCookiePath(controllerName string) string

JujuCookiePath is the location where cookies associated with the given controller are expected to be found.

func JujuCredentialsPath Uses

func JujuCredentialsPath() string

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

func JujuModelsPath Uses

func JujuModelsPath() string

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

func NewTokenStore Uses

func NewTokenStore() *ussologin.FileTokenStore

NewTokenStore returns a FileTokenStore for storing the USSO oauth token

func ParseAccounts Uses

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

ParseAccounts parses the given YAML bytes into accounts metadata.

func ParseBootstrapConfig Uses

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

ParseBootstrapConfig parses the given YAML bytes into bootstrap config metadata.

func ParseModels Uses

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

ParseModels parses the given YAML bytes into models metadata.

func ReadAccountsFile Uses

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 Uses

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 Uses

func ReadCredentialsFile(file string) (*cloud.CredentialCollection, error)

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

func ReadModelsFile Uses

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 Uses

func SplitModelName(name string) (string, names.UserTag, error)

SplitModelName splits a qualified model name into the model and owner name components.

func ValidateAccountDetails Uses

func ValidateAccountDetails(details AccountDetails) error

ValidateModelDetails ensures that given account details are valid.

func ValidateBootstrapConfig Uses

func ValidateBootstrapConfig(cfg BootstrapConfig) error

ValidateBootstrapConfig validates the given boostrap config.

func ValidateControllerDetails Uses

func ValidateControllerDetails(details ControllerDetails) error

ValidateControllerDetails ensures that given controller details are valid.

func ValidateControllerName Uses

func ValidateControllerName(name string) error

ValidateControllerName validates the given controller name.

func ValidateModel Uses

func ValidateModel(name string, details ModelDetails) error

ValidateModel validates the given model name and details.

func ValidateModelDetails Uses

func ValidateModelDetails(details ModelDetails) error

ValidateModelDetails ensures that given model details are valid.

func ValidateModelName Uses

func ValidateModelName(name string) error

ValidateModelName validates the given model name.

func WriteAccountsFile Uses

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 Uses

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 Uses

func WriteControllersFile(controllers *Controllers) error

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

func WriteCredentialsFile Uses

func WriteCredentialsFile(credentials *cloud.CredentialCollection) error

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

func WriteModelsFile Uses

func WriteModelsFile(models map[string]*ControllerModels) error

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

type AccountDetails Uses

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 Uses

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 Uses

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 Uses

type AccountStore interface {
    AccountUpdater
    AccountRemover
    AccountGetter
}

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

type AccountUpdater Uses

type AccountUpdater interface {
    // UpdateAccount updates the account associated with the
    // given controller.
    UpdateAccount(controllerName string, details AccountDetails) error
}

AccountUpdater stores account details.

type BootstrapConfig Uses

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

    // CloudCACertificates contains the CACertificates necessary to
    // communicate with the cloud infrastructure.
    CloudCACertificates []string `yaml:"ca-certificates,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 Uses

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

BootstrapConfigGetter gets bootstrap config.

type BootstrapConfigStore Uses

type BootstrapConfigStore interface {
    BootstrapConfigUpdater
    BootstrapConfigGetter
}

BootstrapConfigStore is an amalgamation of BootstrapConfigUpdater and BootstrapConfigGetter.

type BootstrapConfigUpdater Uses

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 Uses

type ClientStore interface {
    AccountStore
    BootstrapConfigStore
    ControllerStore
    CredentialStore
    ModelStore
    CookieStore
}

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

func NewFileClientStore Uses

func NewFileClientStore() ClientStore

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

type ControllerDetails Uses

type ControllerDetails struct {
    // 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"`

    // DNSCache holds a map of hostname to IP addresses, holding
    // a cache of the last time the API endpoints were looked up.
    // The information held here is strictly optional so that we
    // can avoid slow DNS queries in the usual case that the controller's
    // IP addresses haven't changed since the last time we connected.
    DNSCache map[string][]string `yaml:"dns-cache,omitempty,flow"`

    // PublicDNSName holds the public host name associated with the controller.
    // If this is non-empty, it indicates that the controller will use an
    // officially signed certificate when connecting with this host name.
    PublicDNSName string `yaml:"public-hostname,omitempty"`

    // 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"`

    // CloudType is the type of the cloud that this controller runs in.
    CloudType string `yaml:"type,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"`

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

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)

    // ControllerByAPIEndpoints returns the details and name of the
    // controller where the set of API endpoints contains any of the
    // provided endpoints. If no controller can be located, an error
    // satisfying errors.IsNotFound will be returned.
    ControllerByAPIEndpoints(endpoints ...string) (*ControllerDetails, string, 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 Uses

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 Uses

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 Uses

type ControllerStore interface {
    ControllerUpdater
    ControllerRemover
    ControllerGetter
}

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

type ControllerUpdater Uses

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 Uses

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 Uses

func ParseControllers(data []byte) (*Controllers, error)

ParseControllers parses the given YAML bytes into controllers metadata.

func ReadControllersFile Uses

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

type CookieJar interface {
    http.CookieJar

    // RemoveAll removes all the cookies (note: this doesn't
    // save the cookie file).
    RemoveAll()

    // Save saves the cookies.
    Save() error
}

CookieJar is the interface implemented by cookie jars.

type CookieStore Uses

type CookieStore interface {
    CookieJar(controllerName string) (CookieJar, error)
}

CookieStore allows the retrieval of cookie jars for storage of per-controller authorization information.

type CredentialGetter Uses

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 Uses

type CredentialStore interface {
    CredentialGetter
    CredentialUpdater
}

CredentialStore is an amalgamation of CredentialsUpdater, and CredentialsGetter.

func NewFileCredentialStore Uses

func NewFileCredentialStore() CredentialStore

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

type CredentialUpdater Uses

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

type MemStore struct {
    Controllers           map[string]ControllerDetails
    CurrentControllerName string
    Models                map[string]*ControllerModels
    Accounts              map[string]AccountDetails
    Credentials           map[string]cloud.CloudCredential
    BootstrapConfig       map[string]BootstrapConfig
    CookieJars            map[string]*cookiejar.Jar
    // contains filtered or unexported fields
}

MemStore is an in-memory implementation of ClientStore.

func NewMemStore Uses

func NewMemStore() *MemStore

func (*MemStore) AccountDetails Uses

func (c *MemStore) AccountDetails(controllerName string) (*AccountDetails, error)

AccountDetails implements AccountGetter.

func (*MemStore) AddController Uses

func (c *MemStore) AddController(name string, one ControllerDetails) error

AddController implements ControllerUpdater.AddController

func (*MemStore) AllControllers Uses

func (c *MemStore) AllControllers() (map[string]ControllerDetails, error)

AllController implements ControllerGetter.AllController

func (*MemStore) AllCredentials Uses

func (c *MemStore) AllCredentials() (map[string]cloud.CloudCredential, error)

AllCredentials implements CredentialsGetter.

func (*MemStore) AllModels Uses

func (c *MemStore) AllModels(controller string) (map[string]ModelDetails, error)

AllModels implements ModelGetter.

func (*MemStore) BootstrapConfigForController Uses

func (c *MemStore) BootstrapConfigForController(controllerName string) (*BootstrapConfig, error)

BootstrapConfigForController implements BootstrapConfigGetter.

func (*MemStore) ControllerByAPIEndpoints Uses

func (c *MemStore) ControllerByAPIEndpoints(endpoints ...string) (*ControllerDetails, string, error)

ControllerByAPIEndpoints implements ControllersGetter.ControllerByAPIEndpoints

func (*MemStore) ControllerByName Uses

func (c *MemStore) ControllerByName(name string) (*ControllerDetails, error)

ControllerByName implements ControllerGetter.ControllerByName

func (*MemStore) CookieJar Uses

func (c *MemStore) CookieJar(controllerName string) (CookieJar, error)

func (*MemStore) CredentialForCloud Uses

func (c *MemStore) CredentialForCloud(cloudName string) (*cloud.CloudCredential, error)

CredentialForCloud implements CredentialsGetter.

func (*MemStore) CurrentController Uses

func (c *MemStore) CurrentController() (string, error)

CurrentController implements ControllerGetter.CurrentController

func (*MemStore) CurrentModel Uses

func (c *MemStore) CurrentModel(controller string) (string, error)

CurrentModel implements ModelGetter.

func (*MemStore) ModelByName Uses

func (c *MemStore) ModelByName(controller, model string) (*ModelDetails, error)

ModelByName implements ModelGetter.

func (*MemStore) RemoveAccount Uses

func (c *MemStore) RemoveAccount(controllerName string) error

RemoveAccount implements AccountRemover.

func (*MemStore) RemoveController Uses

func (c *MemStore) RemoveController(name string) error

RemoveController implements ControllerRemover.RemoveController

func (*MemStore) RemoveModel Uses

func (c *MemStore) RemoveModel(controller, model string) error

RemoveModel implements ModelRemover.

func (*MemStore) SetCurrentController Uses

func (c *MemStore) SetCurrentController(name string) error

SetCurrentController implements ControllerUpdater.SetCurrentController

func (*MemStore) SetCurrentModel Uses

func (c *MemStore) SetCurrentModel(controllerName, modelName string) error

SetCurrentModel implements ModelUpdater.

func (*MemStore) SetModels Uses

func (c *MemStore) SetModels(controller string, models map[string]ModelDetails) error

SetModels implements ModelUpdater.

func (*MemStore) UpdateAccount Uses

func (c *MemStore) UpdateAccount(controllerName string, details AccountDetails) error

UpdateAccount implements AccountUpdater.

func (*MemStore) UpdateBootstrapConfig Uses

func (c *MemStore) UpdateBootstrapConfig(controllerName string, cfg BootstrapConfig) error

UpdateBootstrapConfig implements BootstrapConfigUpdater.

func (*MemStore) UpdateController Uses

func (c *MemStore) UpdateController(name string, one ControllerDetails) error

UpdateController implements ControllerUpdater.UpdateController

func (*MemStore) UpdateCredential Uses

func (c *MemStore) UpdateCredential(cloudName string, details cloud.CloudCredential) error

UpdateCredential implements CredentialsUpdater.

func (*MemStore) UpdateModel Uses

func (c *MemStore) UpdateModel(controller, model string, details ModelDetails) error

UpdateModel implements ModelUpdater.

type ModelDetails Uses

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

    // ModelType is the type of model.
    ModelType model.ModelType `yaml:"type"`

    // Active branch is the current working branch for the model.
    ActiveBranch string `yaml:"branch"`
}

ModelDetails holds details of a model.

type ModelGetter Uses

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 Uses

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 Uses

type ModelStore interface {
    ModelUpdater
    ModelRemover
    ModelGetter
}

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

type ModelUpdater Uses

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

    // SetModels updates the list of currently stored controller
    // models in model store - models will be added, updated or removed from the
    // store based on the supplied models collection.
    SetModels(controllerName string, models map[string]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 Uses

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

Directories

PathSynopsis
jujuclienttesting

Package jujuclient imports 25 packages (graph) and is imported by 307 packages. Updated 2019-08-26. Refresh now. Tools for package owners.