config

package
v28.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config implements the configuration management system.

This package contains the logic to interact with the configuration options of taskcluster-cli. It takes care of initializing, serializing, and loading all of the configuration values necessary for the application to function.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Configuration contains the current configuration values.
	Configuration map[string]map[string]interface{}

	// OptionsDefinitions is a map of all the OptionDefinitions, by command.
	OptionsDefinitions = make(map[string]map[string]OptionDefinition)

	// Credentials is the client credentials, if present.
	Credentials *client.Credentials
)

Functions

func Load

func Load() (map[string]map[string]interface{}, error)

Load will load configuration file, and initialize a default configuration if no configuration is present. This only returns an error if a configuration file is present, but we are unable to parse it.

func RegisterOptions

func RegisterOptions(command string, options map[string]OptionDefinition)

RegisterOptions takes in the name of the command and an map of OptionDefinition objects

func RootURL

func RootURL() string

Defer erroring out on a missing RootURL until we actually need one..

func Save

func Save(config map[string]map[string]interface{}) error

Save will save configuration.

func SetRootURL

func SetRootURL(newRootURL string)

set the root URL -- this is used only for testing

func Setup

func Setup()

Setup is to be called from main this was originally the init() function but we want to make sure all other packages have been initialized before calling them, which Load() does

Types

type OptionDefinition

type OptionDefinition struct {
	Description string      // Description of the config option
	Default     interface{} // Default value
	Env         string      // Environment variable to attempt to load from (optional)
	Parse       bool        // True, if string input should be parsed as JSON
	Validate    func(value interface{}) error
}

A OptionDefinition is something with a default value and a validator. Only requirement is that values are JSON structures.

Jump to

Keyboard shortcuts

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