Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 80e2cf9

Browse files
authored
Merge pull request #340 from joshwget/go-yaml
Switch back to go-yaml
2 parents e1a83f7 + fb72517 commit 80e2cf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+8211
-10771
lines changed

config/interpolation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"os"
66
"testing"
77

8-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
98
"github.com/stretchr/testify/assert"
9+
"gopkg.in/yaml.v2"
1010
)
1111

1212
func testInterpolatedLine(t *testing.T, expectedLine, interpolatedLine string, envVariables map[string]string) {

config/marshal_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package config
33
import (
44
"testing"
55

6-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
76
yamlTypes "github.com/docker/libcompose/yaml"
87
"github.com/stretchr/testify/assert"
8+
"gopkg.in/yaml.v2"
99
)
1010

1111
type TestConfig struct {

config/merge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"fmt"
77
"strings"
88

9-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
109
"github.com/docker/docker/pkg/urlutil"
1110
"github.com/docker/libcompose/utils"
1211
composeYaml "github.com/docker/libcompose/yaml"
12+
"gopkg.in/yaml.v2"
1313
)
1414

1515
var (

config/merge_v1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"path"
66

77
"github.com/Sirupsen/logrus"
8-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
98
"github.com/docker/libcompose/utils"
9+
"gopkg.in/yaml.v2"
1010
)
1111

1212
// MergeServicesV1 merges a v1 compose file into an existing set of service configs

config/merge_v2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"path"
66

77
"github.com/Sirupsen/logrus"
8-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
98
"github.com/docker/libcompose/utils"
9+
"gopkg.in/yaml.v2"
1010
)
1111

1212
// MergeServicesV2 merges a v2 compose file into an existing set of service configs

config/types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ type ServiceConfigV1 struct {
2323
CapAdd []string `yaml:"cap_add,omitempty"`
2424
CapDrop []string `yaml:"cap_drop,omitempty"`
2525
CgroupParent string `yaml:"cgroup_parent,omitempty"`
26-
CPUQuota int64 `yaml:"cpu_quota,omitempty"`
26+
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
2727
CPUSet string `yaml:"cpuset,omitempty"`
28-
CPUShares int64 `yaml:"cpu_shares,omitempty"`
28+
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
2929
Command yaml.Command `yaml:"command,flow,omitempty"`
3030
ContainerName string `yaml:"container_name,omitempty"`
3131
Devices []string `yaml:"devices,omitempty"`
@@ -42,8 +42,8 @@ type ServiceConfigV1 struct {
4242
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
4343
LogDriver string `yaml:"log_driver,omitempty"`
4444
MacAddress string `yaml:"mac_address,omitempty"`
45-
MemLimit int64 `yaml:"mem_limit,omitempty"`
46-
MemSwapLimit int64 `yaml:"memswap_limit,omitempty"`
45+
MemLimit yaml.StringorInt `yaml:"mem_limit,omitempty"`
46+
MemSwapLimit yaml.StringorInt `yaml:"memswap_limit,omitempty"`
4747
Name string `yaml:"name,omitempty"`
4848
Net string `yaml:"net,omitempty"`
4949
Pid string `yaml:"pid,omitempty"`
@@ -53,7 +53,7 @@ type ServiceConfigV1 struct {
5353
Privileged bool `yaml:"privileged,omitempty"`
5454
Restart string `yaml:"restart,omitempty"`
5555
ReadOnly bool `yaml:"read_only,omitempty"`
56-
ShmSize int64 `yaml:"shm_size,omitempty"`
56+
ShmSize yaml.StringorInt `yaml:"shm_size,omitempty"`
5757
StdinOpen bool `yaml:"stdin_open,omitempty"`
5858
SecurityOpt []string `yaml:"security_opt,omitempty"`
5959
Tty bool `yaml:"tty,omitempty"`
@@ -81,8 +81,8 @@ type ServiceConfig struct {
8181
CapAdd []string `yaml:"cap_add,omitempty"`
8282
CapDrop []string `yaml:"cap_drop,omitempty"`
8383
CPUSet string `yaml:"cpuset,omitempty"`
84-
CPUShares int64 `yaml:"cpu_shares,omitempty"`
85-
CPUQuota int64 `yaml:"cpu_quota,omitempty"`
84+
CPUShares yaml.StringorInt `yaml:"cpu_shares,omitempty"`
85+
CPUQuota yaml.StringorInt `yaml:"cpu_quota,omitempty"`
8686
Command yaml.Command `yaml:"command,flow,omitempty"`
8787
CgroupParent string `yaml:"cgroup_parent,omitempty"`
8888
ContainerName string `yaml:"container_name,omitempty"`
@@ -105,15 +105,15 @@ type ServiceConfig struct {
105105
Links yaml.MaporColonSlice `yaml:"links,omitempty"`
106106
Logging Log `yaml:"logging,omitempty"`
107107
MacAddress string `yaml:"mac_address,omitempty"`
108-
MemLimit int64 `yaml:"mem_limit,omitempty"`
109-
MemSwapLimit int64 `yaml:"memswap_limit,omitempty"`
108+
MemLimit yaml.StringorInt `yaml:"mem_limit,omitempty"`
109+
MemSwapLimit yaml.StringorInt `yaml:"memswap_limit,omitempty"`
110110
NetworkMode string `yaml:"network_mode,omitempty"`
111111
Networks *yaml.Networks `yaml:"networks,omitempty"`
112112
Pid string `yaml:"pid,omitempty"`
113113
Ports []string `yaml:"ports,omitempty"`
114114
Privileged bool `yaml:"privileged,omitempty"`
115115
SecurityOpt []string `yaml:"security_opt,omitempty"`
116-
ShmSize int64 `yaml:"shm_size,omitempty"`
116+
ShmSize yaml.StringorInt `yaml:"shm_size,omitempty"`
117117
StopSignal string `yaml:"stop_signal,omitempty"`
118118
VolumeDriver string `yaml:"volume_driver,omitempty"`
119119
Volumes []string `yaml:"volumes,omitempty"`

docker/convert.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
171171

172172
resources := container.Resources{
173173
CgroupParent: c.CgroupParent,
174-
Memory: c.MemLimit,
175-
MemorySwap: c.MemSwapLimit,
176-
CPUShares: c.CPUShares,
177-
CPUQuota: c.CPUQuota,
174+
Memory: int64(c.MemLimit),
175+
MemorySwap: int64(c.MemSwapLimit),
176+
CPUShares: int64(c.CPUShares),
177+
CPUQuota: int64(c.CPUQuota),
178178
CpusetCpus: c.CPUSet,
179179
Ulimits: ulimits,
180180
Devices: deviceMappings,
@@ -242,7 +242,7 @@ func Convert(c *config.ServiceConfig, ctx project.Context, clientFactory compose
242242
IpcMode: container.IpcMode(c.Ipc),
243243
PortBindings: portBindings,
244244
RestartPolicy: *restartPolicy,
245-
ShmSize: c.ShmSize,
245+
ShmSize: int64(c.ShmSize),
246246
SecurityOpt: utils.CopySlice(c.SecurityOpt),
247247
VolumeDriver: c.VolumeDriver,
248248
Resources: resources,

project/project_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestParseWithBadContent(t *testing.T) {
9292
t.Fatal("Should have failed parse")
9393
}
9494

95-
if !strings.HasPrefix(err.Error(), "Invalid timestamp: 'garbage'") {
95+
if !strings.Contains(err.Error(), "cannot unmarshal !!str `garbage` into config.Config") {
9696
t.Fatalf("Should have failed parse: %#v", err)
9797
}
9898
}
@@ -204,5 +204,5 @@ func TestParseWithMultipleComposeFiles(t *testing.T) {
204204
assert.Equal(t, "busybox", multipleConfig.Image)
205205
assert.Equal(t, "multi", multipleConfig.ContainerName)
206206
assert.Equal(t, []string{"8000", "9000", "10000"}, multipleConfig.Ports)
207-
assert.Equal(t, int64(40000000), multipleConfig.MemLimit)
207+
assert.Equal(t, yaml.StringorInt(40000000), multipleConfig.MemLimit)
208208
}

script/vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ clone git golang.org/x/crypto 3fbbcd23f1cb824e69491a5930cfeff09b12f4d2 https://g
2727
clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git
2828
# clone git golang.org/x/net 47990a1ba55743e6ef1affd3a14e5bac8553615d https://github.com/golang/net.git
2929
clone git gopkg.in/check.v1 11d3bc7aa68e238947792f30573146a3231fc0f1
30-
clone git github.com/cloudfoundry-incubator/candiedyaml 5cef21e2e4f0fd147973b558d4db7395176bcd95
30+
clone git gopkg.in/yaml.v2 e4d366fc3c7938e2958e662b4258c7a89e1f0e3e
3131
clone git github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62
3232
clone git github.com/Microsoft/go-winio v0.3.0
3333
clone git github.com/xeipuuv/gojsonpointer e0fe6f68307607d540ed8eac07a342c33fa1b54a

utils/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/Sirupsen/logrus"
88

9-
yaml "github.com/cloudfoundry-incubator/candiedyaml"
9+
"gopkg.in/yaml.v2"
1010
)
1111

1212
// InParallel holds a pool and a waitgroup to execute tasks in parallel and to be able

0 commit comments

Comments
 (0)