Skip to content

Commit ce9b87b

Browse files
committed
application (level 7) protocol on ports
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 54804a9 commit ce9b87b

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

loader/loader_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,3 +3175,32 @@ services:
31753175
assert.Equal(t, ports[0].Name, "http")
31763176
assert.Equal(t, ports[1].Name, "https")
31773177
}
3178+
3179+
func TestAppProtocol(t *testing.T) {
3180+
yaml := `
3181+
name: test-named-ports
3182+
services:
3183+
test:
3184+
image: foo
3185+
ports:
3186+
- published: 8080
3187+
target: 80
3188+
protocol: tcp
3189+
app_protocol: http
3190+
- published: 8083
3191+
target: 443
3192+
protocol: tcp
3193+
app_protocol: https
3194+
`
3195+
p, err := LoadWithContext(context.Background(), types.ConfigDetails{
3196+
ConfigFiles: []types.ConfigFile{
3197+
{
3198+
Content: []byte(yaml),
3199+
},
3200+
},
3201+
})
3202+
assert.NilError(t, err)
3203+
ports := p.Services["test"].Ports
3204+
assert.Equal(t, ports[0].AppProtocol, "http")
3205+
assert.Equal(t, ports[1].AppProtocol, "https")
3206+
}

schema/compose-spec.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@
327327
"host_ip": {"type": "string"},
328328
"target": {"type": "integer"},
329329
"published": {"type": ["string", "integer"]},
330-
"protocol": {"type": "string"}
330+
"protocol": {"type": "string"},
331+
"app_protocol": {"type": "string"}
331332
},
332333
"additionalProperties": false,
333334
"patternProperties": {"^x-": {}}

types/types.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,13 @@ 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"`
437-
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
438-
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
439-
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`
440-
Published string `yaml:"published,omitempty" json:"published,omitempty"`
441-
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
436+
Name string `yaml:"name,omitempty" json:"name,omitempty"`
437+
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
438+
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
439+
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`
440+
Published string `yaml:"published,omitempty" json:"published,omitempty"`
441+
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
442+
AppProtocol string `yaml:"app_protocol,omitempty" json:"app_protocol,omitempty"`
442443

443444
Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
444445
}

0 commit comments

Comments
 (0)