Skip to content

Commit 058fad0

Browse files
committed
prefer list format for extra_hosts to preserve backward compatibility
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent d61c32f commit 058fad0

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

loader/full-example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ services:
160160
# somehost: "162.242.195.82"
161161
# otherhost: "50.31.209.229"
162162
extra_hosts:
163-
- "somehost:162.242.195.82"
164163
- "otherhost:50.31.209.229"
164+
- "somehost:162.242.195.82"
165165

166166
hostname: foo
167167

loader/full-struct_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ services:
716716
- project_db_1:mysql
717717
- project_db_1:postgresql
718718
extra_hosts:
719-
otherhost: 50.31.209.229
720-
somehost: 162.242.195.82
719+
- otherhost:50.31.209.229
720+
- somehost:162.242.195.82
721721
hostname: foo
722722
healthcheck:
723723
test:
@@ -1302,10 +1302,10 @@ func fullExampleJSON(workingDir, homeDir string) string {
13021302
"project_db_1:mysql",
13031303
"project_db_1:postgresql"
13041304
],
1305-
"extra_hosts": {
1306-
"otherhost": "50.31.209.229",
1307-
"somehost": "162.242.195.82"
1308-
},
1305+
"extra_hosts": [
1306+
"otherhost:50.31.209.229",
1307+
"somehost:162.242.195.82"
1308+
],
13091309
"hostname": "foo",
13101310
"healthcheck": {
13111311
"test": [

types/types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,18 @@ func (h HostsList) AsList() []string {
539539
return l
540540
}
541541

542+
func (h HostsList) MarshalYAML() (interface{}, error) {
543+
list := h.AsList()
544+
sort.Strings(list)
545+
return list, nil
546+
}
547+
548+
func (h HostsList) MarshalJSON() ([]byte, error) {
549+
list := h.AsList()
550+
sort.Strings(list)
551+
return json.Marshal(list)
552+
}
553+
542554
// LoggingConfig the logging configuration for a service
543555
type LoggingConfig struct {
544556
Driver string `yaml:",omitempty" json:"driver,omitempty"`

0 commit comments

Comments
 (0)