config

package
Version: v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

README

Config Engineering Notes

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

Log Filter Guidelines

Probr Log Levels:

  • ERROR - Behavior that is a result of a definite misconfiguration or code failure
  • WARN - Behavior that is likely due to a misconfiguration, but is not fatal
  • NOTICE - (1) User config information to prevent confusion, or (2) behavior that could result from a misconfiguration but also may be intentional
  • INFO - Non-verbose information that doesn't fit the above criteria
  • DEBUG - Any potentially helpful information that doesn't fit the above criteria

Multi-line logs should be formatted prior to log.Printf(...). By using this command multiple times, each line will get a separate timestamp and will appear to be separate entries.

For example, Results: could be read as if an empty string was being output.

However, by misusing log.Printf we may cause a similar appearance:

log.Printf("[NOTICE] Results:")
log.Printf("[NOTICE] %s", myVar)
// Prints:
// 2020/09/28 11:18:01 [NOTICE] Results:
// 2020/09/28 11:18:01 [NOTICE] {"some": "information"}

Config

Configuration docs are located in the README at the top level of the probr repository.

When creating new config vars, remember to do the following:

  1. Add an entry to the struct ConfigVars in internal/config/config.go
  2. Add an entry (matching the config vars struct) to setEnvOrDefaults in internal/config/defaults.go
  3. If appropriate, add logic to cmd/probr-cli/flags.go

By following the above steps, you will have accomplished the following:

  1. A new variable will be available across the entire probr codebase
  2. That variable will have a default value
  3. An environment variable can be set to override the default value
  4. The env var can be overridden by a provided yaml config file
  5. If set, a flag can be used to override the all other values

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigDecoder

func NewConfigDecoder(path string) (decoder *yaml.Decoder, file *os.File, err error)

NewConfigDecoder reads the provided into a new yaml decoder and leaves the file open

func ParseTags

func ParseTags(inclusions, exclusions []string) string

ParseTags takes two lists of tags and parses them into a cucumber tag string Tags may start with '@' or '~@' respectively, but it is not required

Types

type CloudProviders

type CloudProviders struct {
	Azure ac.Azure `yaml:"Azure"`
}

CloudProviders config options

type GlobalOpts

type GlobalOpts struct {
	StartTime          time.Time
	VarsFile           string
	InstallDir         string         `yaml:"InstallDir"`
	TmpDir             string         `yaml:"TmpDir"`
	GodogResultsFormat string         `yaml:"GodogResultsFormat"`
	CloudProviders     CloudProviders `yaml:"CloudProviders"`
	WriteDirectory     string         `yaml:"WriteDirectory"`
	LogLevel           string         `yaml:"LogLevel"`
	TagExclusions      []string       `yaml:"TagExclusions"`
	TagInclusions      []string       `yaml:"TagInclusions"`
	WriteConfig        string         `yaml:"WriteConfig"`
}

GlobalOpts provides configurable options that will be used throughout the SDK

var GlobalConfig GlobalOpts

GlobalConfig ...

func (*GlobalOpts) CleanupTmp

func (ctx *GlobalOpts) CleanupTmp()

CleanupTmp is used to dispose of any temp resources used during execution

func (*GlobalOpts) Init

func (ctx *GlobalOpts) Init()

Init ...

func (*GlobalOpts) LogConfigState

func (ctx *GlobalOpts) LogConfigState()

LogConfigState ...

func (*GlobalOpts) PrepareOutputDirectory added in v0.1.5

func (ctx *GlobalOpts) PrepareOutputDirectory(subdirectories ...string)

PrepareOutputDirectory will ensure readiness of output dir and specified subdirectories

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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