Update vendoring as well as libcompose

This commit updates libcompose in order to merge in
https://github.com/docker/libcompose/pull/423 which affected
https://github.com/kubernetes-incubator/kompose/issues/92 by not
erroring out when an image name wasn't provided.

Closes https://github.com/kubernetes-incubator/kompose/issues/92

As well as knocks out the last required milestone for a 0.2.1 release
https://github.com/kubernetes-incubator/kompose/milestone/2
This commit is contained in:
Charlie Drage
2017-01-04 13:18:07 -05:00
parent 6e260bab0b
commit 57039425b6
26 changed files with 640 additions and 429 deletions
+60 -13
View File
@@ -29,18 +29,8 @@ func CreateConfig(bytes []byte) (*Config, error) {
if err := yaml.Unmarshal(bytes, &config); err != nil {
return nil, err
}
if config.Version == "2" {
for key, value := range config.Networks {
if value == nil {
config.Networks[key] = &NetworkConfig{}
}
}
for key, value := range config.Volumes {
if value == nil {
config.Volumes[key] = &VolumeConfig{}
}
}
} else {
if config.Version != "2" {
var baseRawServices RawServiceMap
if err := yaml.Unmarshal(bytes, &baseRawServices); err != nil {
return nil, err
@@ -48,6 +38,13 @@ func CreateConfig(bytes []byte) (*Config, error) {
config.Services = baseRawServices
}
if config.Volumes == nil {
config.Volumes = make(map[string]interface{})
}
if config.Networks == nil {
config.Networks = make(map[string]interface{})
}
return &config, nil
}
@@ -63,6 +60,34 @@ func Merge(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup
}
baseRawServices := config.Services
if options.Interpolate {
if err := InterpolateRawServiceMap(&baseRawServices, environmentLookup); err != nil {
return "", nil, nil, nil, err
}
for k, v := range config.Volumes {
if err := Interpolate(k, &v, environmentLookup); err != nil {
return "", nil, nil, nil, err
}
config.Volumes[k] = v
}
for k, v := range config.Networks {
if err := Interpolate(k, &v, environmentLookup); err != nil {
return "", nil, nil, nil, err
}
config.Networks[k] = v
}
}
if options.Preprocess != nil {
var err error
baseRawServices, err = options.Preprocess(baseRawServices)
if err != nil {
return "", nil, nil, nil, err
}
}
var serviceConfigs map[string]*ServiceConfig
if config.Version == "2" {
var err error
@@ -91,7 +116,29 @@ func Merge(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup
}
}
return config.Version, serviceConfigs, config.Volumes, config.Networks, nil
var volumes map[string]*VolumeConfig
var networks map[string]*NetworkConfig
if err := utils.Convert(config.Volumes, &volumes); err != nil {
return "", nil, nil, nil, err
}
if err := utils.Convert(config.Networks, &networks); err != nil {
return "", nil, nil, nil, err
}
return config.Version, serviceConfigs, volumes, networks, nil
}
// InterpolateRawServiceMap replaces varialbse in raw service map struct based on environment lookup
func InterpolateRawServiceMap(baseRawServices *RawServiceMap, environmentLookup EnvironmentLookup) error {
for k, v := range *baseRawServices {
for k2, v2 := range v {
if err := Interpolate(k2, &v2, environmentLookup); err != nil {
return err
}
(*baseRawServices)[k][k2] = v2
}
}
return nil
}
func adjustValues(configs map[string]*ServiceConfig) {