Skip to content

Commit

Permalink
Add expanded port syntax to Compose schema and types.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yongtang committed Feb 7, 2017
1 parent 6d194cd commit c69e0f7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compose/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions compose/schema/data/config_schema_v3.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,20 @@
"ports": {
"type": "array",
"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
},
Expand Down
10 changes: 9 additions & 1 deletion compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type ServiceConfig struct {
NetworkMode string `mapstructure:"network_mode"`
Networks map[string]*ServiceNetworkConfig
Pid string
Ports StringOrNumberList
Ports []ServicePortConfig
Privileged bool
ReadOnly bool `mapstructure:"read_only"`
Restart string
Expand Down Expand Up @@ -215,6 +215,14 @@ type ServiceNetworkConfig struct {
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
type ServiceSecretConfig struct {
Source string
Expand Down

0 comments on commit c69e0f7

Please sign in to comment.