Repository: compose-spec/compose-go
Pull request #141 (2021-05-25 08:56:51)

Add support for port's host_ip in "long syntax"
implements https://github.com/compose-spec/compose-spec/pull/173


Patch:
diff --git a/schema/compose-spec.json b/schema/compose-spec.json
index f7460bf..cefe476 100644
--- a/schema/compose-spec.json
+++ b/schema/compose-spec.json
@@ -316,6 +316,7 @@
                 "type": "object",
                 "properties": {
                   "mode": {"type": "string"},
+                  "host_ip": {"type": "string"},
                   "target": {"type": "integer"},
                   "published": {"type": "integer"},
                   "protocol": {"type": "string"}
diff --git a/types/types.go b/types/types.go
index 3bebcbe..02c62a9 100644
--- a/types/types.go
+++ b/types/types.go
@@ -547,7 +547,7 @@ type ServiceNetworkConfig struct {
 // ServicePortConfig is the port configuration for a service
 type ServicePortConfig struct {
 	Mode      string `yaml:",omitempty" json:"mode,omitempty"`
-	HostIP    string `yaml:"-" json:"-"`
+	HostIP    string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
 	Target    uint32 `yaml:",omitempty" json:"target,omitempty"`
 	Published uint32 `yaml:",omitempty" json:"published,omitempty"`
 	Protocol  string `yaml:",omitempty" json:"protocol,omitempty"`


Test patch:
diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go
index 721ef60..af9807f 100644
--- a/loader/full-struct_test.go
+++ b/loader/full-struct_test.go
@@ -741,50 +741,62 @@ func fullExampleYAML(workingDir, homeDir string) string {
       published: 49100
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 8001
       published: 8001
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5000
       published: 5000
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5001
       published: 5001
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5002
       published: 5002
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5003
       published: 5003
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5004
       published: 5004
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5005
       published: 5005
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5006
       published: 5006
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5007
       published: 5007
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5008
       published: 5008
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5009
       published: 5009
       protocol: tcp
     - mode: ingress
+      host_ip: 127.0.0.1
       target: 5010
       published: 5010
       protocol: tcp
@@ -1313,72 +1325,84 @@ func fullExampleJSON(workingDir, homeDir string) string {
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 8001,
           "published": 8001,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5000,
           "published": 5000,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5001,
           "published": 5001,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5002,
           "published": 5002,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5003,
           "published": 5003,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5004,
           "published": 5004,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5005,
           "published": 5005,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5006,
           "published": 5006,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5007,
           "published": 5007,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5008,
           "published": 5008,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5009,
           "published": 5009,
           "protocol": "tcp"
         },
         {
           "mode": "ingress",
+          "host_ip": "127.0.0.1",
           "target": 5010,
           "published": 5010,
           "protocol": "tcp"