Skip to content

Commit 54804a9

Browse files
committed
introduce port.name
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 69a8120 commit 54804a9

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

loader/loader_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,3 +3148,30 @@ services:
31483148
assert.NilError(t, err)
31493149
assert.Equal(t, p.Name, "test-with-empty-file")
31503150
}
3151+
3152+
func TestNamedPort(t *testing.T) {
3153+
yaml := `
3154+
name: test-named-ports
3155+
services:
3156+
test:
3157+
image: foo
3158+
ports:
3159+
- name: http
3160+
published: 8080
3161+
target: 80
3162+
- name: https
3163+
published: 8083
3164+
target: 443
3165+
`
3166+
p, err := LoadWithContext(context.Background(), types.ConfigDetails{
3167+
ConfigFiles: []types.ConfigFile{
3168+
{
3169+
Content: []byte(yaml),
3170+
},
3171+
},
3172+
})
3173+
assert.NilError(t, err)
3174+
ports := p.Services["test"].Ports
3175+
assert.Equal(t, ports[0].Name, "http")
3176+
assert.Equal(t, ports[1].Name, "https")
3177+
}

schema/compose-spec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322
{
323323
"type": "object",
324324
"properties": {
325+
"name": {"type": "string"},
325326
"mode": {"type": "string"},
326327
"host_ip": {"type": "string"},
327328
"target": {"type": "integer"},

types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ type ServiceNetworkConfig struct {
433433

434434
// ServicePortConfig is the port configuration for a service
435435
type ServicePortConfig struct {
436+
Name string `yaml:"name,omitempty" json:"name,omitempty"`
436437
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
437438
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
438439
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`

0 commit comments

Comments
 (0)