1
0
mirror of https://github.com/rancher/os.git synced 2025-09-24 20:09:21 +00:00

Pre-process YAML config data

Stringify libcompose datatypes' leaf values to avoid unmarshaling errors, even on somewhat incorrect input data: like using bools or numerics in labels.
This commit is contained in:
Ivan Mikushin
2015-12-07 20:56:33 +05:00
parent 07fdba4642
commit 66ba159482
33 changed files with 7582 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package compose
import (
log "github.com/Sirupsen/logrus"
yaml "github.com/cloudfoundry-incubator/candiedyaml"
"github.com/docker/libcompose/cli/logger"
"github.com/docker/libcompose/docker"
"github.com/docker/libcompose/project"
@@ -129,6 +130,16 @@ func newCoreServiceProject(cfg *config.CloudConfig, network bool) (*project.Proj
continue
}
m := map[interface{}]interface{}{}
if err := yaml.Unmarshal(bytes, &m); err != nil {
log.Errorf("Failed to parse YAML configuration: %s : %v", service, err)
continue
}
bytes, err = yaml.Marshal(config.StringifyValues(m))
if err != nil {
log.Errorf("Failed to marshal YAML configuration: %s : %v", service, err)
continue
}
err = p.Load(bytes)
if err != nil {
log.Errorf("Failed to load %s : %v", service, err)