config

package
v0.0.0-...-7a6a509 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppSSH

type AppSSH struct {
	Endpoint           string `yaml:"endpoint" validate:"required,url"`
	OAuthClient        string `yaml:"oauth_client" validate:"required"`
	HostKeyFingerprint string `yaml:"host_key_fingerprint"`
}

type CfAPIConfig

type CfAPIConfig struct {
	Listen           string        `yaml:"listen"`
	ExternalDomain   string        `yaml:"external_domain" validate:"required"`
	ExternalProtocol string        `yaml:"external_protocol" validate:"required"`
	Info             InfoConfig    `yaml:"info"`
	DB               DBConfig      `yaml:"db"`
	Log              ZapConfig     `yaml:"log"`
	RateLimit        RateLimitConf `yaml:"rate_limiting"`
	Uaa              UaaConfig     `yaml:"uaa"`
	URLs             URLs          `yaml:"urls"`
	AppSSH           AppSSH        `yaml:"app_ssh"`
}

func Get

func Get(configFile string) (*CfAPIConfig, error)

Parses the config once, otherwise just returns it Priority from lowest to highest: Default Values, Config File, Environment Variables After setting the Config in this order it is validated according to struct tags If validation is not succefull we have a invalid config and thus throw a FATAL

func (*CfAPIConfig) Validate

func (s *CfAPIConfig) Validate() error

We need to extend the validation function because of https://github.com/go-playground/validator/issues/782 Otherwise users would not get a clue why their config did not validate (meaningless error message).

type DBConfig

type DBConfig struct {
	// For connection string documentation see
	// Postgres: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS
	// Mysql: https://github.com/go-sql-driver/mysql#dsn-data-source-name
	ConnectionString string    `yaml:"connection_string" validate:"required"`
	Type             string    `yaml:"type" validate:"required,oneof=postgres mysql"`
	Log              ZapConfig `yaml:"log"`
	MaxConnections   int       `yaml:"max_connections" validate:"gte=1,lte=1000"`
	MinConnections   int       `yaml:"min_connections" validate:"gte=1,lte=1000,ltefield=MaxConnections"`
}

type InfoConfig

type InfoConfig struct {
	Name                     string `yaml:"name" validate:"required"`
	Build                    string `yaml:"build" validate:"required"`
	Version                  int    `yaml:"version" validate:"gte=0"`
	SupportAddress           string `yaml:"support_address" validate:"required"`
	Description              string `yaml:"description" validate:"required"`
	MinCliVersion            string `yaml:"min_cli_version"`
	MinRecommendedCliVersion string `yaml:"min_recommended_cli_version"`
}

type RateLimitConf

type RateLimitConf struct {
	Enabled                        bool          `yaml:"enabled"`
	PerProcessGeneralLimit         int           `yaml:"per_process_general_limit"`
	GlobalGeneralLimit             int           `yaml:"global_general_limit"`
	PerProcessUnauthenticatedLimit int           `yaml:"per_process_unauthenticated_limit"`
	GlobalUnauthenticatedLimit     int           `yaml:"global_unauthenticated_limit"`
	ResetInterval                  time.Duration `yaml:"reset_interval"`
}

type URLs

type URLs struct {
	LogCache   string  `yaml:"log_cache" validate:"required,url"`
	LogStream  string  `yaml:"log_stream" validate:"required,url"`
	Doppler    string  `yaml:"doppler" validate:"required,url"`
	Login      string  `yaml:"login" validate:"required,url"`
	UAA        string  `yaml:"uaa" validate:"required,url"`
	RoutingAPI *string `yaml:"routing_api" validate:"omitempty,url"`
}

type UaaConfig

type UaaConfig struct {
	URL    string                      `yaml:"url"`
	Client promconfig.HTTPClientConfig `yaml:"client"`
}

type ZapConfig

type ZapConfig struct {
	Level      string `yaml:"level" validate:"required,oneof=debug info warn error dpanic panic fatal"`
	Production bool   `yaml:"production"`
}

Jump to

Keyboard shortcuts

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