diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go index 80d92181e..0dad15bd7 100644 --- a/loader/full-struct_test.go +++ b/loader/full-struct_test.go @@ -716,8 +716,8 @@ services: - project_db_1:mysql - project_db_1:postgresql extra_hosts: - otherhost: 50.31.209.229 - somehost: 162.242.195.82 + - somehost:162.242.195.82 + - otherhost:50.31.209.229 hostname: foo healthcheck: test: @@ -1302,10 +1302,10 @@ func fullExampleJSON(workingDir, homeDir string) string { "project_db_1:mysql", "project_db_1:postgresql" ], - "extra_hosts": { - "otherhost": "50.31.209.229", - "somehost": "162.242.195.82" - }, + "extra_hosts": [ + "somehost:162.242.195.82", + "otherhost:50.31.209.229" + ], "hostname": "foo", "healthcheck": { "test": [ diff --git a/types/types.go b/types/types.go index b01167ba0..2f3aa90f4 100644 --- a/types/types.go +++ b/types/types.go @@ -354,12 +354,12 @@ type ThrottleDevice struct { // ShellCommand is a string or list of string args. // // When marshaled to YAML, nil command fields will be omitted if `omitempty` -// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `''`) +// is specified as a struct tag. Explicitly empty commands (i.e. `[]` or `”`) // will serialize to an empty array (`[]`). // // When marshaled to JSON, the `omitempty` struct must NOT be specified. // If the command field is nil, it will be serialized as `null`. -// Explicitly empty commands (i.e. `[]` or `''`) will serialize to an empty +// Explicitly empty commands (i.e. `[]` or `”`) will serialize to an empty // array (`[]`). // // The distinction between nil and explicitly empty is important to distinguish @@ -539,6 +539,14 @@ func (h HostsList) AsList() []string { return l } +func (h HostsList) MarshalYAML() (interface{}, error) { + return h.AsList(), nil +} + +func (h HostsList) MarshalJSON() ([]byte, error) { + return json.Marshal(h.AsList()) +} + // LoggingConfig the logging configuration for a service type LoggingConfig struct { Driver string `yaml:",omitempty" json:"driver,omitempty"`