Skip to content

Commit

Permalink
prefer list format for extra_hosts to preserve backward compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Dec 7, 2022
1 parent d61c32f commit 058fad0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ services:
# somehost: "162.242.195.82"
# otherhost: "50.31.209.229"
extra_hosts:
- "somehost:162.242.195.82"
- "otherhost:50.31.209.229"
- "somehost:162.242.195.82"

hostname: foo

Expand Down
12 changes: 6 additions & 6 deletions loader/full-struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
- otherhost:50.31.209.229
- somehost:162.242.195.82
hostname: foo
healthcheck:
test:
Expand Down Expand Up @@ -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": [
"otherhost:50.31.209.229",
"somehost:162.242.195.82"
],
"hostname": "foo",
"healthcheck": {
"test": [
Expand Down
12 changes: 12 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,18 @@ func (h HostsList) AsList() []string {
return l
}

func (h HostsList) MarshalYAML() (interface{}, error) {
list := h.AsList()
sort.Strings(list)
return list, nil
}

func (h HostsList) MarshalJSON() ([]byte, error) {
list := h.AsList()
sort.Strings(list)
return json.Marshal(list)
}

// LoggingConfig the logging configuration for a service
type LoggingConfig struct {
Driver string `yaml:",omitempty" json:"driver,omitempty"`
Expand Down

0 comments on commit 058fad0

Please sign in to comment.