config

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

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

Documentation

Index

Constants

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"

	// FwNone requests that no firewalling should be performed inside
	// the environment. No firewaller worker will be started. It's
	// useful for clouds without support for either global or per
	// instance security groups.
	FwNone = "none"
)
View Source
const (

	// NameKey is the key for the model's name.
	NameKey = "name"

	// TypeKey is the key for the model's cloud type.
	TypeKey = "type"

	// AgentVersionKey is the key for the model's Juju agent version.
	AgentVersionKey = "agent-version"

	// UUIDKey is the key for the model UUID attribute.
	UUIDKey = "uuid"

	// AuthorizedKeysKey is the key for the authorized-keys attribute.
	AuthorizedKeysKey = "authorized-keys"

	// ProvisionerHarvestModeKey stores the key for this setting.
	ProvisionerHarvestModeKey = "provisioner-harvest-mode"

	// AgentStreamKey stores the key for this setting.
	AgentStreamKey = "agent-stream"

	// AgentMetadataURLKey stores the key for this setting.
	AgentMetadataURLKey = "agent-metadata-url"

	// HTTPProxyKey stores the key for this setting.
	HTTPProxyKey = "http-proxy"

	// HTTPSProxyKey stores the key for this setting.
	HTTPSProxyKey = "https-proxy"

	// FTPProxyKey stores the key for this setting.
	FTPProxyKey = "ftp-proxy"

	// AptHTTPProxyKey stores the key for this setting.
	AptHTTPProxyKey = "apt-http-proxy"

	// AptHTTPSProxyKey stores the key for this setting.
	AptHTTPSProxyKey = "apt-https-proxy"

	// AptFTPProxyKey stores the key for this setting.
	AptFTPProxyKey = "apt-ftp-proxy"

	// NoProxyKey stores the key for this setting.
	NoProxyKey = "no-proxy"

	// The default block storage source.
	StorageDefaultBlockSourceKey = "storage-default-block-source"

	// ResourceTagsKey is an optional list or space-separated string
	// of k=v pairs, defining the tags for ResourceTags.
	ResourceTagsKey = "resource-tags"

	// LogForwardEnabled determines whether the log forward functionality is enabled.
	LogForwardEnabled = "logforward-enabled"

	// LogFwdSyslogHost sets the hostname:port of the syslog server.
	LogFwdSyslogHost = "syslog-host"

	// LogFwdSyslogCACert sets the certificate of the CA that signed the syslog
	// server certificate.
	LogFwdSyslogCACert = "syslog-ca-cert"

	// LogFwdSyslogClientCert sets the client certificate for syslog
	// forwarding.
	LogFwdSyslogClientCert = "syslog-client-cert"

	// LogFwdSyslogClientKey sets the client key for syslog
	// forwarding.
	LogFwdSyslogClientKey = "syslog-client-key"

	// AutomaticallyRetryHooks determines whether the uniter will
	// automatically retry a hook that has failed
	AutomaticallyRetryHooks = "automatically-retry-hooks"

	// TransmitVendorMetricsKey is the key for whether the controller sends
	// metrics collected in this model for anonymized aggregate analytics.
	TransmitVendorMetricsKey = "transmit-vendor-metrics"

	// IgnoreMachineAddresses, when true, will cause the
	// machine worker not to discover any machine addresses
	// on start up.
	IgnoreMachineAddresses = "ignore-machine-addresses"
)

TODO(katco-): Please grow this over time. Centralized place to store values of config keys. This transitions mistakes in referencing key-values to a compile-time error.

View Source
const (
	// JujuDefaultSource is used to label model config attributes that
	// come from hard coded defaults.
	JujuDefaultSource = "default"

	// JujuControllerSource is used to label model config attributes that
	// come from those associated with the controller.
	JujuControllerSource = "controller"

	// JujuRegionSource is used to label model config attributes that come from
	// those associated with the region where the model is
	// running.
	JujuRegionSource = "region"

	// JujuModelConfigSource is used to label model config attributes that
	// have been explicitly set by the user.
	JujuModelConfigSource = "model"
)

These constants define named sources of model config attributes. After a call to UpdateModelConfig, any attributes added/removed will have a source of JujuModelConfigSource.

View Source
const (
	// JujuSystemKey is the SSH key comment for Juju system keys.
	JujuSystemKey = "juju-system-key"
)

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 CoerceForStorage

func CoerceForStorage(attrs map[string]interface{}) map[string]interface{}

CoerceForStorage transforms attributes prior to being saved in a persistent store.

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 ConfigDefaults

func ConfigDefaults() map[string]interface{}

ConfigDefaults returns the config default values to be used for any new model where there is no value yet defined.

func PreferredSeries

func PreferredSeries(cfg HasDefaultSeries) string

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

func ProcessDeprecatedAttributes

func ProcessDeprecatedAttributes(attrs map[string]interface{}) map[string]interface{}

ProcessDeprecatedAttributes gathers any deprecated attributes in attrs and adds or replaces them with new name value pairs for the replacement attrs. Ths ensures that older versions of Juju which require that deprecated attribute values still be used will work as expected.

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 Schema

func Schema(extra environschema.Fields) (environschema.Fields, error)

Schema returns a configuration schema that includes both the given extra fields and all the fields defined in this package. It returns an error if extra defines any fields defined in this package.

func SpecializeCharmRepo

func SpecializeCharmRepo(repo charmrepo.Interface, cfg *Config) charmrepo.Interface

SpecializeCharmRepo customizes a repository for a given configuration. It returns a charm repository with test mode enabled if applicable.

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 AttributeDefaultValues

type AttributeDefaultValues struct {
	// Default and Controller represent the values as set at those levels.
	Default    interface{} `json:"default,omitempty" yaml:"default,omitempty"`
	Controller interface{} `json:"controller,omitempty" yaml:"controller,omitempty"`
	// Regions is a slice of Region representing the values as set in each
	// region.
	Regions []RegionDefaultValue `json:"regions,omitempty" yaml:"regions,omitempty"`
}

AttributeDefaultValues represents all the default values at each level for a given setting.

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.

"ca-cert-path" and "ca-private-key-path" are translated into the "ca-cert" and "ca-private-key" values. If not specified, CA details will be read from:

~/.local/share/juju/<name>-cert.pem
~/.local/share/juju/<name>-private-key.pem

if $XDG_DATA_HOME is defined it will be used instead of ~/.local/share

func (*Config) AgentMetadataURL

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

AgentMetadataURL returns the URL that locates the agent tarballs and metadata, and whether it has been set.

func (*Config) AgentStream

func (c *Config) AgentStream() string

AgentStream returns the simplestreams stream used to identify which tools to use when when bootstrapping or upgrading an environment.

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

func (c *Config) AptMirror() string

AptMirror sets the apt mirror for the environment.

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

func (c *Config) AutomaticallyRetryHooks() bool

AutomaticallyRetryHooks returns whether we should automatically retry hooks. By default this should be true.

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

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

DisableNetworkManagement reports whether Juju is allowed to configure and manage networking inside the environment.

func (*Config) EnableOSRefreshUpdate

func (c *Config) EnableOSRefreshUpdate() bool

EnableOSRefreshUpdate returns whether or not newly provisioned instances should run their respective OS's update capability.

func (*Config) EnableOSUpgrade

func (c *Config) EnableOSUpgrade() bool

EnableOSUpgrade returns whether or not newly provisioned instances should run their respective OS's upgrade capability.

func (*Config) FTPProxy

func (c *Config) FTPProxy() string

FTPProxy returns the ftp proxy for the environment.

func (*Config) FirewallMode

func (c *Config) FirewallMode() string

FirewallMode returns whether the firewall should manage ports per machine, globally, or not at all. (FwInstance, FwGlobal, or FwNone).

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

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

IgnoreMachineAddresses reports whether Juju will discover and store machine addresses on startup.

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

func (c *Config) LogFwdSyslog() (*syslog.RawConfig, bool)

LogFwdSyslog returns the syslog forwarding config.

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 model name.

func (*Config) NoProxy

func (c *Config) NoProxy() string

NoProxy returns the 'no proxy' for the environment.

func (*Config) ProvisionerHarvestMode

func (c *Config) ProvisionerHarvestMode() HarvestMode

ProvisionerHarvestMode reports the harvesting methodology the provisioner should take.

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

func (c *Config) ResourceTags() (map[string]string, bool)

ResourceTags returns a set of tags to set on environment resources that Juju creates and manages, if the provider supports them. These tags have no special meaning to Juju, but may be used for existing chargeback accounting schemes or other identification purposes.

func (*Config) SSLHostnameVerification

func (c *Config) SSLHostnameVerification() bool

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

func (*Config) StorageDefaultBlockSource

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

StorageDefaultBlockSource returns the default block storage source 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) TransmitVendorMetrics

func (c *Config) TransmitVendorMetrics() bool

TransmitVendorMetrics returns whether the controller sends charm-collected metrics in this model for anonymized aggregate analytics. By default this should be true.

func (*Config) Type

func (c *Config) Type() string

Type returns the model's cloud provider type.

func (*Config) UUID

func (c *Config) UUID() string

UUID returns the uuid for the model.

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 ConfigSchemaSource

type ConfigSchemaSource interface {
	// ConfigSchema returns extra config attributes specific
	// to this provider only.
	ConfigSchema() schema.Fields

	// ConfigDefaults returns the default values for the
	// provider specific config attributes.
	ConfigDefaults() schema.Defaults
}

ConfigSchemaSource instances provide information on config attributes and the default attribute values.

type ConfigValue

type ConfigValue struct {
	// Value is the configuration value.
	Value interface{}

	// Source is the name of the inherited config
	// source from where the value originates.
	Source string
}

ConfigValue encapsulates a configuration value and its source.

type ConfigValues

type ConfigValues map[string]ConfigValue

ConfigValues is a map of configuration values keyed by attribute name.

func (ConfigValues) AllAttrs

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

AllAttrs returns just the attribute values from the config.

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 HarvestMode

type HarvestMode uint32

HarvestMode is a bit field which is used to store the harvesting behavior for Juju.

const (
	// HarvestNone signifies that Juju should not harvest any
	// machines.
	HarvestNone HarvestMode = 1 << iota
	// HarvestUnknown signifies that Juju should only harvest machines
	// which exist, but we don't know about.
	HarvestUnknown
	// HarvestDestroyed signifies that Juju should only harvest
	// machines which have been explicitly released by the user
	// through a destroy of a service/model/unit.
	HarvestDestroyed
	// HarvestAll signifies that Juju should harvest both unknown and
	// destroyed instances. ♫ Don't fear the reaper. ♫
	HarvestAll HarvestMode = HarvestUnknown | HarvestDestroyed
)

func ParseHarvestMode

func ParseHarvestMode(description string) (HarvestMode, error)

ParseHarvestMode parses description of harvesting method and returns the representation.

func (HarvestMode) HarvestDestroyed

func (method HarvestMode) HarvestDestroyed() bool

Destroyed returns whether or not the Destroyed harvesting flag is set.

func (HarvestMode) HarvestNone

func (method HarvestMode) HarvestNone() bool

None returns whether or not the None harvesting flag is set.

func (HarvestMode) HarvestUnknown

func (method HarvestMode) HarvestUnknown() bool

Unknown returns whether or not the Unknown harvesting flag is set.

func (HarvestMode) String

func (method HarvestMode) String() string

String returns the description of the harvesting mode.

type HasDefaultSeries

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

type InvalidConfigValueError

type InvalidConfigValueError struct {
	// Key is the config key used to access the value.
	Key string
	// Value is the value that failed validation.
	Value string
	// Reason indicates why the value failed validation.
	Reason error
}

InvalidConfigValue is an error type for a config value that failed validation.

func (*InvalidConfigValueError) Error

func (e *InvalidConfigValueError) Error() string

Error returns the error string.

type ModelDefaultAttributes

type ModelDefaultAttributes map[string]AttributeDefaultValues

ModelDefaultAttributes is a map of configuration values to a list of possible values.

type RegionDefaultValue

type RegionDefaultValue struct {
	// Name represents the region name for this specific setting.
	Name string `json:"name" yaml:"name"`
	// Value is the value of the setting this represents in the named region.
	Value interface{} `json:"value" yaml:"value"`
}

RegionDefaultValue holds the region information for each region in DefaultSetting.

type Validator

type Validator interface {
	// Validate ensures that cfg is a valid configuration.
	// If old is not nil, Validate should use it to determine
	// whether a configuration change is valid.
	//
	// TODO(axw) Validate should just return an error. We should
	// use a separate mechanism for updating config.
	Validate(cfg, old *Config) (valid *Config, _ error)
}

Validator is an interface for validating model configuration.

Jump to

Keyboard shortcuts

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