config

package
v0.0.0-...-ebd413c Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvErrorFmt                            = "Error creating config from env: %s"
	DefaultNginxTemplatePath               = "/etc/nginx/nginx.template"
	DefaultNginxConfPath                   = "/etc/nginx/nginx.conf"
	MarathonScheduler        SchedulerType = 1
	SwarmScheduler           SchedulerType = 2
)

Variables

View Source
var (
	FileNotFound = errors.New("Cannot find the specified config file")
)

Functions

func AddFlags

func AddFlags(cmd *cobra.Command)

AddFlags is a hook to add additional CLI Flags

Types

type Config

type Config struct {
	// Scheduler type to use (0 for Marathon, 1 for Swarm)
	// Only applicable if both Swarm and Marathon are configured
	SchedulerType SchedulerType `json:"scheduler_type"`

	// Docker/Swarm configuration
	Swarm *SwarmConfig `json:"swarm"`

	// Marathon configuration options
	Marathon *MarathonConfig `json:"marathon"`

	// Deprecated - Please use Marathon
	MarthonUrls []string `json:"marthon_urls" envconfig:"-"`

	// Deprecated - Use Marathon.Username
	Username string `json:"username" envconfig:"-"`

	// Deprecated - Use Marathon.Password
	Password string `json:"password" envconfig:"-"`

	// Optional regex filter to only reload based on certain apps that match
	// ex. ^.*something.* would match all /apps/something app identifiers
	// Enivronment variable: BT_FILTER_REGEX
	FilterRegExStr string `json:"filter_regex" envconfig:"filter_regex"`

	// Port to listen to HTTP requests.  Default 7777
	Port int `json:"port"`

	// Scheme we are listening to (http | https)
	Scheme string `json:"scheme"`

	// Location to nginx.conf template - default: /etc/nginx/nginx.template
	Template string `json:"template"`

	// Location of the nginx.conf - default: /etc/nginx/nginx.conf
	NginxConfig string `json:"nginx_config"`

	// User defined configuration data that can be used as part of the template parsing
	// if Beethoven is launched with --root-apps=false .
	Data map[string]interface{}

	/* Internal */
	Version string `json:"-"`
	// contains filtered or unexported fields
}

Config provides configuration information for Marathon streams and the proxy

func LoadConfigFromCommand

func LoadConfigFromCommand(cmd *cobra.Command) (*Config, error)

func (*Config) DryRun

func (c *Config) DryRun() bool

func (*Config) Filter

func (c *Config) Filter() *regexp.Regexp

func (*Config) HttpPort

func (c *Config) HttpPort() int

HttpPort is the port we serve the API with default 7777 if config port is undefined

func (*Config) IsFilterDefined

func (c *Config) IsFilterDefined() bool

func (*Config) IsTemplatedAppRooted

func (c *Config) IsTemplatedAppRooted() bool

IsTemplatedAppRooted means that application from marathon are the actual object during template parsing. If false then applications are a sub-element.

func (*Config) ParseRegEx

func (c *Config) ParseRegEx()

ParseRegEx validates and parses that the regex is valid. If the FilterRegExpStr is invalid the value is emptied and an Error is logged

func (*Config) Reload

func (c *Config) Reload() bool

Reload will re-fetch/load the a subset of the configuration and apply it. The data applied is "Data" and "FilterRegExStr" values

type MarathonConfig

type MarathonConfig struct {
	// The URL to Marathon: ex. http://host:8080
	// Enivronment variable: BT_MARATHON_URLS
	Endpoints []string `json:"endpoints" envconfig:"marathon_urls"`

	// The Marathon ID for Beethoven (optional).  If set,
	// will allow for reloading new configuration changes (if using user Data below).
	ServiceId string `json:"service_id"`

	// The basic auth username - if applicable
	// Enivronment variable: BT_USERNAME
	Username string `json:"username" envconfig:"username"`

	// The basic auth password - if applicable
	// Enivronment variable: BT_PASSWORD
	Password string `json:"password" envconfig:"password"`
}

type SchedulerType

type SchedulerType int

type SwarmConfig

type SwarmConfig struct {
	// Target connection string for Swarm
	Endpoint string `json:"endpoint"`

	// Network is the name of the network Beethoven should proxy internal requests to.  This is only used
	// if RouteToNode is set to false (the default)
	Network string `json:"network"`

	// RouteToNode will instruct beethoven to route requests to the public address of the Swarm node.  This
	// can be used in scenarios where Beethoven is running outside of the Swarm cluster
	RouteToNode bool

	// Interval to watch for Swarm topology changes
	WatchIntervalSecs int `json:"watch_interval_secs"`

	// TLS Certificate file
	TLSCert string `json:"tls_cert"`
	// TLS Certificate key
	TLSKey string `json:"tls_key"`
	// TLS CA Certificate
	TLSCACert string `json:"tlsca_cert"`
	// Verify TLS
	TLSVerify bool `json:"tls_verify"`
}

Jump to

Keyboard shortcuts

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