config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Register: false,
	Proxy:    false,

	Service: Service{
		Name: "",
		Tags: nil,
	},
	Endpoint: Endpoint{
		Host: "",
		Port: 0,
		Type: "http",
	},

	Registry: Registry{
		URL:   "",
		Token: "",
		Poll:  time.Duration(15 * time.Second),
	},
	Controller: Controller{
		URL:   "",
		Token: "",
		Poll:  time.Duration(15 * time.Second),
	},

	Supervise: false,
	App:       nil,

	Log:            false,
	LogstashServer: "",

	LogLevel: "info",
}

DefaultConfig defines default values for the various configuration options

View Source
var Flags = []cli.Flag{
	cli.StringFlag{
		Name:   configFlag,
		EnvVar: envVar(configFlag),
		Usage:  "Load configuration from file",
	},
	cli.BoolFlag{
		Name:   registerFlag,
		EnvVar: envVar(registerFlag),
		Usage:  "Enable automatic service registration and heartbeat",
	},
	cli.BoolFlag{
		Name:   proxyFlag,
		EnvVar: envVar(proxyFlag),
		Usage:  "Enable automatic service discovery and load balancing across services using NGINX",
	},
	cli.StringFlag{
		Name:   serviceFlag,
		EnvVar: envVar(serviceFlag),
		Usage:  "Service name to register with",
	},
	cli.StringFlag{
		Name:   endpointHostFlag,
		EnvVar: envVar(endpointHostFlag),
		Usage:  "Service endpoint host name (local IP is used if none specified)",
	},
	cli.IntFlag{
		Name:   endpointPortFlag,
		EnvVar: envVar(endpointPortFlag),
		Usage:  "Service endpoint port",
	},
	cli.StringFlag{
		Name:   endpointTypeFlag,
		EnvVar: envVar(endpointTypeFlag),
		Usage:  "Service endpoint type (http, https, tcp, udp, user)",
	},
	cli.StringFlag{
		Name:   registryURLFlag,
		EnvVar: envVar(registryURLFlag),
		Usage:  "URL for Registry",
	},
	cli.StringFlag{
		Name:   registryTokenFlag,
		EnvVar: envVar(registryTokenFlag),
		Usage:  "API token for Registry",
	},
	cli.DurationFlag{
		Name:   registryPollFlag,
		EnvVar: envVar(registryPollFlag),
		Usage:  "Interval for polling Controller",
	},
	cli.StringFlag{
		Name:   controllerURLFlag,
		EnvVar: envVar(controllerURLFlag),
		Usage:  "URL for Controller service",
	},
	cli.StringFlag{
		Name:   controllerTokenFlag,
		EnvVar: envVar(controllerTokenFlag),
		Usage:  "Amalgam8 controller token",
	},
	cli.DurationFlag{
		Name:   controllerPollFlag,
		EnvVar: envVar(controllerPollFlag),
		Usage:  "Interval for polling Controller",
	},
	cli.BoolFlag{
		Name:   superviseFlag,
		EnvVar: envVar(superviseFlag),
		Usage:  "Enable monitoring of application process. If application dies, container is killed as well. This has to be the last flag. All arguments provided after this flag will considered as part of the application invocation",
	},
	cli.BoolFlag{
		Name:   logFlag,
		EnvVar: envVar(logFlag),
		Usage:  "Enable logging of outgoing requests through proxy using FileBeat",
	},
	cli.StringFlag{
		Name:   logstashServerFlag,
		EnvVar: envVar(logstashServerFlag),
		Usage:  "Logstash target for nginx logs",
	},
	cli.StringFlag{
		Name:   logLevelFlag,
		EnvVar: envVar(logLevelFlag),
		Usage:  "Logging level (debug, info, warn, error, fatal, panic)",
	},
}

Flags is the set of supported flags

Functions

func Validate

func Validate(validators []ValidatorFunc) error

Validate runs validation checks

Types

type Config

type Config struct {
	Register bool `yaml:"register"`
	Proxy    bool `yaml:"proxy"`

	Service  Service  `yaml:"service"`
	Endpoint Endpoint `yaml:"endpoint"`

	Registry   Registry   `yaml:"registry"`
	Controller Controller `yaml:"controller"`

	Supervise bool     `yaml:"supervise"`
	App       []string `yaml:"app"`

	Log            bool   `yaml:"log"`
	LogstashServer string `yaml:"logstash_server"`

	LogLevel string `yaml:"log_level"`
}

Config stores the various configuration options for the sidecar

func New

func New(context *cli.Context) (*Config, error)

New creates a new Config object from the given commandline flags, environment variables, and configuration file context.

func (*Config) Validate

func (c *Config) Validate() error

Validate the configuration

type Controller

type Controller struct {
	URL   string        `yaml:"url"`
	Token string        `yaml:"token"`
	Poll  time.Duration `yaml:"poll"`
}

Controller configuration

type Endpoint

type Endpoint struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
	Type string `yaml:"type"`
}

Endpoint configuration

type Registry

type Registry struct {
	URL   string        `yaml:"url"`
	Token string        `yaml:"token"`
	Poll  time.Duration `yaml:"poll"`
}

Registry configuration

type Service

type Service struct {
	Name string   `yaml:"name"`
	Tags []string `yaml:"tags"`
}

Service configuration

type ValidatorFunc

type ValidatorFunc func() error

ValidatorFunc performs a validation check

func IsInRange

func IsInRange(name string, value, min, max int) ValidatorFunc

IsInRange ensures the integer is within the specified inclusive range

func IsInRangeDuration

func IsInRangeDuration(name string, value, min, max time.Duration) ValidatorFunc

IsInRangeDuration ensures the time value is between the given min and max times

func IsInSet

func IsInSet(name, value string, set []string) ValidatorFunc

IsInSet ensures that the value is a member of the set

func IsNotEmpty

func IsNotEmpty(name, value string) ValidatorFunc

IsNotEmpty ensures the value is not empty

func IsValidURL

func IsValidURL(name, value string) ValidatorFunc

IsValidURL ensures that the URL is valid and has a protocol specified (http, https, etc...)

Jump to

Keyboard shortcuts

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