config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Flags is the list of all CLI flags accepted by travis-worker
	Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "provider-name",
			Value:  defaultProviderName,
			Usage:  "The name of the provider to use. See below for provider-specific configuration",
			EnvVar: twEnvVars("PROVIDER_NAME"),
		},
		cli.StringFlag{
			Name:   "queue-type",
			Value:  defaultQueueType,
			Usage:  `The name of the queue type to use ("amqp" or "file")`,
			EnvVar: twEnvVars("QUEUE_TYPE"),
		},
		cli.StringFlag{
			Name:   "amqp-uri",
			Value:  defaultAmqpURI,
			Usage:  `The URI to the AMQP server to connect to (only valid for "amqp" queue type)`,
			EnvVar: twEnvVars("AMQP_URI"),
		},
		cli.StringFlag{
			Name:   "base-dir",
			Value:  defaultBaseDir,
			Usage:  `The base directory for file-based queues (only valid for "file" queue type)`,
			EnvVar: twEnvVars("BASE_DIR"),
		},
		cli.DurationFlag{
			Name:   "file-polling-interval",
			Value:  defaultFilePollingInterval,
			Usage:  `The interval at which file-based queues are checked (only valid for "file" queue type)`,
			EnvVar: twEnvVars("FILE_POLLING_INTERVAL"),
		},
		cli.IntFlag{
			Name:   "pool-size",
			Value:  defaultPoolSize,
			Usage:  "The size of the processor pool, affecting the number of jobs this worker can run in parallel",
			EnvVar: twEnvVars("POOL_SIZE"),
		},
		cli.StringFlag{
			Name:   "build-api-uri",
			Usage:  "The full URL to the build API endpoint to use. Note that this also requires the path of the URL. If a username is included in the URL, this will be translated to a token passed in the Authorization header",
			EnvVar: twEnvVars("BUILD_API_URI"),
		},
		cli.StringFlag{
			Name:   "queue-name",
			Usage:  "The AMQP queue to subscribe to for jobs",
			EnvVar: twEnvVars("QUEUE_NAME"),
		},
		cli.StringFlag{
			Name:   "librato-email",
			Usage:  "Librato metrics account email",
			EnvVar: twEnvVars("LIBRATO_EMAIL"),
		},
		cli.StringFlag{
			Name:   "librato-token",
			Usage:  "Librato metrics account token",
			EnvVar: twEnvVars("LIBRATO_TOKEN"),
		},
		cli.StringFlag{
			Name:   "librato-source",
			Value:  defaultHostname,
			Usage:  "Librato metrics source name",
			EnvVar: twEnvVars("LIBRATO_SOURCE"),
		},
		cli.StringFlag{
			Name:   "sentry-dsn",
			Usage:  "The DSN to send Sentry events to",
			EnvVar: twEnvVars("SENTRY_DSN"),
		},
		cli.StringFlag{
			Name:   "hostname",
			Value:  defaultHostname,
			Usage:  "Host name used in log output to identify the source of a job",
			EnvVar: twEnvVars("HOSTNAME"),
		},
		cli.StringFlag{
			Name:   "default-language",
			Value:  defaultLanguage,
			Usage:  "Default \"language\" value for each job",
			EnvVar: twEnvVars("DEFAULT_LANGUAGE"),
		},
		cli.StringFlag{
			Name:   "default-dist",
			Value:  defaultDist,
			Usage:  "Default \"dist\" value for each job",
			EnvVar: twEnvVars("DEFAULT_DIST"),
		},
		cli.StringFlag{
			Name:   "default-group",
			Value:  defaultGroup,
			Usage:  "Default \"group\" value for each job",
			EnvVar: twEnvVars("DEFAULT_GROUP"),
		},
		cli.StringFlag{
			Name:   "default-os",
			Value:  defaultOS,
			Usage:  "Default \"os\" value for each job",
			EnvVar: twEnvVars("DEFAULT_OS"),
		},
		cli.DurationFlag{
			Name:   "hard-timeout",
			Value:  defaultHardTimeout,
			Usage:  "The outermost (maximum) timeout for a given job, at which time the job is cancelled",
			EnvVar: twEnvVars("HARD_TIMEOUT"),
		},
		cli.DurationFlag{
			Name:   "log-timeout",
			Value:  defaultLogTimeout,
			Usage:  "The timeout for a job that's not outputting anything",
			EnvVar: twEnvVars("LOG_TIMEOUT"),
		},

		cli.DurationFlag{
			Name:   "build-cache-fetch-timeout",
			Value:  defaultBuildCacheFetchTimeout,
			EnvVar: twEnvVars("BUILD_CACHE_FETCH_TIMEOUT"),
		},
		cli.DurationFlag{
			Name:   "build-cache-push-timeout",
			Value:  defaultBuildCachePushTimeout,
			EnvVar: twEnvVars("BUILD_CACHE_PUSH_TIMEOUT"),
		},
		cli.StringFlag{
			Name:   "build-apt-cache",
			EnvVar: twEnvVars("BUILD_APT_CACHE"),
		},
		cli.StringFlag{
			Name:   "build-npm-cache",
			EnvVar: twEnvVars("BUILD_NPM_CACHE"),
		},
		cli.BoolFlag{
			Name:   "build-paranoid",
			EnvVar: twEnvVars("BUILD_PARANOID"),
		},
		cli.BoolFlag{
			Name:   "build-fix-resolv-conf",
			EnvVar: twEnvVars("BUILD_FIX_RESOLV_CONF"),
		},
		cli.BoolFlag{
			Name:   "build-fix-etc-hosts",
			EnvVar: twEnvVars("BUILD_FIX_ETC_HOSTS"),
		},
		cli.StringFlag{
			Name:   "build-cache-type",
			EnvVar: twEnvVars("BUILD_CACHE_TYPE"),
		},
		cli.StringFlag{
			Name:   "build-cache-s3-scheme",
			EnvVar: twEnvVars("BUILD_CACHE_S3_SCHEME"),
		},
		cli.StringFlag{
			Name:   "build-cache-s3-region",
			EnvVar: twEnvVars("BUILD_CACHE_S3_REGION"),
		},
		cli.StringFlag{
			Name:   "build-cache-s3-bucket",
			EnvVar: twEnvVars("BUILD_CACHE_S3_BUCKET"),
		},
		cli.StringFlag{
			Name:   "build-cache-s3-access-key-id",
			EnvVar: twEnvVars("BUILD_CACHE_S3_ACCESS_KEY_ID"),
		},
		cli.StringFlag{
			Name:   "build-cache-s3-secret-access-key",
			EnvVar: twEnvVars("BUILD_CACHE_S3_SECRET_ACCESS_KEY"),
		},

		cli.StringFlag{
			Name:   "skip-shutdown-on-log-timeout",
			Usage:  "Special-case mode to aid with debugging timed out jobs",
			EnvVar: twEnvVars("SKIP_SHUTDOWN_ON_LOG_TIMEOUT"),
		},
		cli.BoolFlag{
			Name:   "build-api-insecure-skip-verify",
			Usage:  "Skip build API TLS verification (useful for Enterprise and testing)",
			EnvVar: twEnvVars("BUILD_API_INSECURE_SKIP_VERIFY"),
		},
		cli.StringFlag{
			Name:   "pprof-port",
			Usage:  "enable pprof http endpoint at port",
			EnvVar: twEnvVars("PPROF_PORT"),
		},
		cli.BoolFlag{
			Name:   "silence-metrics",
			Usage:  "silence metrics logging in case no Librato creds have been provided",
			EnvVar: twEnvVars("SILENCE_METRICS"),
		},
		cli.BoolFlag{
			Name:   "echo-config",
			Usage:  "echo parsed config and exit",
			EnvVar: twEnvVars("ECHO_CONFIG"),
		},
		cli.BoolFlag{
			Name:   "list-backend-providers",
			Usage:  "echo backend provider list and exit",
			EnvVar: twEnvVars("LIST_BACKEND_PROVIDERS"),
		},
		cli.BoolFlag{
			Name:   "debug",
			Usage:  "set log level to debug",
			EnvVar: twEnvVars("DEBUG"),
		},
	}
)

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
	QueueType           string
	AmqpURI             string
	BaseDir             string
	FilePollingInterval time.Duration
	PoolSize            int
	BuildAPIURI         string
	ProviderConfig      *ProviderConfig
	QueueName           string
	LibratoEmail        string
	LibratoToken        string
	LibratoSource       string
	SentryDSN           string
	Hostname            string
	DefaultLanguage     string
	DefaultDist         string
	DefaultGroup        string
	DefaultOS           string
	HardTimeout         time.Duration
	LogTimeout          time.Duration

	BuildAPIInsecureSkipVerify bool
	SkipShutdownOnLogTimeout   bool

	// build script generator options
	BuildCacheFetchTimeout      time.Duration
	BuildCachePushTimeout       time.Duration
	BuildAptCache               string
	BuildNpmCache               string
	BuildParanoid               bool
	BuildFixResolvConf          bool
	BuildFixEtcHosts            bool
	BuildCacheType              string
	BuildCacheS3Scheme          string
	BuildCacheS3Region          string
	BuildCacheS3Bucket          string
	BuildCacheS3AccessKeyID     string
	BuildCacheS3SecretAccessKey string
}

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