config

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 13 Imported by: 0

Documentation

Overview

Package config handles loading configuration data, warning on missing data, and setting sane defaults.

Configuration Sources

Configuration data is loaded from two sources currently: the environment and a json config file.

Environment Variables:

The environment variables from which configuration values are loaded are documented in the README file which can be found at https://github.com/aws/amazon-ecs-agent#environment-variables.

Config file:

The config file will be loaded from the path stored in the environment key ECS_AGENT_CONFIG_FILE_PATH. It must be a JSON file of the format described by the "Config" struct below.

Index

Constants

View Source
const (
	// http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=docker
	DOCKER_RESERVED_PORT     = 2375
	DOCKER_RESERVED_SSL_PORT = 2376

	SSH_PORT = 22

	AGENT_INTROSPECTION_PORT = 51678

	DEFAULT_CLUSTER_NAME = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DEPRECATED
	// ClusterArn is the Name or full ARN of a Cluster to register into. It has
	// been deprecated (and will eventually be removed) in favor of Cluster
	ClusterArn string `deprecated:"Please use Cluster instead"`
	// Cluster can either be the Name or full ARN of a Cluster. This is the
	// cluster the agent should register this ContainerInstance into. If this
	// value is not set, it will default to "default"
	Cluster string `trim:"true"`
	// APIEndpoint is the endpoint, such as "ecs.us-east-1.amazonaws.com", to
	// make calls against. If this value is not set, it will default to the
	// endpoint for your current AWSRegion
	APIEndpoint string `trim:"true"`
	// DockerEndpoint is the address the agent will attempt to connect to the
	// Docker daemon at. This should have the same value as "DOCKER_HOST"
	// normally would to interact with the daemon. It defaults to
	// unix:///var/run/docker.sock
	DockerEndpoint string
	// AWSRegion is the region to run in (such as "us-east-1"). This value will
	// be inferred from the EC2 metadata service, but if it cannot be found this
	// will be fatal.
	AWSRegion string `missing:"fatal" trim:"true"`

	// ReservedPorts is an array of ports which should be registerd as
	// unavailable. If not set, they default to [22,2375,2376,51678].
	ReservedPorts []uint16
	// ReservedPortsUDP is an array of UDP ports which should be registered as
	// unavailable. If not set, it defaults to [].
	ReservedPortsUDP []uint16

	// DataDir is the directory data is saved to in order to preserve state
	// across agent restarts. It is only used if "Checkpoint" is true as well.
	DataDir string
	// Checkpoint configures whether data should be periodically to a checkpoint
	// file, in DataDir, such that on instance or agent restarts it will resume
	// as the same ContainerInstance. It defaults to false.
	Checkpoint bool

	// EngineAuthType configures what type of data is in EngineAuthData.
	// Supported types, right now, can be found in the dockerauth package: https://godoc.org/github.com/aws/amazon-ecs-agent/agent/engine/dockerauth
	EngineAuthType string `trim:"true"`
	// EngineAuthData contains authentication data. Please see the documentation
	// for EngineAuthType for more information.
	EngineAuthData *SensitiveRawMessage

	// UpdatesEnabled specifies whether updates should be applied to this agent.
	// Default true
	UpdatesEnabled bool
	// UpdateDownloadDir specifies where new agent versions should be placed
	// within the container in order for the external updating process to
	// correctly handle them.
	UpdateDownloadDir string

	// DisableMetrics configures whether task utilization metrics should be
	// sent to the ECS telemetry endpoint
	DisableMetrics bool

	// DockerGraphPath specifies the path for docker graph directory.
	DockerGraphPath string

	// ReservedMemory specifies the amount of memory (in MB) to reserve for things
	// other than containers managed by ECS
	ReservedMemory uint16

	// AvailableLoggingDrivers specifies the logging drivers available for use
	// with Docker.  If not set, it defaults to ["json-file"].
	AvailableLoggingDrivers []dockerclient.LoggingDriver

	// PrivilegedDisabled specified whether the Agent is capable of launching
	// tasks with privileged containers
	PrivilegedDisabled bool

	// SELinxuCapable specifies whether the Agent is capable of using SELinux
	// security options
	SELinuxCapable bool

	// AppArmorCapable specifies whether the Agent is capable of using AppArmor
	// security options
	AppArmorCapable bool
}

func DefaultConfig

func DefaultConfig() Config

func EC2MetadataConfig

func EC2MetadataConfig(ec2client ec2.EC2MetadataClient) Config

func EnvironmentConfig

func EnvironmentConfig() Config

EnvironmentConfig reads the given configs from the environment and attempts to convert them to the given type

func FileConfig

func FileConfig() Config

func NewConfig

func NewConfig(ec2client ec2.EC2MetadataClient) (config *Config, err error)

NewConfig returns a config struct created by merging environment variables, a config file, and EC2 Metadata info. The 'config' struct it returns can be used, even if an error is returned. An error is returned, however, if the config is incomplete in some way that is considered fatal.

func (*Config) Merge

func (lhs *Config) Merge(rhs Config) *Config

Merge merges two config files, preferring the ones on the left. Any nil or zero values present in the left that are not present in the right will be overridden

func (*Config) String added in v1.2.1

func (config *Config) String() string

String returns a lossy string representation of the config suitable for human readable display. Consequently, it *should not* return any sensitive information.

type ConfigReader

type ConfigReader interface {
	ReadConfig() *Config
}

type SensitiveRawMessage added in v1.5.0

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

SensitiveRawMessage is a struct to store some data that should not be logged or printed. This struct is a Stringer which will not print its contents with 'String'. It is a json.Marshaler and json.Unmarshaler and will present its actual contents in plaintext when read/written from/to json.

func NewSensitiveRawMessage added in v1.5.0

func NewSensitiveRawMessage(data json.RawMessage) *SensitiveRawMessage

NewSensitiveRawMessage returns a new encapsulated json.RawMessage that cannot be accidentally logged via .String/.GoString/%v/%#v

func (SensitiveRawMessage) Contents added in v1.5.0

func (data SensitiveRawMessage) Contents() json.RawMessage

func (SensitiveRawMessage) GoString added in v1.5.0

func (data SensitiveRawMessage) GoString() string

func (SensitiveRawMessage) MarshalJSON added in v1.5.0

func (data SensitiveRawMessage) MarshalJSON() ([]byte, error)

func (SensitiveRawMessage) String added in v1.5.0

func (data SensitiveRawMessage) String() string

func (*SensitiveRawMessage) UnmarshalJSON added in v1.5.0

func (data *SensitiveRawMessage) UnmarshalJSON(jsonData []byte) error

Jump to

Keyboard shortcuts

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