Skip to content

Commit

Permalink
application (level 7) protocol on ports
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Mar 15, 2024
1 parent 54804a9 commit ce9b87b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
29 changes: 29 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3175,3 +3175,32 @@ services:
assert.Equal(t, ports[0].Name, "http")
assert.Equal(t, ports[1].Name, "https")
}

func TestAppProtocol(t *testing.T) {
yaml := `
name: test-named-ports
services:
test:
image: foo
ports:
- published: 8080
target: 80
protocol: tcp
app_protocol: http
- published: 8083
target: 443
protocol: tcp
app_protocol: https
`
p, err := LoadWithContext(context.Background(), types.ConfigDetails{
ConfigFiles: []types.ConfigFile{
{
Content: []byte(yaml),
},
},
})
assert.NilError(t, err)
ports := p.Services["test"].Ports
assert.Equal(t, ports[0].AppProtocol, "http")
assert.Equal(t, ports[1].AppProtocol, "https")
}
3 changes: 2 additions & 1 deletion schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@
"host_ip": {"type": "string"},
"target": {"type": "integer"},
"published": {"type": ["string", "integer"]},
"protocol": {"type": "string"}
"protocol": {"type": "string"},
"app_protocol": {"type": "string"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
Expand Down
13 changes: 7 additions & 6 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,13 @@ type ServiceNetworkConfig struct {

// ServicePortConfig is the port configuration for a service
type ServicePortConfig struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`
Published string `yaml:"published,omitempty" json:"published,omitempty"`
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`
Published string `yaml:"published,omitempty" json:"published,omitempty"`
Protocol string `yaml:"protocol,omitempty" json:"protocol,omitempty"`
AppProtocol string `yaml:"app_protocol,omitempty" json:"app_protocol,omitempty"`

Extensions Extensions `yaml:"#extensions,inline,omitempty" json:"-"`
}
Expand Down

0 comments on commit ce9b87b

Please sign in to comment.