mirror of
https://github.com/rancher/os.git
synced 2025-07-01 09:11: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
|
version: 58b270c338e831ac6668a29788c72d202f9fc251
|
||||||
|
|
||||||
- package: github.com/docker/libcompose
|
- package: github.com/docker/libcompose
|
||||||
version: 5cad17e57c7c5a2faa180b75c5beb90afc7dde05
|
version: d4939c5f375cfe102e04810cf0db4127cfbb1875
|
||||||
|
|
||||||
- package: github.com/docker/libcontainer
|
- package: github.com/docker/libcontainer
|
||||||
version: 83a102cc68a09d890cce3b6c2e5c14c49e6373a0
|
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
|
# 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 \
|
RUN apt-get update && apt-get install -y \
|
||||||
iptables \
|
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) {
|
func toStrings(s []interface{}) ([]string, error) {
|
||||||
|
if len(s) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
r := make([]string, len(s))
|
r := make([]string, len(s))
|
||||||
for k, v := range s {
|
for k, v := range s {
|
||||||
if sv, ok := v.(string); ok {
|
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.
|
// UnmarshalYAML implements the Unmarshaller interface.
|
||||||
func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
|
func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
|
||||||
var err error
|
|
||||||
switch value := value.(type) {
|
switch value := value.(type) {
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
parts, err := toStrings(value)
|
parts, err := toStrings(value)
|
||||||
@ -90,11 +92,15 @@ func (s *Command) UnmarshalYAML(tag string, value interface{}) error {
|
|||||||
}
|
}
|
||||||
s.parts = parts
|
s.parts = parts
|
||||||
case string:
|
case string:
|
||||||
s.parts, err = shlex.Split(value)
|
parts, err := shlex.Split(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
s.parts = parts
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Failed to unmarshal Command: %#v", value)
|
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).
|
// 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) {
|
func toSepMapParts(value map[interface{}]interface{}, sep string) ([]string, error) {
|
||||||
|
if len(value) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
parts := make([]string, 0, len(value))
|
parts := make([]string, 0, len(value))
|
||||||
for k, v := range value {
|
for k, v := range value {
|
||||||
if sk, ok := k.(string); ok {
|
if sk, ok := k.(string); ok {
|
||||||
|
47
vendor/github.com/docker/libcompose/project/types_yaml_test.go
generated
vendored
47
vendor/github.com/docker/libcompose/project/types_yaml_test.go
generated
vendored
@ -1,11 +1,12 @@
|
|||||||
package project
|
package project
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||||
|
|
||||||
"fmt"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,14 +23,10 @@ func newTestConfig() TestConfig {
|
|||||||
SystemContainers: map[string]*ServiceConfig{
|
SystemContainers: map[string]*ServiceConfig{
|
||||||
"udev": {
|
"udev": {
|
||||||
Image: "udev",
|
Image: "udev",
|
||||||
Entrypoint: Command{[]string{}},
|
|
||||||
Command: Command{[]string{}},
|
|
||||||
Restart: "always",
|
Restart: "always",
|
||||||
Net: "host",
|
Net: "host",
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
DNS: Stringorslice{[]string{"8.8.8.8", "8.8.4.4"}},
|
DNS: Stringorslice{[]string{"8.8.8.8", "8.8.4.4"}},
|
||||||
DNSSearch: Stringorslice{[]string{}},
|
|
||||||
EnvFile: Stringorslice{[]string{}},
|
|
||||||
Environment: MaporEqualSlice{[]string{
|
Environment: MaporEqualSlice{[]string{
|
||||||
"DAEMON=true",
|
"DAEMON=true",
|
||||||
}},
|
}},
|
||||||
@ -37,27 +34,19 @@ func newTestConfig() TestConfig {
|
|||||||
"io.rancher.os.detach": "true",
|
"io.rancher.os.detach": "true",
|
||||||
"io.rancher.os.scope": "system",
|
"io.rancher.os.scope": "system",
|
||||||
}},
|
}},
|
||||||
Links: MaporColonSlice{[]string{}},
|
|
||||||
VolumesFrom: []string{
|
VolumesFrom: []string{
|
||||||
"system-volumes",
|
"system-volumes",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"system-volumes": {
|
"system-volumes": {
|
||||||
Image: "state",
|
Image: "state",
|
||||||
Entrypoint: Command{[]string{}},
|
Net: "none",
|
||||||
Command: Command{[]string{}},
|
ReadOnly: true,
|
||||||
Net: "none",
|
Privileged: true,
|
||||||
ReadOnly: true,
|
|
||||||
Privileged: true,
|
|
||||||
DNS: Stringorslice{[]string{}},
|
|
||||||
DNSSearch: Stringorslice{[]string{}},
|
|
||||||
EnvFile: Stringorslice{[]string{}},
|
|
||||||
Environment: MaporEqualSlice{[]string{}},
|
|
||||||
Labels: SliceorMap{map[string]string{
|
Labels: SliceorMap{map[string]string{
|
||||||
"io.rancher.os.createonly": "true",
|
"io.rancher.os.createonly": "true",
|
||||||
"io.rancher.os.scope": "system",
|
"io.rancher.os.scope": "system",
|
||||||
}},
|
}},
|
||||||
Links: MaporColonSlice{[]string{}},
|
|
||||||
Volumes: []string{
|
Volumes: []string{
|
||||||
"/dev:/host/dev",
|
"/dev:/host/dev",
|
||||||
"/var/lib/rancher/conf:/var/lib/rancher/conf",
|
"/var/lib/rancher/conf:/var/lib/rancher/conf",
|
||||||
@ -221,6 +210,26 @@ func TestUnmarshalCommand(t *testing.T) {
|
|||||||
err = yaml.Unmarshal(bytes, s2)
|
err = yaml.Unmarshal(bytes, s2)
|
||||||
|
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, []string{"bash"}, s.Command.Slice())
|
assert.Equal(t, []string{"bash"}, s2.Command.Slice())
|
||||||
assert.Nil(t, s.Entrypoint.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