Преглед изворни кода

Add expanded port syntax to Compose schema and types.

This commit adds expanded port syntax to Compose schema and types
so that it is possible to have
```
ports:
  - mode: host
    target: 80
    published: 9005
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Yong Tang пре 8 година
родитељ
комит
60c1eaf8f0

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
cli/compose/schema/bindata.go


+ 14 - 2
cli/compose/schema/data/config_schema_v3.1.json

@@ -167,8 +167,20 @@
         "ports": {
         "ports": {
           "type": "array",
           "type": "array",
           "items": {
           "items": {
-            "type": ["string", "number"],
-            "format": "ports"
+            "oneOf": [
+              {"type": "number", "format": "ports"},
+              {"type": "string", "format": "ports"},
+              {
+                "type": "object",
+                "properties": {
+                  "mode": {"type": "string"},
+                  "target": {"type": "integer"},
+                  "published": {"type": "integer"},
+                  "protocol": {"type": "string"}
+                },
+                "additionalProperties": false
+              }
+            ]
           },
           },
           "uniqueItems": true
           "uniqueItems": true
         },
         },

+ 9 - 1
cli/compose/types/types.go

@@ -106,7 +106,7 @@ type ServiceConfig struct {
 	NetworkMode     string `mapstructure:"network_mode"`
 	NetworkMode     string `mapstructure:"network_mode"`
 	Networks        map[string]*ServiceNetworkConfig
 	Networks        map[string]*ServiceNetworkConfig
 	Pid             string
 	Pid             string
-	Ports           StringOrNumberList
+	Ports           []ServicePortConfig
 	Privileged      bool
 	Privileged      bool
 	ReadOnly        bool `mapstructure:"read_only"`
 	ReadOnly        bool `mapstructure:"read_only"`
 	Restart         string
 	Restart         string
@@ -215,6 +215,14 @@ type ServiceNetworkConfig struct {
 	Ipv6Address string `mapstructure:"ipv6_address"`
 	Ipv6Address string `mapstructure:"ipv6_address"`
 }
 }
 
 
+// ServicePortConfig is the port configuration for a service
+type ServicePortConfig struct {
+	Mode      string
+	Target    uint32
+	Published uint32
+	Protocol  string
+}
+
 // ServiceSecretConfig is the secret configuration for a service
 // ServiceSecretConfig is the secret configuration for a service
 type ServiceSecretConfig struct {
 type ServiceSecretConfig struct {
 	Source string
 	Source string

Неке датотеке нису приказане због велике количине промена