forked from LaconicNetwork/kompose
Update vendoring
This updates the libcompose vendoring as well as a general update to vendoring (adds the latest git commit of libcompose). Closes https://github.com/kubernetes-incubator/kompose/issues/426 Closes https://github.com/kubernetes-incubator/kompose/issues/471
This commit is contained in:
+2
@@ -86,6 +86,7 @@ var schemaDataV1 = `{
|
||||
"log_opt": {"type": "object"},
|
||||
"mac_address": {"type": "string"},
|
||||
"mem_limit": {"type": ["number", "string"]},
|
||||
"mem_reservation": {"type": ["number", "string"]},
|
||||
"memswap_limit": {"type": ["number", "string"]},
|
||||
"mem_swappiness": {"type": "integer"},
|
||||
"net": {"type": "string"},
|
||||
@@ -298,6 +299,7 @@ var servicesSchemaDataV2 = `{
|
||||
|
||||
"mac_address": {"type": "string"},
|
||||
"mem_limit": {"type": ["number", "string"]},
|
||||
"mem_reservation": {"type": ["number", "string"]},
|
||||
"memswap_limit": {"type": ["number", "string"]},
|
||||
"mem_swappiness": {"type": "integer"},
|
||||
"network_mode": {"type": "string"},
|
||||
|
||||
+1
@@ -117,6 +117,7 @@ type ServiceConfig struct {
|
||||
Logging Log `yaml:"logging,omitempty"`
|
||||
MacAddress string `yaml:"mac_address,omitempty"`
|
||||
MemLimit yaml.MemStringorInt `yaml:"mem_limit,omitempty"`
|
||||
MemReservation yaml.MemStringorInt `yaml:"mem_reservation,omitempty"`
|
||||
MemSwapLimit yaml.MemStringorInt `yaml:"memswap_limit,omitempty"`
|
||||
MemSwappiness yaml.MemStringorInt `yaml:"mem_swappiness,omitempty"`
|
||||
NetworkMode string `yaml:"network_mode,omitempty"`
|
||||
|
||||
+16
-5
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -65,7 +66,17 @@ func NewProject(context *Context, runtime RuntimeProject, parseOptions *config.P
|
||||
}
|
||||
|
||||
if context.EnvironmentLookup == nil {
|
||||
cwd, err := os.Getwd()
|
||||
var envPath, absPath, cwd string
|
||||
var err error
|
||||
if len(context.ComposeFiles) > 0 {
|
||||
absPath, err = filepath.Abs(context.ComposeFiles[0])
|
||||
dir, _ := path.Split(absPath)
|
||||
envPath = filepath.Join(dir, ".env")
|
||||
} else {
|
||||
cwd, err = os.Getwd()
|
||||
envPath = filepath.Join(cwd, ".env")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Could not get the rooted path name to the current directory: %v", err)
|
||||
return nil
|
||||
@@ -73,7 +84,7 @@ func NewProject(context *Context, runtime RuntimeProject, parseOptions *config.P
|
||||
context.EnvironmentLookup = &lookup.ComposableEnvLookup{
|
||||
Lookups: []config.EnvironmentLookup{
|
||||
&lookup.EnvfileLookup{
|
||||
Path: filepath.Join(cwd, ".env"),
|
||||
Path: envPath,
|
||||
},
|
||||
&lookup.OsEnvLookup{},
|
||||
},
|
||||
@@ -150,7 +161,7 @@ func (p *Project) CreateService(name string) (Service, error) {
|
||||
|
||||
// check the environment for extra build Args that are set but not given a value in the compose file
|
||||
for arg, value := range config.Build.Args {
|
||||
if value == "\x00" {
|
||||
if *value == "\x00" {
|
||||
envValue := p.context.EnvironmentLookup.Lookup(arg, &config)
|
||||
// depending on what we get back we do different things
|
||||
switch l := len(envValue); l {
|
||||
@@ -158,7 +169,7 @@ func (p *Project) CreateService(name string) (Service, error) {
|
||||
delete(config.Build.Args, arg)
|
||||
case 1:
|
||||
parts := strings.SplitN(envValue[0], "=", 2)
|
||||
config.Build.Args[parts[0]] = parts[1]
|
||||
config.Build.Args[parts[0]] = &parts[1]
|
||||
default:
|
||||
return nil, fmt.Errorf("tried to set Build Arg %#v to multi-value %#v", arg, envValue)
|
||||
}
|
||||
@@ -312,7 +323,7 @@ func (p *Project) handleVolumeConfig() {
|
||||
}
|
||||
|
||||
vol, ok := p.VolumeConfigs[volume.Source]
|
||||
if !ok {
|
||||
if !ok || vol == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -12,7 +12,7 @@ import (
|
||||
type Build struct {
|
||||
Context string
|
||||
Dockerfile string
|
||||
Args map[string]string
|
||||
Args map[string]*string
|
||||
}
|
||||
|
||||
// MarshalYAML implements the Marshaller interface.
|
||||
@@ -63,8 +63,8 @@ func (b *Build) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
return errors.New("Failed to unmarshal Build")
|
||||
}
|
||||
|
||||
func handleBuildArgs(value interface{}) (map[string]string, error) {
|
||||
var args map[string]string
|
||||
func handleBuildArgs(value interface{}) (map[string]*string, error) {
|
||||
var args map[string]*string
|
||||
switch v := value.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
return handleBuildArgMap(v)
|
||||
@@ -75,25 +75,26 @@ func handleBuildArgs(value interface{}) (map[string]string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func handleBuildArgSlice(s []interface{}) (map[string]string, error) {
|
||||
var args = map[string]string{}
|
||||
func handleBuildArgSlice(s []interface{}) (map[string]*string, error) {
|
||||
var args = map[string]*string{}
|
||||
for _, arg := range s {
|
||||
// check if a value is provided
|
||||
switch v := strings.SplitN(arg.(string), "=", 2); len(v) {
|
||||
case 1:
|
||||
// if we have not specified a a value for this build arg, we assign it an ascii null value and query the environment
|
||||
// later when we build the service
|
||||
args[v[0]] = "\x00"
|
||||
str := "\x00"
|
||||
args[v[0]] = &str
|
||||
case 2:
|
||||
// if we do have a value provided, we use it
|
||||
args[v[0]] = v[1]
|
||||
args[v[0]] = &v[1]
|
||||
}
|
||||
}
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func handleBuildArgMap(m map[interface{}]interface{}) (map[string]string, error) {
|
||||
args := map[string]string{}
|
||||
func handleBuildArgMap(m map[interface{}]interface{}) (map[string]*string, error) {
|
||||
args := map[string]*string{}
|
||||
for mapKey, mapValue := range m {
|
||||
var argValue string
|
||||
name, ok := mapKey.(string)
|
||||
@@ -110,7 +111,7 @@ func handleBuildArgMap(m map[interface{}]interface{}) (map[string]string, error)
|
||||
default:
|
||||
return args, fmt.Errorf("Cannot unmarshal '%v' to type %T into a string value", mapValue, mapValue)
|
||||
}
|
||||
args[name] = argValue
|
||||
args[name] = &argValue
|
||||
}
|
||||
return args, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user