Updated Vendoring

This commit is contained in:
Suraj Narwade
2017-04-27 21:38:38 +05:30
parent 605d643a84
commit 1eb162d697
77 changed files with 2293 additions and 1354 deletions
+13
View File
@@ -10,6 +10,7 @@ import (
"github.com/docker/libcompose/utils"
composeYaml "github.com/docker/libcompose/yaml"
"gopkg.in/yaml.v2"
"reflect"
)
var (
@@ -60,6 +61,18 @@ func Merge(existingServices *ServiceConfigs, environmentLookup EnvironmentLookup
}
baseRawServices := config.Services
for service, data := range baseRawServices {
for key, value := range data {
//check for "extends" key and check whether it is string or not
if key == "extends" && reflect.TypeOf(value).Kind() == reflect.String {
//converting string to map
extendMap := make(map[interface{}]interface{})
extendMap["service"] = value
baseRawServices[service][key] = extendMap
}
}
}
if options.Interpolate {
if err := InterpolateRawServiceMap(&baseRawServices, environmentLookup); err != nil {
return "", nil, nil, nil, err
+7 -2
View File
@@ -180,8 +180,13 @@ func resolveContextV2(inFile string, serviceData RawService) RawService {
} else {
current = path.Join(current, context)
}
build["context"] = current
if _, ok := serviceData["build"].(string); ok {
//build is specified as a string containing a path to the build context
serviceData["build"] = current
} else {
//build is specified as an object with the path specified under context
build["context"] = current
}
return serviceData
}
+10
View File
@@ -17,6 +17,16 @@ var (
schemaV2 map[string]interface{}
)
func init() {
if err := setupSchemaLoaders(schemaDataV1, &schemaV1, &schemaLoaderV1, &constraintSchemaLoaderV1); err != nil {
panic(err)
}
if err := setupSchemaLoaders(servicesSchemaDataV2, &schemaV2, &schemaLoaderV2, &constraintSchemaLoaderV2); err != nil {
panic(err)
}
}
type (
environmentFormatChecker struct{}
portsFormatChecker struct{}
-16
View File
@@ -157,10 +157,6 @@ func invalidTypeMessage(service, key string, err gojsonschema.ResultError) strin
}
func validate(serviceMap RawServiceMap) error {
if err := setupSchemaLoaders(schemaDataV1, &schemaV1, &schemaLoaderV1, &constraintSchemaLoaderV1); err != nil {
return err
}
serviceMap = convertServiceMapKeysToStrings(serviceMap)
dataLoader := gojsonschema.NewGoLoader(serviceMap)
@@ -174,10 +170,6 @@ func validate(serviceMap RawServiceMap) error {
}
func validateV2(serviceMap RawServiceMap) error {
if err := setupSchemaLoaders(servicesSchemaDataV2, &schemaV2, &schemaLoaderV2, &constraintSchemaLoaderV2); err != nil {
return err
}
serviceMap = convertServiceMapKeysToStrings(serviceMap)
dataLoader := gojsonschema.NewGoLoader(serviceMap)
@@ -250,10 +242,6 @@ func generateErrorMessages(serviceMap RawServiceMap, schema map[string]interface
}
func validateServiceConstraints(service RawService, serviceName string) error {
if err := setupSchemaLoaders(schemaDataV1, &schemaV1, &schemaLoaderV1, &constraintSchemaLoaderV1); err != nil {
return err
}
service = convertServiceKeysToStrings(service)
var validationErrors []string
@@ -289,10 +277,6 @@ func validateServiceConstraints(service RawService, serviceName string) error {
}
func validateServiceConstraintsv2(service RawService, serviceName string) error {
if err := setupSchemaLoaders(servicesSchemaDataV2, &schemaV2, &schemaLoaderV2, &constraintSchemaLoaderV2); err != nil {
return err
}
service = convertServiceKeysToStrings(service)
var validationErrors []string
+2 -1
View File
@@ -249,8 +249,9 @@ func toStrings(s []interface{}) ([]string, error) {
func toMap(s []string, sep string) map[string]string {
m := map[string]string{}
for _, v := range s {
// Return everything past first sep
values := strings.Split(v, sep)
m[values[0]] = values[1]
m[values[0]] = strings.SplitN(v, sep, 2)[1]
}
return m
}