common

package
v0.0.0-...-4bd6544 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func BuiltInClouds

func BuiltInClouds() map[string]cloud.Cloud

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

func CloudOrProvider

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

CloudOrProvider finds and returns cloud or provider.

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. gopkg.in/juju/charm.v4/actions.go 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/id_dsa.pub, ~/.ssh/id_rsa.pub, and ~/.ssh/identity.pub.

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

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

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

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 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 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 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 SetBootstrapEndpointAddress

func SetBootstrapEndpointAddress(
	store jujuclient.ControllerStore,
	controllerName string, agentVersion version.Number,
	apiPort int, environ environs.Environ,
) error

SetBootstrapEndpointAddress writes the API endpoint address of the bootstrap server, plus the agent version, into the connection information. This should only be run once directly after Bootstrap. It assumes that there is just one instance in the environment - the bootstrap instance.

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 WaitForAgentInitialisation

func WaitForAgentInitialisation(ctx *cmd.Context, c *modelcmd.ModelCommandBase, controllerName, hostedModelName string) 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.

Types

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

func (*ConfigFlag) Set

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

Set implements gnuflag.Value.Set.

func (*ConfigFlag) String

func (f *ConfigFlag) String() string

String implements gnuflag.Value.String.

type ModelInfo

type ModelInfo struct {
	Name           string                      `json:"name" yaml:"name"`
	UUID           string                      `json:"model-uuid" yaml:"model-uuid"`
	ControllerUUID string                      `json:"controller-uuid" yaml:"controller-uuid"`
	ControllerName string                      `json:"controller-name" yaml:"controller-name"`
	Owner          string                      `json:"owner" yaml:"owner"`
	Cloud          string                      `json:"cloud" yaml:"cloud"`
	CloudRegion    string                      `json:"region,omitempty" yaml:"region,omitempty"`
	ProviderType   string                      `json:"type" yaml:"type"`
	Life           string                      `json:"life" yaml:"life"`
	Status         ModelStatus                 `json:"status" yaml:"status"`
	Users          map[string]ModelUserInfo    `json:"users" yaml:"users"`
	Machines       map[string]ModelMachineInfo `json:"machines,omitempty" yaml:"machines,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" yaml:"current"`
	Message string        `json:"message,omitempty" yaml:"message,omitempty"`
	Since   string        `json:"since,omitempty" yaml:"since,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.

Jump to

Keyboard shortcuts

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