config

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

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 `validate:"required"`
	Host      string `validate:"required,hostname|ip"`
	Port      int    `validate:"required,min=1,max=65535"`
	APIPrefix string `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 Auth

type Auth struct {
	Username string `validate:"required"`
}

Auth represents client auth configs

type Base

type Base interface {
	IsDebug() bool
}

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

type Client

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

Client is the aptomictl config representation

func (Client) IsDebug

func (c Client) IsDebug() bool

IsDebug returns true if debug mode enabled

type DB

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

DB represents configs for DB

type Enforcer

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

Enforcer represents configs for 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
}

HTTP is the config for low level HTTP client

type Helm

type Helm struct {
}

Helm represents configs for Helm 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 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"`
	Helm                 Helm            `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             Enforcer        `validate:"required"`
	DomainAdminOverrides map[string]bool `validate:"-"`
}

Server represents configs for the server

func (Server) IsDebug

func (s Server) IsDebug() bool

IsDebug returns true if debug mode enabled

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