mirror of
https://github.com/rancher/os.git
synced 2025-07-01 01:01:48 +00:00
Bump libcompose
Replace empty slices with nils in unmarshaled libcompose datatypes.
This commit is contained in:
parent
d18ec0d34b
commit
349df9adc7
@ -27,7 +27,7 @@ import:
|
||||
version: 58b270c338e831ac6668a29788c72d202f9fc251
|
||||
|
||||
- package: github.com/docker/libcompose
|
||||
version: 5cad17e57c7c5a2faa180b75c5beb90afc7dde05
|
||||
version: d4939c5f375cfe102e04810cf0db4127cfbb1875
|
||||
|
||||
- package: github.com/docker/libcontainer
|
||||
version: 83a102cc68a09d890cce3b6c2e5c14c49e6373a0
|
||||
|
2
vendor/github.com/docker/libcompose/Dockerfile
generated
vendored
2
vendor/github.com/docker/libcompose/Dockerfile
generated
vendored
@ -1,5 +1,5 @@
|
||||
# This file describes the standard way to build libcompose, using docker
|
||||
FROM golang:1.5.1
|
||||
FROM golang:1.5.2
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
iptables \
|
||||
|
15
vendor/github.com/docker/libcompose/project/types_yaml.go
generated
vendored
15
vendor/github.com/docker/libcompose/project/types_yaml.go
generated
vendored
@ -19,6 +19,9 @@ func (s Stringorslice) MarshalYAML() (tag string, value interface{}, err error)
|
||||
}
|
||||
|
||||
func toStrings(s []interface{}) ([]string, error) {
|
||||
if len(s) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
r := make([]string, len(s))
|
||||
for k, v := range s {
|
||||
if sv, ok := v.(string); ok {
|
||||
@ -81,7 +84,6 @@ func (s Command) MarshalYAML() (tag string, value interface{}, err error) {
|
||||
|
||||
// UnmarshalYAML implements the Unmarshaller interface.
|
||||
func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
|
||||
var err error
|
||||
switch value := value.(type) {
|
||||
case []interface{}:
|
||||
parts, err := toStrings(value)
|
||||
@ -90,11 +92,15 @@ func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
|
||||
}
|
||||
s.parts = parts
|
||||
case string:
|
||||
s.parts, err = shlex.Split(value)
|
||||
parts, err := shlex.Split(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.parts = parts
|
||||
default:
|
||||
return fmt.Errorf("Failed to unmarshal Command: %#v", value)
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
// ToString returns the parts of the command as a string (joined by spaces).
|
||||
@ -188,6 +194,9 @@ func (s MaporEqualSlice) MarshalYAML() (tag string, value interface{}, err error
|
||||
}
|
||||
|
||||
func toSepMapParts(value map[interface{}]interface{}, sep string) ([]string, error) {
|
||||
if len(value) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
parts := make([]string, 0, len(value))
|
||||
for k, v := range value {
|
||||
if sk, ok := k.(string); ok {
|
||||
|
39
vendor/github.com/docker/libcompose/project/types_yaml_test.go
generated
vendored
39
vendor/github.com/docker/libcompose/project/types_yaml_test.go
generated
vendored
@ -1,11 +1,12 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -22,14 +23,10 @@ func newTestConfig() TestConfig {
|
||||
SystemContainers: map[string]*ServiceConfig{
|
||||
"udev": {
|
||||
Image: "udev",
|
||||
Entrypoint: Command{[]string{}},
|
||||
Command: Command{[]string{}},
|
||||
Restart: "always",
|
||||
Net: "host",
|
||||
Privileged: true,
|
||||
DNS: Stringorslice{[]string{"8.8.8.8", "8.8.4.4"}},
|
||||
DNSSearch: Stringorslice{[]string{}},
|
||||
EnvFile: Stringorslice{[]string{}},
|
||||
Environment: MaporEqualSlice{[]string{
|
||||
"DAEMON=true",
|
||||
}},
|
||||
@ -37,27 +34,19 @@ func newTestConfig() TestConfig {
|
||||
"io.rancher.os.detach": "true",
|
||||
"io.rancher.os.scope": "system",
|
||||
}},
|
||||
Links: MaporColonSlice{[]string{}},
|
||||
VolumesFrom: []string{
|
||||
"system-volumes",
|
||||
},
|
||||
},
|
||||
"system-volumes": {
|
||||
Image: "state",
|
||||
Entrypoint: Command{[]string{}},
|
||||
Command: Command{[]string{}},
|
||||
Net: "none",
|
||||
ReadOnly: true,
|
||||
Privileged: true,
|
||||
DNS: Stringorslice{[]string{}},
|
||||
DNSSearch: Stringorslice{[]string{}},
|
||||
EnvFile: Stringorslice{[]string{}},
|
||||
Environment: MaporEqualSlice{[]string{}},
|
||||
Labels: SliceorMap{map[string]string{
|
||||
"io.rancher.os.createonly": "true",
|
||||
"io.rancher.os.scope": "system",
|
||||
}},
|
||||
Links: MaporColonSlice{[]string{}},
|
||||
Volumes: []string{
|
||||
"/dev:/host/dev",
|
||||
"/var/lib/rancher/conf:/var/lib/rancher/conf",
|
||||
@ -221,6 +210,26 @@ func TestUnmarshalCommand(t *testing.T) {
|
||||
err = yaml.Unmarshal(bytes, s2)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, []string{"bash"}, s.Command.Slice())
|
||||
assert.Nil(t, s.Entrypoint.Slice())
|
||||
assert.Equal(t, []string{"bash"}, s2.Command.Slice())
|
||||
assert.Nil(t, s2.Entrypoint.Slice())
|
||||
}
|
||||
|
||||
var sampleEmptyCommand = `{}`
|
||||
|
||||
func TestUnmarshalEmptyCommand(t *testing.T) {
|
||||
s := &StructCommand{}
|
||||
err := yaml.Unmarshal([]byte(sampleEmptyCommand), s)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, s.Command.Slice())
|
||||
|
||||
bytes, err := yaml.Marshal(s)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, "entrypoint: []\ncommand: []", strings.TrimSpace(string(bytes)))
|
||||
|
||||
s2 := &StructCommand{}
|
||||
err = yaml.Unmarshal(bytes, s2)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, s2.Command.Slice())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user