upgrade libcompose to fbdac0a6a80837c63eb6c8f43514f7bb3f32df6c

This commit is contained in:
Tuna
2016-10-09 02:35:51 +02:00
parent 5a37bf0fb4
commit 592cc95907
567 changed files with 6730 additions and 44603 deletions
+15 -44
View File
@@ -6,18 +6,10 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/libcompose/utils"
"gopkg.in/yaml.v2"
)
// MergeServicesV2 merges a v2 compose file into an existing set of service configs
func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup, resourceLookup ResourceLookup, file string, bytes []byte, options *ParseOptions) (map[string]*ServiceConfig, error) {
var config Config
if err := yaml.Unmarshal(bytes, &config); err != nil {
return nil, err
}
datas := config.Services
func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup, resourceLookup ResourceLookup, file string, datas RawServiceMap, options *ParseOptions) (map[string]*ServiceConfig, error) {
if options.Interpolate {
if err := Interpolate(environmentLookup, &datas); err != nil {
return nil, err
@@ -32,6 +24,12 @@ func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup Environ
}
}
if options.Validate {
if err := validateV2(datas); err != nil {
return nil, err
}
}
for name, data := range datas {
data, err := parseV2(resourceLookup, environmentLookup, file, data, datas, options)
if err != nil {
@@ -59,38 +57,6 @@ func MergeServicesV2(existingServices *ServiceConfigs, environmentLookup Environ
return serviceConfigs, nil
}
// ParseVolumes parses volumes in a compose file
func ParseVolumes(bytes []byte) (map[string]*VolumeConfig, error) {
volumeConfigs := make(map[string]*VolumeConfig)
var config Config
if err := yaml.Unmarshal(bytes, &config); err != nil {
return nil, err
}
if err := utils.Convert(config.Volumes, &volumeConfigs); err != nil {
return nil, err
}
return volumeConfigs, nil
}
// ParseNetworks parses networks in a compose file
func ParseNetworks(bytes []byte) (map[string]*NetworkConfig, error) {
networkConfigs := make(map[string]*NetworkConfig)
var config Config
if err := yaml.Unmarshal(bytes, &config); err != nil {
return nil, err
}
if err := utils.Convert(config.Networks, &networkConfigs); err != nil {
return nil, err
}
return networkConfigs, nil
}
func parseV2(resourceLookup ResourceLookup, environmentLookup EnvironmentLookup, inFile string, serviceData RawService, datas RawServiceMap, options *ParseOptions) (RawService, error) {
serviceData, err := readEnvFile(resourceLookup, inFile, serviceData)
if err != nil {
@@ -135,11 +101,10 @@ func parseV2(resourceLookup ResourceLookup, environmentLookup EnvironmentLookup,
return nil, err
}
var config Config
if err := yaml.Unmarshal(bytes, &config); err != nil {
config, err := CreateConfig(bytes)
if err != nil {
return nil, err
}
baseRawServices := config.Services
if options.Interpolate {
@@ -149,6 +114,12 @@ func parseV2(resourceLookup ResourceLookup, environmentLookup EnvironmentLookup,
}
}
if options.Validate {
if err := validate(baseRawServices); err != nil {
return nil, err
}
}
baseService, ok = baseRawServices[service]
if !ok {
return nil, fmt.Errorf("Failed to find service %s in file %s", service, file)