Documentation ¶
Overview ¶
An abstraction of the Chef Workstation configuration file (config.toml).
Basic usage ¶
This example is loading the Chef Workstation configuration file located by default at $HOME/.chef-workstation/config.toml and printing the log level:
package main import "github.com/chef/go-libs/config" func main() { cfg, err := config.New() if err != nil { fmt.Println("unable to read the config", err) } fmt.Println("the log level of my config is: ", cfg.Log.Level) }
Index ¶
Constants ¶
const ( ApplyExec = "chef-apply" AutomateProduct = "Chef Automate" ClientExec = "chef-client" ClientProduct = "Chef Infra Client" CompanyName = "Chef Software" DirSuffix = "chef" DocsWebsite = "https://docs.chef.io" MainWebsite = "https://chef.io" ServerProduct = "Chef Infra Server" ShellExec = "chef-shell" SoloExec = "chef-solo" SoloProduct = "Chef Infra Solo" UserConfDir = ".chef" WorkstationDir = ".chef-workstation" WorkstationProduct = "Chef Workstation" ZeroExec = "chef-zero" )
const ( DefaultChefWorkstationDirectory = WorkstationDir DefaultChefWSUserConfigFile = "config.toml" DefaultChefWSAppConfigFile = ".app-managed-config.toml" )
const DefaultChefDirectory = UserConfDir
Variables ¶
var ( UserConfigTomlNotFoundErr = fmt.Sprintf(` %[1]s file not found. (default: $HOME/%[2]s/%[1]s) setup your local configuration file by following this documentation: - https://www.chef.sh/docs/reference/config/ `, DefaultChefWSUserConfigFile, WorkstationDir) UserConfigTomlMalformedErr = fmt.Sprintf(` unable to parse %s file. verify the format of the configuration file by following this documentation: - https://www.chef.sh/docs/reference/config/ `, DefaultChefWSUserConfigFile) AppConfigTomlNotFoundErr = fmt.Sprintf(` %[1]s file not found. (default: $HOME/%[2]s/%[1]s) verify that the %[3]s App is runnig on your local workstation. `, DefaultChefWSUserConfigFile, WorkstationDir, WorkstationProduct) AppConfigTomlMalformedErr = fmt.Sprintf(` unable to parse %s file. there must be a problem with the %s App, verify the format of the configuration by following this documentation: - https://www.chef.sh/docs/reference/config/ `, DefaultChefWSAppConfigFile, WorkstationProduct) )
Functions ¶
func ChefWorkstationDir ¶
returns the ~/.chef-workstation directory
func FindChefWSAppConfigFile ¶
finds the application configuration file (default .chef-workstation/.app-managed-config.toml) inside the current directory and recursively, plus inside the $HOME directory
func FindChefWSUserConfigFile ¶
finds the user configuration file (default .chef-workstation/config.toml) inside the current directory and recursively, plus inside the $HOME directory
func FindConfigFile ¶
finds the provided configuration file name inside the current directory, if the file is not there the, it looks up inside the users $HOME directory
Types ¶
type Config ¶
type Config struct { Telemetry telemetrySettings `toml:"telemetry" mapstructure:"telemetry"` Log logSettings `toml:"log" mapstructure:"log"` Cache cacheSettings `toml:"cache" mapstructure:"cache"` Chef chefSettings `toml:"chef" mapstructure:"chef"` Updates updatesSettings `toml:"updates" mapstructure:"updates"` DataCollector dcSettings `toml:"data_collector" mapstructure:"data_collector"` Connection connSettings `toml:"connection" mapstructure:"connection"` Features map[string]bool `toml:"features" mapstructure:"features"` Dev devSettings `toml:"dev" mapstructure:"dev"` Reports reportSettings `toml:"reports" mapstructure:"reports"` }
abstraction of the chef-workstation configuration file (config.toml)
func App ¶
func App(overrides ...OverrideFunc) (Config, error)
returns a new Config with only the WS App (Tray) config loaded
func New ¶
func New(overrides ...OverrideFunc) (Config, error)
returns a new Config instance with both config loaded, the WS App (Tray) config and the User config
func User ¶
func User(overrides ...OverrideFunc) (Config, error)
returns a new Config with only the User config loaded (`config.toml`)
func (*Config) MergeAppConfig ¶
func (*Config) MergeUserConfig ¶
type OverrideFunc ¶
type OverrideFunc func(*Config)
override functions to override any particular setting