Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyYaml ¶
func ApplyYaml(ex mains.Executable, yamlFile, yamlKey string, thunk UnmarshalThunk, om []OptionData)
ApplyYaml adds options read from a yaml file.
File: The filename searched comes from Executable.Program or the yamlFile argument. If yamlFile is set exactly this file is read. If yamlFile is not set, A search is executed in the directories ~/apps .. and /etc. The filename searched is [program]-[hostname].yaml and [program].yaml.
Content: If the file does not eixst, no action is taken. If the file is empty, no action is taken.
The top entry in the yaml file is expected to be a dictionary of dictionaries. The key searched for in the top level dictionary is the yamlKey argument or “options” if not set.
thunk needs to in otuside of the library for typoing reasons and is implemented similar to the below. y is the variable receiving parsed yaml data. The om list is then svcaned for its Y pointers to copy yaml settings to options.
func applyYaml(bytes []byte, unmarshal mains.UnmarshalFunc, yamlDictionaryKey string) (hasData bool, err error) { yamlContentObject := map[string]*YamlData{} // need map[string] because yaml top level is dictionary if err = unmarshal(bytes, &yamlContentObject); err != nil { return } yamlDataPointer := yamlContentObject[yamlDictionaryKey] // pick out the options dictionary value if hasData = yamlDataPointer != nil; !hasData { return } y = *yamlDataPointer return }
func GetTopLevelKey ¶
GetTopLevelKey gets the top level key to use
Types ¶
type UnmarshalFunc ¶
type UnmarshalThunk ¶
type UnmarshalThunk func(bytes []byte, unmarshal UnmarshalFunc, yamlKey string) (hasDate bool, err error)