juju: github.com/juju/juju/cmd/juju/common Index | Files

package common

import "github.com/juju/juju/cmd/juju/common"

Index

Package Files

authkeys.go cloud.go cloudcredential.go controller.go errors.go flags.go format.go gui.go model.go

Variables

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.

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

func BootstrapEndpointAddresses Uses

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

BootstrapEndpointAddresses returns the addresses of the bootstrapped instance.

func BuiltInClouds Uses

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

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

func ChooseCloudRegion Uses

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 Uses

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 Uses

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

CloudOrProvider finds and returns cloud or provider.

func CloudSchemaByType Uses

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 Uses

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. gopkg.in/juju/charm.v4/actions.go cleanse

func FinalizeAuthorizedKeys Uses

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/id_dsa.pub, ~/.ssh/id_rsa.pub, and ~/.ssh/identity.pub.

func FormatConfigSchema Uses

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

func FormatTime Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

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

func IsChooseCloudRegionError Uses

func IsChooseCloudRegionError(err error) bool

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

func LastConnection Uses

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 Uses

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

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

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

func ModelSLAFromParams Uses

func ModelSLAFromParams(sla *params.ModelSLAInfo) string

func ModelSLAOwnerFromParams Uses

func ModelSLAOwnerFromParams(sla *params.ModelSLAInfo) string

func ModelUserInfoFromParams Uses

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 Uses

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

OutputUpdateCredentialModelResult prints detailed results of UpdateCredentialsCheckModels.

func OwnerQualifiedModelName Uses

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 Uses

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 Uses

func PermissionsMessage(writer io.Writer, command string)

func ProviderConfigSchemaSourceByType Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func WaitForAgentInitialisation(
    ctx *cmd.Context,
    c *modelcmd.ModelCommandBase,
    isCAASController bool,
    controllerName,
    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 Uses

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 Uses

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 Uses

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

AbsoluteFileNames returns the absolute path of any file names specified.

func (*ConfigFlag) ReadAttrs Uses

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.

func (*ConfigFlag) ReadConfigPairs Uses

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

ReadConfigPairs returns just the k=v attributes.

func (*ConfigFlag) Set Uses

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

Set implements gnuflag.Value.Set.

func (*ConfigFlag) SetPreserveStringValue Uses

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 Uses

func (f *ConfigFlag) String() string

String implements gnuflag.Value.String.

type ModelCredential Uses

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 Uses

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 Uses

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

ModelInfoFromParams translates a params.ModelInfo to ModelInfo.

type ModelMachineInfo Uses

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 Uses

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 Uses

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 Uses

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 Uses

type TermsRequiredError struct {
    Terms []string
}

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

func (*TermsRequiredError) Error Uses

func (e *TermsRequiredError) Error() string

Error implements error.

func (*TermsRequiredError) UserErr Uses

func (e *TermsRequiredError) UserErr() error

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

type TestCloudProvider Uses

type TestCloudProvider interface {
    environs.EnvironProvider
    environs.ProviderCredentialsRegister
}

TestCloudProvider is used for testing.

Package common imports 35 packages (graph) and is imported by 321 packages. Updated 2019-10-03. Refresh now. Tools for package owners.