Пример #1
0
func parseManifest(file io.Reader) (yamlMap generic.Map, err error) {
	decoder := candiedyaml.NewDecoder(file)
	yamlMap = generic.NewMap()
	err = decoder.Decode(yamlMap)
	if err != nil {
		return
	}

	if !generic.IsMappable(yamlMap) {
		err = errors.New("Invalid manifest. Expected a map")
		return
	}

	return
}
Пример #2
0
func LoadConfiguration(path string) Configuration {
	file, err := os.Open(path)

	if err != nil {
		println("File does not exist:", err.Error())
		os.Exit(1)
	}

	config := Configuration{}
	decoder := candiedyaml.NewDecoder(file)

	if err := decoder.Decode(&config); err != nil {
		println("Failed to decode document:", err.Error())
	}

	return config
}