1
0
mirror of https://github.com/rancher/os.git synced 2025-09-02 07:15:41 +00:00

migrate to upstream libcompose in one and a half go

This commit is contained in:
Ivan Mikushin
2015-11-26 17:41:42 +05:00
parent 1d691cd8d6
commit 5a363ab97d
1291 changed files with 40107 additions and 123532 deletions

View File

@@ -15,9 +15,6 @@ type Stringorslice struct {
// MarshalYAML implements the Marshaller interface.
func (s Stringorslice) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", []string{}, nil
}
return "", s.parts, nil
}
@@ -67,9 +64,6 @@ type Command struct {
// MarshalYAML implements the Marshaller interface.
func (s Command) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", []string{}, nil
}
return "", s.parts, nil
}
@@ -113,9 +107,6 @@ type SliceorMap struct {
// MarshalYAML implements the Marshaller interface.
func (s SliceorMap) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", map[string]string{}, nil
}
return "", s.parts, nil
}
@@ -169,9 +160,6 @@ type MaporEqualSlice struct {
// MarshalYAML implements the Marshaller interface.
func (s MaporEqualSlice) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", []string{}, nil
}
return "", s.parts, nil
}
@@ -214,9 +202,6 @@ type MaporColonSlice struct {
// MarshalYAML implements the Marshaller interface.
func (s MaporColonSlice) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", []string{}, nil
}
return "", s.parts, nil
}
@@ -259,9 +244,6 @@ type MaporSpaceSlice struct {
// MarshalYAML implements the Marshaller interface.
func (s MaporSpaceSlice) MarshalYAML() (tag string, value interface{}, err error) {
if s.parts == nil {
return "", []string{}, nil
}
return "", s.parts, nil
}

View File

@@ -120,6 +120,11 @@ type StructSliceorMap struct {
Bars []string `yaml:"bars"`
}
type StructCommand struct {
Entrypoint Command `yaml:"entrypoint,flow,omitempty"`
Command Command `yaml:"command,flow,omitempty"`
}
func TestSliceOrMapYaml(t *testing.T) {
str := `{foos: [bar=baz, far=faz]}`
@@ -192,3 +197,24 @@ func TestMaporsliceYaml(t *testing.T) {
assert.True(t, contains(s2.Foo.parts, "bar=baz"))
assert.True(t, contains(s2.Foo.parts, "far=faz"))
}
var sampleStructCommand = `command: bash`
func TestUnmarshalCommand(t *testing.T) {
s := &StructCommand{}
err := yaml.Unmarshal([]byte(sampleStructCommand), s)
assert.Nil(t, err)
assert.Equal(t, []string{"bash"}, s.Command.Slice())
assert.Nil(t, s.Entrypoint.Slice())
bytes, err := yaml.Marshal(s)
assert.Nil(t, err)
s2 := &StructCommand{}
err = yaml.Unmarshal(bytes, s2)
assert.Nil(t, err)
assert.Equal(t, []string{"bash"}, s.Command.Slice())
assert.Nil(t, s.Entrypoint.Slice())
}