config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

Config

Internal code to manage config, including Cloud Driver parameters and Test Packs

Available Config Vars

The struct config.Vars uses the Config struct presented below.

type Config struct {
	KubeConfigPath string `yaml:"kubeConfig"`
	OutputType     string `yaml:"outputType"`
	Images         struct {
		Repository string `yaml:"repository"`
		Curl       string `yaml:"curl"`
		BusyBox    string `yaml:"busyBox"`
	} `yaml:"Images"`
	Azure struct {
		SubscriptionID  string `yaml:"subscriptionID"`
		ClientID        string `yaml:"clientID"`
		ClientSecret    string `yaml:"clientSecret"`
		TenantID        string `yaml:"tenantID"`
		LocationDefault string `yaml:"locationDefault"`
	} `yaml:"azure"`
}

How the Config Works

These values are populated in one of three ways, with the value being taken from the highest priority entry.

  1. Default values; found in config/defaults.go (lowest priority)
  2. OS environment variables; set locally prior to probr execution (mid priority)
  3. Vars file; yaml (highest priority)
Default Values

Most variables pertain to environment specific elements such as image repository information or cloud provider credentials. As such, most defaults are empty values.

Environment Variables

If you would like to handle logic differently per environment, env vars may be useful. An example of how to set an env var is as follows:

export KUBE_CONFIG=./path/to/config

Vars File

You may have as many vars files as you wish in your codebase, which will enable you to maintain configurations for multiple environments in a single codebase.

An example of how to a vars file is as follows:

probr --varsFile=./config-dev.yml

IMPORTANT: Do not forget to encrypt your config file if it contains secrets.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentLogLevel

func CurrentLogLevel() string

CurrentLogLevel returns the current log level. It cannot be changed.

func Init

func Init(configPath string) error

Init will override Vars when it is used

func LineBreakReplacer

func LineBreakReplacer(s string) string

LineBreakReplacer replaces carriage return (\r), linefeed (\n), formfeed (\f) and other similar characters with a space.

func ValidateConfigPath

func ValidateConfigPath(path string) error

ValidateConfigPath simply ensures the file exists

Types

type Config

type Config interface {
	GetKubeConfigPath() *string
	SetKubeConfigPath(*string)

	GetAzureSubscriptionID() *string
	GetAzureClientID() *string
	GetAzureClientSecret() *string
	GetAzureTenantID() *string
	GetAzureLocationDefault() *string

	GetImageRepository() *string
	GetCurlImage() *string
	GetBusyBoxImage() *string
	GetOutputType() *string
	SetOutputType(string)
}

Config ...

type ConfigVars

type ConfigVars struct {
	KubeConfigPath string `yaml:"kubeConfig"`
	OutputType     string `yaml:"outputType"`
	Images         struct {
		Repository string `yaml:"repository"`
		Curl       string `yaml:"curl"`
		BusyBox    string `yaml:"busyBox"`
	} `yaml:"Images"`
	Azure struct {
		SubscriptionID  string `yaml:"subscriptionID"`
		ClientID        string `yaml:"clientID"`
		ClientSecret    string `yaml:"clientSecret"`
		TenantID        string `yaml:"tenantID"`
		LocationDefault string `yaml:"locationDefault"`
	} `yaml:"azure"`
	Tests struct {
		Tags string `yaml:"tags"`
	} `yaml:"Tests"`
}

ConfigVars contains all possible config vars. May be set by .yml, env, or defaults.

var Vars ConfigVars

Vars ...

func NewConfig

func NewConfig(c string) (ConfigVars, error)

NewConfig can be used multiple times, if the need arises

func (*ConfigVars) GetAzureClientID

func (e *ConfigVars) GetAzureClientID() string

GetAzureClientID ...

func (*ConfigVars) GetAzureClientSecret

func (e *ConfigVars) GetAzureClientSecret() string

GetAzureClientSecret ...

func (*ConfigVars) GetAzureLocationDefault

func (e *ConfigVars) GetAzureLocationDefault() string

GetAzureLocationDefault ...

func (*ConfigVars) GetAzureSubscriptionID

func (e *ConfigVars) GetAzureSubscriptionID() string

GetAzureSubscriptionID ...

func (*ConfigVars) GetAzureTenantID

func (e *ConfigVars) GetAzureTenantID() string

GetAzureTenantID ...

func (*ConfigVars) GetBusyBoxImage

func (e *ConfigVars) GetBusyBoxImage() string

GetBusyBoxImage ...

func (*ConfigVars) GetCurlImage

func (e *ConfigVars) GetCurlImage() string

GetCurlImage ...

func (*ConfigVars) GetImageRepository

func (e *ConfigVars) GetImageRepository() string

GetImageRepository ...

func (*ConfigVars) GetKubeConfigPath

func (e *ConfigVars) GetKubeConfigPath(d string)

GetKubeConfigPath ...

func (*ConfigVars) GetOutputType

func (e *ConfigVars) GetOutputType(s string) string

GetOutputType ...

func (*ConfigVars) SetKubeConfigPath

func (e *ConfigVars) SetKubeConfigPath(p string)

SetKubeConfigPath ...

func (*ConfigVars) SetOutputType

func (e *ConfigVars) SetOutputType(s string)

SetOutputType ...

func (*ConfigVars) SetTags

func (e *ConfigVars) SetTags(t string)

SetTags ...

type EnvConfig

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

EnvConfig ...

func GetEnvConfigInstance

func GetEnvConfigInstance() *EnvConfig

GetEnvConfigInstance ...

func (*EnvConfig) GetAzureClientID

func (e *EnvConfig) GetAzureClientID() *string

GetAzureClientID ...

func (*EnvConfig) GetAzureClientSecret

func (e *EnvConfig) GetAzureClientSecret() *string

GetAzureClientSecret ...

func (*EnvConfig) GetAzureLocationDefault

func (e *EnvConfig) GetAzureLocationDefault() *string

GetAzureLocationDefault ...

func (*EnvConfig) GetAzureSubscriptionID

func (e *EnvConfig) GetAzureSubscriptionID() *string

GetAzureSubscriptionID ...

func (*EnvConfig) GetAzureTenantID

func (e *EnvConfig) GetAzureTenantID() *string

GetAzureTenantID ...

func (*EnvConfig) GetBusyBoxImage

func (e *EnvConfig) GetBusyBoxImage() *string

GetBusyBoxImage ...

func (*EnvConfig) GetCurlImage

func (e *EnvConfig) GetCurlImage() *string

GetCurlImage ...

func (*EnvConfig) GetImageRepository

func (e *EnvConfig) GetImageRepository() *string

GetImageRepository ...

func (*EnvConfig) GetKubeConfigPath

func (e *EnvConfig) GetKubeConfigPath() *string

GetKubeConfigPath ...

func (*EnvConfig) GetOutputType

func (e *EnvConfig) GetOutputType() *string

GetOutputType ...

func (*EnvConfig) SetKubeConfigPath

func (e *EnvConfig) SetKubeConfigPath(p *string)

SetKubeConfigPath ...

func (*EnvConfig) SetOutputType

func (e *EnvConfig) SetOutputType(s string)

SetOutputType

func (*EnvConfig) String

func (e *EnvConfig) String() string

type EnvVariable

type EnvVariable int

EnvVariable ...

const (
	KubeConfig EnvVariable = iota
	AzSubscriptionID
	AzClientID
	AzClientSecret
	AzTenantID
	AzLocationDefault
	ImageRepository
	CurlImage
	BusyBoxImage
)

EnvVariable ...

func (EnvVariable) String

func (v EnvVariable) String() string

Jump to

Keyboard shortcuts

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