config

package
v0.0.0-...-732aecd Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2014 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthKeysConfig is the configuration key for authorised keys.
	AuthKeysConfig = "authorized-keys"
	// JujuSystemKey is the SSH key comment for Juju system keys.
	JujuSystemKey = "juju-system-key"
)
View Source
const (
	// FwInstance requests the use of an individual firewall per instance.
	FwInstance = "instance"

	// FwGlobal requests the use of a single firewall group for all machines.
	// When ports are opened for one machine, all machines will have the same
	// port opened.
	FwGlobal = "global"

	// DefaultStatePort is the default port the state server is listening on.
	DefaultStatePort int = 37017

	// DefaultApiPort is the default port the API server is listening on.
	DefaultAPIPort int = 17070

	// DefaultSyslogPort is the default port that the syslog UDP/TCP listener is
	// listening on.
	DefaultSyslogPort int = 6514

	// DefaultBootstrapSSHTimeout is the amount of time to wait
	// contacting a state server, in seconds.
	DefaultBootstrapSSHTimeout int = 600

	// DefaultBootstrapSSHRetryDelay is the amount of time between
	// attempts to connect to an address, in seconds.
	DefaultBootstrapSSHRetryDelay int = 5

	// DefaultBootstrapSSHAddressesDelay is the amount of time between
	// refreshing the addresses, in seconds. Not too frequent, as we
	// refresh addresses from the provider each time.
	DefaultBootstrapSSHAddressesDelay int = 10
)

Variables

This section is empty.

Functions

func AptProxyConfigMap

func AptProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}

AptProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.

func ConcatAuthKeys

func ConcatAuthKeys(a, b string) string

ConcatAuthKeys concatenates the two sets of authorised keys, interposing a newline if necessary, because authorised keys are newline-separated.

func LatestLtsSeries

func LatestLtsSeries() string

func PreferredSeries

func PreferredSeries(cfg HasDefaultSeries) string

PreferredSeries returns the preferred series to use when a charm does not explicitly specify a series.

func ProxyConfigMap

func ProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}

ProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.

func ReadAuthorizedKeys

func ReadAuthorizedKeys(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.

func SpecializeCharmRepo

func SpecializeCharmRepo(repo charm.Repository, cfg *Config) charm.Repository

SpecializeCharmRepo returns a repository customized for given configuration. It adds authentication if necessary and sets a charm store's testMode flag.

func Validate

func Validate(cfg, old *Config) error

Validate ensures that config is a valid configuration. If old is not nil, it holds the previous environment configuration for consideration when validating changes.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds an immutable environment configuration.

func New

func New(withDefaults Defaulting, attrs map[string]interface{}) (*Config, error)

New returns a new configuration. Fields that are common to all environment providers are verified. If useDefaults is UseDefaults, default values will be taken from the environment.

Specifically, the "authorized-keys-path" key is translated into "authorized-keys" by loading the content from respective file. Similarly, "ca-cert-path" and "ca-private-key-path" are translated into the "ca-cert" and "ca-private-key" values. If not specified, authorized SSH keys and CA details will be read from:

~/.ssh/id_dsa.pub
~/.ssh/id_rsa.pub
~/.ssh/identity.pub
~/.juju/<name>-cert.pem
~/.juju/<name>-private-key.pem

The required keys (after any files have been read) are "name", "type" and "authorized-keys", all of type string. Additional keys recognised are "agent-version" (string) and "development" (bool) as well as charm-store-auth (string containing comma-separated key=value pairs).

func (*Config) APIPort

func (c *Config) APIPort() int

APIPort returns the API server port for the environment.

func (*Config) AdminSecret

func (c *Config) AdminSecret() string

AdminSecret returns the administrator password. It's empty if the password has not been set.

func (*Config) AgentVersion

func (c *Config) AgentVersion() (version.Number, bool)

AgentVersion returns the proposed version number for the agent tools, and whether it has been set. Once an environment is bootstrapped, this must always be valid.

func (*Config) AllAttrs

func (c *Config) AllAttrs() map[string]interface{}

AllAttrs returns a copy of the raw configuration attributes.

func (*Config) Apply

func (c *Config) Apply(attrs map[string]interface{}) (*Config, error)

Apply returns a new configuration that has the attributes of c plus attrs.

func (*Config) AptFtpProxy

func (c *Config) AptFtpProxy() string

AptFtpProxy returns the apt ftp proxy for the environment. Falls back to the default ftp-proxy if not specified.

func (*Config) AptHttpProxy

func (c *Config) AptHttpProxy() string

AptHttpProxy returns the apt http proxy for the environment. Falls back to the default http-proxy if not specified.

func (*Config) AptHttpsProxy

func (c *Config) AptHttpsProxy() string

AptHttpsProxy returns the apt https proxy for the environment. Falls back to the default https-proxy if not specified.

func (*Config) AptProxySettings

func (c *Config) AptProxySettings() proxy.Settings

AptProxySettings returns all three proxy settings; http, https and ftp.

func (*Config) AuthorizedKeys

func (c *Config) AuthorizedKeys() string

AuthorizedKeys returns the content for ssh's authorized_keys file.

func (*Config) BootstrapSSHOpts

func (c *Config) BootstrapSSHOpts() SSHTimeoutOpts

BootstrapSSHOpts returns the SSH timeout and retry delays used during bootstrap.

func (*Config) CACert

func (c *Config) CACert() (string, bool)

CACert returns the certificate of the CA that signed the state server certificate, in PEM format, and whether the setting is available.

func (*Config) CAPrivateKey

func (c *Config) CAPrivateKey() (key string, ok bool)

CAPrivateKey returns the private key of the CA that signed the state server certificate, in PEM format, and whether the setting is available.

func (*Config) CharmStoreAuth

func (c *Config) CharmStoreAuth() (string, bool)

Auth token sent to charm store

func (*Config) DefaultSeries

func (c *Config) DefaultSeries() (string, bool)

DefaultSeries returns the configured default Ubuntu series for the environment, and whether the default series was explicitly configured on the environment.

func (*Config) Development

func (c *Config) Development() bool

Development returns whether the environment is in development mode.

func (*Config) FirewallMode

func (c *Config) FirewallMode() string

FirewallMode returns whether the firewall should manage ports per machine or global (FwInstance or FwGlobal)

func (*Config) FtpProxy

func (c *Config) FtpProxy() string

FtpProxy returns the ftp proxy for the environment.

func (*Config) GenerateStateServerCertAndKey

func (cfg *Config) GenerateStateServerCertAndKey() (string, string, error)

GenerateStateServerCertAndKey makes sure that the config has a CACert and CAPrivateKey, generates and retruns new certificate and key.

func (*Config) HttpProxy

func (c *Config) HttpProxy() string

HttpProxy returns the http proxy for the environment.

func (*Config) HttpsProxy

func (c *Config) HttpsProxy() string

HttpsProxy returns the https proxy for the environment.

func (*Config) ImageMetadataURL

func (c *Config) ImageMetadataURL() (string, bool)

ImageMetadataURL returns the URL at which the metadata used to locate image ids is located, and wether it has been set.

func (*Config) ImageStream

func (c *Config) ImageStream() string

ImageStream returns the simplestreams stream used to identify which image ids to search when starting an instance.

func (*Config) LXCUseClone

func (c *Config) LXCUseClone() (bool, bool)

LXCUseClone reports whether the LXC provisioner should create a template and use cloning to speed up container provisioning.

func (*Config) LXCUseCloneAUFS

func (c *Config) LXCUseCloneAUFS() (bool, bool)

LXCUseCloneAUFS reports whether the LXC provisioner should create a lxc clone using aufs if available.

func (*Config) LoggingConfig

func (c *Config) LoggingConfig() string

LoggingConfig returns the configuration string for the loggers.

func (*Config) Name

func (c *Config) Name() string

Name returns the environment name.

func (*Config) NoProxy

func (c *Config) NoProxy() string

NoProxy returns the 'no proxy' for the environment.

func (*Config) ProvisionerSafeMode

func (c *Config) ProvisionerSafeMode() bool

ProvisionerSafeMode reports whether the provisioner should not destroy machines it does not know about.

func (*Config) ProxySSH

func (c *Config) ProxySSH() bool

ProxySSH returns a flag indicating whether SSH commands should be proxied through the API server.

func (*Config) ProxySettings

func (c *Config) ProxySettings() proxy.Settings

ProxySettings returns all four proxy settings; http, https, ftp, and no proxy.

func (*Config) Remove

func (c *Config) Remove(attrs []string) (*Config, error)

Remove returns a new configuration that has the attributes of c minus attrs.

func (*Config) RsyslogCACert

func (c *Config) RsyslogCACert() string

RsyslogCACert returns the certificate of the CA that signed the rsyslog certificate, in PEM format, or nil if one hasn't been generated yet.

func (*Config) SSLHostnameVerification

func (c *Config) SSLHostnameVerification() bool

SSLHostnameVerification returns weather the environment has requested SSL hostname verification to be enabled.

func (*Config) StatePort

func (c *Config) StatePort() int

StatePort returns the state server port for the environment.

func (*Config) SyslogPort

func (c *Config) SyslogPort() int

SyslogPort returns the syslog port for the environment.

func (*Config) TestMode

func (c *Config) TestMode() bool

TestMode indicates if the environment is intended for testing. In this case, accessing the charm store does not affect statistical data of the store.

func (*Config) ToolsURL

func (c *Config) ToolsURL() (string, bool)

ToolsURL returns the URL that locates the tools tarballs and metadata, and whether it has been set.

func (*Config) Type

func (c *Config) Type() string

Type returns the environment type.

func (*Config) UnknownAttrs

func (c *Config) UnknownAttrs() map[string]interface{}

UnknownAttrs returns a copy of the raw configuration attributes that are supposedly specific to the environment type. They could also be wrong attributes, though. Only the specific environment implementation can tell.

func (*Config) ValidateUnknownAttrs

func (cfg *Config) ValidateUnknownAttrs(fields schema.Fields, defaults schema.Defaults) (map[string]interface{}, error)

ValidateUnknownAttrs checks the unknown attributes of the config against the supplied fields and defaults, and returns an error if any fails to validate. Unknown fields are warned about, but preserved, on the basis that they are reasonably likely to have been written by or for a version of juju that does recognise the fields, but that their presence is still anomalous to some degree and should be flagged (and that there is thereby a mechanism for observing fields that really are typos etc).

type Defaulting

type Defaulting bool

Defaulting is a value that specifies whether a configuration creator should use defaults from the environment.

const (
	UseDefaults Defaulting = true
	NoDefaults  Defaulting = false
)

type HasDefaultSeries

type HasDefaultSeries interface {
	DefaultSeries() (string, bool)
}

type SSHTimeoutOpts

type SSHTimeoutOpts struct {
	// Timeout is the amount of time to wait contacting a state
	// server.
	Timeout time.Duration

	// RetryDelay is the amount of time between attempts to connect to
	// an address.
	RetryDelay time.Duration

	// AddressesDelay is the amount of time between refreshing the
	// addresses.
	AddressesDelay time.Duration
}

SSHTimeoutOpts lists the amount of time we will wait for various parts of the SSH connection to complete. This is similar to DialOpts, see http://pad.lv/1258889 about possibly deduplicating them.

type Specializer

type Specializer interface {
	WithAuthAttrs(string) charm.Repository
	WithTestMode(testMode bool) charm.Repository
}

Jump to

Keyboard shortcuts

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