Documentation ¶
Index ¶
Constants ¶
const ( // ArchivePriorBuild is a boolean for whether or not a compressed tarball // of a prior build, for a given Packer template, should be created, if it // exists. ArchivePriorBuild = "archive_prior_build" // Dir is the directory that contains the Feedlot build information. Dir = "conf_dir" // Example is a bool that let's Feedlot know that the current run is an // example run. Feedlot will look for the configurations and source in // the configured ExampleDir. Example = "example" // ExampleDir is the directory that contains Feedlot examples. Examples // are used to show how Feedlot build templates may be configured and to // provide an easy way to generated example Packer templates. ExampleDir = "example_dir" // Format is the format used for the Feedlot configuration files: either // TOML or JSON. TOML expects all configuration files to have either the // '.toml' or '.tml' extension. JSON expects all configuration files to have // one of the following extensions: '.json', '.jsn', '.cjsn', or '.cjson'. // JSON is the default format. Format = "format" // ParamDelimStart is the delimiter used to indicate the start of a Feedlot // parameter (variable). The default start delimiter is ':'. This is used // so that Feedlot parameters in templates do not conflict with Packer // parameters, which use '{{ }}'. ParamDelimStart = "param_delim_start" // File is the flag name for the file to be used if logging is enabled; // this defaults to stderr. LogFile = "log_file" // Level is the flag name for the minimum log level used for logging. LogLevel = "log_level" // LogFlags: is the flags to use when logging: https://golang.org/pkg/log/#pkg-constants // In addition to the ones defined in the docs, none is also a valid value. None means // don't use any flags. By default, log.LstdFlags is used. LogFlags = "log_flags" )
Feedlot setting names: these values are used in the config files, for flags, and as the basis for environment variables.
const ( // DefaultFormat is the default configuration format. DefaultFormat = JSON )
Variables ¶
var ( // Name is the name of the application Name = filepath.Base(os.Args[0]) // File is the suffix for the ENV variable name that holds the override // value for the Feedlot conf file, if there is one. File = "conf_file" // Filename is the default value for the optional Feedlot conf file. This // may be overridden using the 'FEEDLOT_CONF_FILE' environment variable. Filename = "feedlot.cjson" // App contains the values for the loaded Feedlot configuration. // TODO is this still necessary? App app )
var ErrUnsupportedFormat = errors.New("unsupported format")
ErrUnsupportedFormat occurs when the specified format is not supported.
Functions ¶
func FindConfFile ¶
FindConfFile returns the location of the provided conf file. This accounts for examples. An empty
If the p field has a value, it is used as the dir path, instead of the confDir,
func SetAppConfFile ¶
func SetAppConfFile() error
SetAppConfFile set's the App conf from the app's conf file and then applies any env vars that have been set. After this, settings can only be updated programmatically or via command-line flags.
The default conf file may not be the one found as the app conf file may be in a different format. SetAppConfFile first looks for it in the configured location. If it is not found, the alternate format is checked.
Since Feedlot supports operations without a conf file, not finding one is not an error state.
Currently supported conf file formats:
TOML JSON || CJSN
Types ¶
type ConfFormat ¶
type ConfFormat int
ConfFormat: the configuration file's format.
const ( UnsupportedConfFormat ConfFormat = iota JSON TOML )
supported conf formats
func ConfFilename ¶
func ConfFilename(fname string) (string, ConfFormat, error)
ConfFilename takea a conf file name and checks to see if it exists. If it doesn't exist, it checks to see if the file can be found under an alternate extension by checking what config format Feedlot is set to use and iterating through the list of supported exts for that format. If a file exists under a particular file + ext combination, that is returned. If no match is found, the error on the original filename is returned so that the message information is consistent with what is expected.
func ParseConfFormat ¶
func ParseConfFormat(s string) ConfFormat
ParseConfFormat returns the ConfFormat for the provided string. All values are lower cased prior to comparison. If a corresponding ConfFormat is not found, UnsupportedConfFormat is returned.
func (ConfFormat) String ¶
func (c ConfFormat) String() string