I'm having the following yaml , when I try to parse it I got error, any idea what could be missing here? im not sure how to struct the zone property.
This is the valid yaml
https://codebeautify.org/yaml-validator/cb42f23a
Error:
error in model extConfigYaml: *yaml: line 4: mapping values are not allowed in this context
type ExternalConfig struct {
Landscape zone `yaml:"Landscape"`
}
type zone struct {
zone models `yaml:"zone"`
}
type models struct {
models []Model `yaml:"models"`
}
type Model struct {
AppType string `yaml:"app-type"`
ServiceType string `yaml:"service-type"`
}
var external_config = []byte(`
Landscape:
zone: zone1
models:
- app-type: app1
service-type: GCP
- app-type: app2
service-type: AMAZON
zone: zone2
models:
- app-type: app3
service-type: AZURE
- app-type: app4Í
service-type: HEROKU
`)
extConfigYaml := ExternalConfig{}
err = yaml.Unmarshal([]byte(external_config), &extConfigYaml)
if err != nil {
log.Fatalf("error in model extConfigYaml: %v", err)
}
fmt.Printf("%+v
", extConfigYaml)