This section is empty.


View Source
var ErrMultipleDetectedCredentials = errors.New("multiple detected credentials")

ErrMultipleDetectedCredentials is the error returned by GetOrDetectCredential when multiple credentials are detected, meaning Juju cannot choose one automatically.

View Source
var ErrNoAuthorizedKeys = errors.New("no public ssh keys found")


func BootstrapEndpointAddresses

func BootstrapEndpointAddresses(
	environ environs.InstanceBroker, callContext context.ProviderCallContext,
) ([]network.ProviderAddress, error)

BootstrapEndpointAddresses returns the addresses of the bootstrapped instance.

func BuiltInClouds

func BuiltInClouds() (map[string]jujucloud.Cloud, error)

BuiltInClouds returns cloud information for those providers which are built in to Juju.

func ChooseCloudRegion

func ChooseCloudRegion(cloud jujucloud.Cloud, regionName string) (jujucloud.Region, error)

ChooseCloudRegion returns the cloud.Region to use, based on the specified region name. If no region name is specified, and there is at least one region, we use the first region in the list. If there are no regions, then we return a region with no name, having the same endpoints as the cloud.

func CloudByName

func CloudByName(cloudName string) (*jujucloud.Cloud, error)

CloudByName returns a cloud for given name regardless of whether it's public, private or builtin cloud. Not to be confused with cloud.CloudByName which does not cater for built-in clouds like localhost.

func CloudOrProvider

func CloudOrProvider(cloudName string, cloudByNameFunc func(string) (*jujucloud.Cloud, error)) (cloud *jujucloud.Cloud, err error)

CloudOrProvider finds and returns cloud or provider.

func CloudSchemaByType

func CloudSchemaByType(cloudType string) (environschema.Fields, error)

CloudSchemaByType returns the Schema for a given cloud type. If the ProviderSchema is not implemented for the given cloud type, a NotFound error is returned.

func ConformYAML

func ConformYAML(input interface{}) (interface{}, error)

ConformYAML ensures all keys of any nested maps are strings. This is necessary because YAML unmarshals map[interface{}]interface{} in nested maps, which cannot be serialized by bson. Also, handle []interface{}. cf. cleanse

func FinalizeAuthorizedKeys

func FinalizeAuthorizedKeys(ctx *cmd.Context, attrs map[string]interface{}) error

FinalizeAuthorizedKeys takes a set of configuration attributes and ensures that it has an authorized-keys setting, or returns ErrNoAuthorizedKeys if it cannot.

If the attributes contains a non-empty value for "authorized-keys", then it is left alone. If there is an "authorized-keys-path" setting, its contents will be loaded into "authorized-keys". Otherwise, the contents of standard public keys will be used: ~/.ssh/, ~/.ssh/, and ~/.ssh/

func FormatConfigSchema

func FormatConfigSchema(values interface{}) (string, error)

func FormatTime

func FormatTime(t *time.Time, formatISO bool) string

FormatTime returns a string with the local time formatted in an arbitrary format used for status or and localized tz or in UTC timezone and format RFC3339 if u is specified.

func FormatTimeAsTimestamp

func FormatTimeAsTimestamp(t *time.Time, formatISO bool) string

FormatTimeAsTimestamp formats a time.Time to a given machine readable format. Returns a string with the local time formatted or uses the localized tz or in UTC timezone. The difference between this and `common.FormatTime` is that this version drops the date part of the time.Time.

func FriendlyDuration

func FriendlyDuration(when *time.Time, now time.Time) string

FriendlyDuration renders a time pointer that we get from the API as a friendly string.

func GUIDataSourceBaseURL

func GUIDataSourceBaseURL() string

GUIDataSourceBaseURL returns the default base URL to use for the Juju GUI simplestreams data source. The default value can be overridden by setting the JUJU_GUI_SIMPLESTREAMS_URL environment variable.

func GetOrDetectCredential

func GetOrDetectCredential(
	ctx *cmd.Context,
	store jujuclient.CredentialGetter,
	provider environs.EnvironProvider,
	args modelcmd.GetCredentialsParams,
) (_ *jujucloud.Credential, chosenCredentialName, regionName string, isDetected bool, returnedErr error)

GetOrDetectCredential returns a credential to use for given cloud. This function first calls modelcmd.GetCredentials, and returns its results if it finds credentials. If modelcmd.GetCredentials cannot find a credential, and a credential has not been specified by name, then this function will attempt to detect credentials from the environment.

If multiple credentials are found in the client store, then modelcmd.ErrMultipleCredentials is returned. If multiple credentials are detected by the provider, then ErrMultipleDetectedCredentials is returned.

func HumanReadableBoolPointer

func HumanReadableBoolPointer(pointer *bool, trueValue, falseValue string) string

HumanReadableBoolPointer returns trueValue if given bool pointer contains true, falseValue otherwise.

func IsChooseCloudRegionError

func IsChooseCloudRegionError(err error) bool

IsChooseCloudRegionError reports whether or not the given error was returned from ChooseCloudRegion.

func LastConnection

func LastConnection(connectionTime *time.Time, now time.Time, exact bool) string

LastConnection turns the *time.Time returned from the API server into a user facing string with either exact time or a user friendly string based on the args.

func MaybeTermsAgreementError

func MaybeTermsAgreementError(err error) error

MaybeTermsAgreementError returns err as a *TermsAgreementError if it has a "terms agreement required" error code, otherwise it returns err unchanged.

func MissingModelNameError

func MissingModelNameError(cmdName string) error

MissingModelNameError returns an error stating that the model name is missing and provides a better UX experience to the user.

func ModelMachineInfoFromParams

func ModelMachineInfoFromParams(machines []params.ModelMachineInfo) map[string]ModelMachineInfo

ModelMachineInfoFromParams translates []params.ModelMachineInfo to a map of machine ids to ModelMachineInfo.

func ModelSLAFromParams

func ModelSLAFromParams(sla *params.ModelSLAInfo) string

func ModelSLAOwnerFromParams

func ModelSLAOwnerFromParams(sla *params.ModelSLAInfo) string

func ModelUserInfoFromParams

func ModelUserInfoFromParams(users []params.ModelUserInfo, now time.Time) map[string]ModelUserInfo

ModelUserInfoFromParams translates []params.ModelUserInfo to a map of user names to ModelUserInfo.

func OutputUpdateCredentialModelResult

func OutputUpdateCredentialModelResult(ctx *cmd.Context, models []params.UpdateCredentialModelResult, showValid bool)

OutputUpdateCredentialModelResult prints detailed results of UpdateCredentialsCheckModels.

func OwnerQualifiedModelName

func OwnerQualifiedModelName(modelName string, owner, user names.UserTag) string

OwnerQualifiedModelName returns the model name qualified with the model owner if the owner is not the same as the given canonical user name. If the owner is a local user, we omit the domain.

func ParseConstraints

func ParseConstraints(ctx *cmd.Context, cons string) (constraints.Value, error)

ParseConstraints parses the given constraints and uses WarnConstraintAliases if any aliases were used.

func PermissionsMessage

func PermissionsMessage(writer io.Writer, command string)

func ProviderConfigSchemaSourceByType

func ProviderConfigSchemaSourceByType(cloudType string) (config.ConfigSchemaSource, error)

ProviderConfigSchemaSourceByType returns a config.ConfigSchemaSource for the environ provider, found for the given cloud type, or an error.

func ReadAuthorizedKeys

func ReadAuthorizedKeys(ctx *cmd.Context, path string) (string, error)

ReadAuthorizedKeys implements the standard juju behaviour for finding authorized_keys. It returns a set of keys in in authorized_keys format (see sshd(8) for a description). If path is non-empty, it names the file to use; otherwise the user's .ssh directory will be searched. Home directory expansion will be performed on the path if it starts with a ~; if the expanded path is relative, it will be interpreted relative to $HOME/.ssh.

The result of utils/ssh.PublicKeyFiles will always be prepended to the result. In practice, this means ReadAuthorizedKeys never returns an error when the call originates in the CLI.

If no SSH keys are found, ReadAuthorizedKeys returns ErrNoAuthorizedKeys.

func RegisterCredentials

func RegisterCredentials(
	ctx *cmd.Context,
	store jujuclient.CredentialStore,
	provider environs.EnvironProvider,
	args modelcmd.RegisterCredentialsParams,
) error

RegisterCredentials will attempt to register any credentials that a provider has to offer.

func ResolveCloudCredentialTag

func ResolveCloudCredentialTag(user names.UserTag, cloud names.CloudTag, credentialName string) (names.CloudCredentialTag, error)

ResolveCloudCredentialTag takes a string which is of either the format "<credential>" or "<user>/<credential>". If the string does not include a user, then the supplied user tag is implied.

func UserFriendlyDuration

func UserFriendlyDuration(when, now time.Time) string

UserFriendlyDuration translates a time in the past into a user friendly string representation relative to the "now" time argument.

func ValidateIaasController

func ValidateIaasController(c modelcmd.CommandBase, cmdName, controllerName string, store jujuclient.ClientStore) error

ValidateIaasController returns an error if the controller is not an IAAS controller.

func WaitForAgentInitialisation

func WaitForAgentInitialisation(
	ctx *cmd.Context,
	c *modelcmd.ModelCommandBase,
	isCAASController bool,
	hostedModelName string,
) (err error)

WaitForAgentInitialisation polls the bootstrapped controller with a read-only command which will fail until the controller is fully initialised. TODO(wallyworld) - add a bespoke command to maybe the admin facade for this purpose.

func WarnConstraintAliases

func WarnConstraintAliases(ctx *cmd.Context, aliases map[string]string)

WarnConstraintAliases shows a warning to the user that they have used an alias for a constraint that might go away sometime.


type ConfigFlag

type ConfigFlag struct {
	// contains filtered or unexported fields

ConfigFlag records k=v attributes from command arguments and/or specified files containing key values.

func (*ConfigFlag) AbsoluteFileNames

func (f *ConfigFlag) AbsoluteFileNames(ctx *cmd.Context) ([]string, error)

AbsoluteFileNames returns the absolute path of any file names specified.

func (*ConfigFlag) ReadAttrs

func (f *ConfigFlag) ReadAttrs(ctx *cmd.Context) (map[string]interface{}, error)

ReadAttrs reads attributes from the specified files, and then overlays the results with the k=v attributes. TODO (stickupkid): This should only know about io.Readers and correctly handle the various path ways from that abstraction.

func (*ConfigFlag) ReadConfigPairs

func (f *ConfigFlag) ReadConfigPairs(ctx *cmd.Context) (map[string]interface{}, error)

ReadConfigPairs returns just the k=v attributes.

func (*ConfigFlag) Set

func (f *ConfigFlag) Set(s string) error

Set implements gnuflag.Value.Set. TODO (stickupkid): Clean this up to correctly handle stdin. Additionally the method is confusing and cryptic, we should improve this at some point!

func (*ConfigFlag) SetAttrsFromReader

func (f *ConfigFlag) SetAttrsFromReader(reader io.Reader) error

SetAttrsFromReader sets the attributes from a slice of bytes. The bytes are expected to be YAML parsable and align to the attrs type of map[string]interface{}. This will over write any attributes that already exist if found in the YAML configuration.

func (*ConfigFlag) SetPreserveStringValue

func (f *ConfigFlag) SetPreserveStringValue(val bool)

SetPreserveStringValue sets whether name values should be converted to a type that is inferred from their string value, by way of YAML unmarshalling,or kept as the original string value. The default behaviour is to apply YAML unmarshalling to the value.

func (*ConfigFlag) String

func (f *ConfigFlag) String() string

String implements gnuflag.Value.String.

type ModelCredential

type ModelCredential struct {
	Name     string `json:"name" yaml:"name"`
	Owner    string `json:"owner" yaml:"owner"`
	Cloud    string `json:"cloud" yaml:"cloud"`
	Validity string `json:"validity-check,omitempty" yaml:"validity-check,omitempty"`

ModelCredential contains model credential basic details.

type ModelInfo

type ModelInfo struct {
	// Name is a fully qualified model name, i.e. having the format $owner/$model.
	Name string `json:"name" yaml:"name"`

	// ShortName is un-qualified model name.
	ShortName      string                      `json:"short-name" yaml:"short-name"`
	UUID           string                      `json:"model-uuid" yaml:"model-uuid"`
	Type           model.ModelType             `json:"model-type" yaml:"model-type"`
	ControllerUUID string                      `json:"controller-uuid" yaml:"controller-uuid"`
	ControllerName string                      `json:"controller-name" yaml:"controller-name"`
	IsController   bool                        `json:"is-controller" yaml:"is-controller"`
	Owner          string                      `json:"owner" yaml:"owner"`
	Cloud          string                      `json:"cloud" yaml:"cloud"`
	CloudRegion    string                      `json:"region,omitempty" yaml:"region,omitempty"`
	ProviderType   string                      `json:"type,omitempty" yaml:"type,omitempty"`
	Life           string                      `json:"life" yaml:"life"`
	Status         *ModelStatus                `json:"status,omitempty" yaml:"status,omitempty"`
	Users          map[string]ModelUserInfo    `json:"users,omitempty" yaml:"users,omitempty"`
	Machines       map[string]ModelMachineInfo `json:"machines,omitempty" yaml:"machines,omitempty"`
	SLA            string                      `json:"sla,omitempty" yaml:"sla,omitempty"`
	SLAOwner       string                      `json:"sla-owner,omitempty" yaml:"sla-owner,omitempty"`
	AgentVersion   string                      `json:"agent-version,omitempty" yaml:"agent-version,omitempty"`
	Credential     *ModelCredential            `json:"credential,omitempty" yaml:"credential,omitempty"`

ModelInfo contains information about a model.

func ModelInfoFromParams

func ModelInfoFromParams(info params.ModelInfo, now time.Time) (ModelInfo, error)

ModelInfoFromParams translates a params.ModelInfo to ModelInfo.

type ModelMachineInfo

type ModelMachineInfo struct {
	Cores uint64 `json:"cores" yaml:"cores"`

ModelMachineInfo contains information about a machine in a model. We currently only care about showing core count, but might in the future care about memory, disks, containers etc.

type ModelStatus

type ModelStatus struct {
	Current        status.Status `json:"current,omitempty" yaml:"current,omitempty"`
	Message        string        `json:"message,omitempty" yaml:"message,omitempty"`
	Since          string        `json:"since,omitempty" yaml:"since,omitempty"`
	Migration      string        `json:"migration,omitempty" yaml:"migration,omitempty"`
	MigrationStart string        `json:"migration-start,omitempty" yaml:"migration-start,omitempty"`
	MigrationEnd   string        `json:"migration-end,omitempty" yaml:"migration-end,omitempty"`

ModelStatus contains the current status of a model.

type ModelUserInfo

type ModelUserInfo struct {
	DisplayName    string `yaml:"display-name,omitempty" json:"display-name,omitempty"`
	Access         string `yaml:"access" json:"access"`
	LastConnection string `yaml:"last-connection" json:"last-connection"`

ModelUserInfo defines the serialization behaviour of the model user information.

type PrintConfigSchema

type PrintConfigSchema struct {
	Type        string `yaml:"type,omitempty" json:"type,omitempty"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`

PrintConfigSchema is used to print model configuration schema.

type TermsRequiredError

type TermsRequiredError struct {
	Terms []string

TermsRequiredError is an error returned when agreement to terms is required.

func (*TermsRequiredError) Error

func (e *TermsRequiredError) Error() string

Error implements error.

func (*TermsRequiredError) UserErr

func (e *TermsRequiredError) UserErr() error

UserErr returns an error containing a user-friendly message describing how to agree to required terms.

type TestCloudProvider

type TestCloudProvider interface {

TestCloudProvider is used for testing.