Created
July 30, 2015 19:35
-
-
Save squeedee/1f309f8264c97cc672fe to your computer and use it in GitHub Desktop.
Candied Yaml doesn't support merge.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
services: | |
- acceptance-db | |
env: | |
RAILS_ENV: acceptance | |
application-types: | |
web: &WEB | |
mem: 2G | |
disk: 2G | |
applications: | |
- | |
name: blue | |
<<: *WEB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"path/filepath" | |
"github.com/cloudfoundry-incubator/candiedyaml" | |
"github.com/cloudfoundry/cli/generic" | |
) | |
func parseManifest(path string) (yamlMap generic.Map) { | |
file, err := os.Open(filepath.Clean(path)) | |
if err != nil { | |
fmt.Println("Could not open") | |
return | |
} | |
defer file.Close() | |
decoder := candiedyaml.NewDecoder(file) | |
yamlMap = generic.NewMap() | |
err = decoder.Decode(yamlMap) | |
if err != nil { | |
return | |
} | |
if !generic.IsMappable(yamlMap) { | |
fmt.Println("Invalid manifest - not a map") | |
return | |
} | |
return | |
} | |
func main() { | |
mapp := parseManifest("./manifest.yml") | |
fmt.Println(mapp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
○ → go run test.go
map[services:[acceptance-db] env:map[RAILS_ENV:acceptance] application-types:map[web:map[mem:2G disk:2G]] applications:[map[name:blue <<:map[disk:2G mem:2G]]]]