config

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2016 License: MIT Imports: 10 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Flags is the list of all CLI flags accepted by travis-worker
	Flags = defFlags(defs)
)

Functions

func WriteEnvConfig

func WriteEnvConfig(cfg *Config, out io.Writer)

WriteEnvConfig writes the given configuration to out. The format of the output is a list of environment variables settings suitable to be sourced by a Bourne-like shell.

Types

type Config

type Config struct {
	ProviderName    string `config:"provider-name"`
	QueueType       string `config:"queue-type"`
	AmqpURI         string `config:"amqp-uri"`
	AmqpInsecure    bool   `config:"amqp-insecure"`
	BaseDir         string `config:"base-dir"`
	PoolSize        int    `config:"pool-size"`
	BuildAPIURI     string `config:"build-api-uri"`
	QueueName       string `config:"queue-name"`
	LibratoEmail    string `config:"librato-email"`
	LibratoToken    string `config:"librato-token"`
	LibratoSource   string `config:"librato-source"`
	SentryDSN       string `config:"sentry-dsn"`
	Hostname        string `config:"hostname"`
	DefaultLanguage string `config:"default-language"`
	DefaultDist     string `config:"default-dist"`
	DefaultGroup    string `config:"default-group"`
	DefaultOS       string `config:"default-os"`

	FilePollingInterval time.Duration `config:"file-polling-interval"`
	HardTimeout         time.Duration `config:"hard-timeout"`
	LogTimeout          time.Duration `config:"log-timeout"`
	ScriptUploadTimeout time.Duration `config:"script-upload-timeout"`
	StartupTimeout      time.Duration `config:"startup-timeout"`

	SentryHookErrors           bool `config:"sentry-hook-errors"`
	BuildAPIInsecureSkipVerify bool `config:"build-api-insecure-skip-verify"`
	SkipShutdownOnLogTimeout   bool `config:"skip-shutdown-on-log-timeout"`

	// build script generator options
	BuildCacheFetchTimeout time.Duration `config:"build-cache-fetch-timeout"`
	BuildCachePushTimeout  time.Duration `config:"build-cache-push-timeout"`

	BuildParanoid      bool `config:"build-paranoid"`
	BuildFixResolvConf bool `config:"build-fix-resolv-conf"`
	BuildFixEtcHosts   bool `config:"build-fix-etc-hosts"`

	BuildAptCache               string `config:"build-apt-cache"`
	BuildNpmCache               string `config:"build-npm-cache"`
	BuildCacheType              string `config:"build-cache-type"`
	BuildCacheS3Scheme          string `config:"build-cache-s3-scheme"`
	BuildCacheS3Region          string `config:"build-cache-s3-region"`
	BuildCacheS3Bucket          string `config:"build-cache-s3-bucket"`
	BuildCacheS3AccessKeyID     string `config:"build-cache-s3-access-key-id"`
	BuildCacheS3SecretAccessKey string `config:"build-cache-s3-secret-access-key"`

	ProviderConfig *ProviderConfig
}

Config contains all the configuration needed to run the worker.

func FromCLIContext added in v1.3.0

func FromCLIContext(c *cli.Context) *Config

FromCLIContext creates a Config using a cli.Context by pulling configuration from the flags in the context.

type ConfigDef

type ConfigDef struct {
	FieldName string
	Name      string
	EnvVar    string
	Flag      cli.Flag
	HasField  bool
}

func NewConfigDef

func NewConfigDef(fieldName string, flag cli.Flag) *ConfigDef

type ProviderConfig

type ProviderConfig struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ProviderConfig is the part of a configuration specific to a provider.

func ProviderConfigFromEnviron

func ProviderConfigFromEnviron(providerName string) *ProviderConfig

ProviderConfigFromEnviron dynamically builds a *ProviderConfig from the environment by loading values from keys with prefixes that match either the uppercase provider name + "_" or "TRAVIS_WORKER_" + uppercase provider name + "_", e.g., for provider "foo":

env: TRAVIS_WORKER_FOO_BAR=ham FOO_BAZ=bones
map equiv: {"BAR": "ham", "BAZ": "bones"}

func ProviderConfigFromMap added in v1.3.0

func ProviderConfigFromMap(cfgMap map[string]string) *ProviderConfig

ProviderConfigFromMap creates a provider configuration backed by the given map. Useful for testing a provider.

func (*ProviderConfig) Each added in v1.3.0

func (pc *ProviderConfig) Each(f func(string, string))

Each loops over all configuration settings and calls the given function with the key and value. The settings are sorted so f i called with the keys in alphabetical order.

func (*ProviderConfig) Get

func (pc *ProviderConfig) Get(key string) string

Get the value of a setting with the given key. The empty string is returned if the setting could not be found.

func (*ProviderConfig) GoString

func (pc *ProviderConfig) GoString() string

GoString formats the ProviderConfig as valid Go syntax. This makes ProviderConfig implement fmt.GoStringer.

func (*ProviderConfig) IsSet

func (pc *ProviderConfig) IsSet(key string) bool

IsSet returns true if a setting with the given key exists, or false if it does not.

func (*ProviderConfig) Set

func (pc *ProviderConfig) Set(key, value string)

Set the value of a setting with the given key.

func (*ProviderConfig) Unset added in v1.3.0

func (pc *ProviderConfig) Unset(key string)

Unset removes the given key from the config map

Jump to

Keyboard shortcuts

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