config

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0 Imports: 11 Imported by: 66

Documentation

Overview

Package config provides support for Aptomi configuration - Server config, Client config, and their common sections (API config)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Schema    string `yaml:",omitempty" validate:"required"`
	Host      string `yaml:",omitempty" validate:"required,hostname|ip"`
	Port      int    `yaml:",omitempty" validate:"required,min=1,max=65535"`
	APIPrefix string `yaml:",omitempty" validate:"required"`
}

API represents configs for the API used in both client and server

func (API) ListenAddr

func (a API) ListenAddr() string

ListenAddr returns address server listens on

func (API) URL

func (a API) URL() string

URL returns server API url to connect to

type ActualStateUpdater added in v0.1.15

type ActualStateUpdater struct {
	Disabled             bool          `validate:"-"`
	Interval             time.Duration `validate:"-"`
	Noop                 bool          `validate:"-"`
	NoopSleep            time.Duration `validate:"-"`
	MaxConcurrentActions int           `validate:"-"`
}

ActualStateUpdater represents config for actual state updater background process that periodically refreshes actual state (e.g. retrieves endpoints for all components)

type Base

type Base interface {
	IsDebug() bool
	GetLogLevel() logrus.Level
}

Base is the interface for all configs used in Aptomi (e.g. client config, server config)

type Client

type Client struct {
	Debug  bool       `yaml:",omitempty" validate:"-"`
	Output string     `yaml:",omitempty" validate:"required"`
	API    API        `yaml:",omitempty" validate:"required"`
	Auth   ClientAuth `yaml:",omitempty" validate:"required"`
	HTTP   HTTP       `yaml:",omitempty" validate:"required"`
}

Client is the aptomictl config representation

func (*Client) GetLogLevel added in v0.1.14

func (c *Client) GetLogLevel() logrus.Level

GetLogLevel returns log level

func (Client) IsDebug

func (c Client) IsDebug() bool

IsDebug returns true if debug mode enabled

type ClientAuth added in v0.1.8

type ClientAuth struct {
	Token string `yaml:",omitempty" validate:"-"`
}

ClientAuth represents client auth configs

type DB

type DB struct {
	Connection string `validate:"required"`
}

DB represents configs for DB

type DesiredStateEnforcer added in v0.1.15

type DesiredStateEnforcer struct {
	Disabled             bool          `validate:"-"`
	Interval             time.Duration `validate:"-"`
	Noop                 bool          `validate:"-"`
	NoopSleep            time.Duration `validate:"-"`
	MaxConcurrentActions int           `validate:"-"`
}

DesiredStateEnforcer represents config for desired state enforcer background process that periodically gets latest policy, calculating difference between it and actual state and then applying calculated actions

type HTTP

type HTTP struct {
	Timeout time.Duration `yaml:",omitempty" `
}

HTTP is the config for low level HTTP client

type Helm

type Helm struct {
	Timeout time.Duration
}

Helm represents configs for Helm code plugin

type K8s added in v0.1.11

type K8s struct {
	Timeout time.Duration
}

K8s represents config for Kubernetes cluster plugin

type K8sRaw added in v0.1.11

type K8sRaw struct {
	DataNamespace string
}

K8sRaw represents config for Kubernetes Raw code plugin

type LDAP

type LDAP struct {
	Host   string `validate:"required,hostname|ip"`
	Port   int    `validate:"required,min=1,max=65535"`
	BaseDN string `validate:"required"`

	// Filter is LDAP filter query for all users
	Filter string `validate:"required"`

	// FilterByName is LDAP filter query when doing user lookup by name
	FilterByName string `validate:"required"`

	LabelToAttributes map[string]string `validate:"required"`
}

LDAP contains configuration for LDAP sync service (host, port, DN, filter query and mapping of LDAP properties to Aptomi attributes)

func (*LDAP) GetAttributes

func (cfg *LDAP) GetAttributes() []string

GetAttributes returns the list of attributes to be retrieved from LDAP

type Plugins added in v0.1.11

type Plugins struct {
	K8s    K8s
	K8sRaw K8sRaw
	Helm   Helm
}

Plugins represents configs for all plugins

type Profile added in v0.1.14

type Profile struct {
	CPU   string
	Trace string
}

Profile represents profiler config

type Server

type Server struct {
	Debug                bool                 `validate:"-"`
	API                  API                  `validate:"required"`
	UI                   UI                   `validate:"omitempty"` // if UI is not defined, then UI will not be started
	DB                   DB                   `validate:"required"`
	Plugins              Plugins              `validate:"required"`
	Users                UserSources          `validate:"required"`
	SecretsDir           string               `validate:"omitempty,dir"` // secrets is not a first-class citizen yet, so it's not required
	Enforcer             DesiredStateEnforcer `validate:"required"`
	Updater              ActualStateUpdater   `validate:"required"`
	DomainAdminOverrides map[string]bool      `validate:"-"`
	Auth                 ServerAuth           `validate:"-"`
	Profile              Profile              `validate:"-"`
}

Server represents configs for the server

func (*Server) GetLogLevel added in v0.1.14

func (s *Server) GetLogLevel() logrus.Level

GetLogLevel returns log level

func (Server) IsDebug

func (s Server) IsDebug() bool

IsDebug returns true if debug mode enabled

type ServerAuth added in v0.1.8

type ServerAuth struct {
	Secret string `validate:"-"`
}

ServerAuth represents server auth config

type UI

type UI struct {
	Enable bool `validate:"required"`
}

UI represents configs for the UI

type UserSources

type UserSources struct {
	LDAP []LDAP   `validate:"dive"`
	File []string `validate:"dive,file"`
}

UserSources represents configs for the user loaders that could be file and LDAP loaders

type Validator

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

Validator is a custom validator for configs

func NewValidator

func NewValidator(config Base) *Validator

NewValidator creates a new Validator

func (*Validator) Validate

func (v *Validator) Validate() error

Validate validates config for errors and returns an error (it can be casted to configValidationError, containing a list of errors inside). When error is printed as string, it will automatically contains the full list of validation errors.

Jump to

Keyboard shortcuts

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