File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff 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+ }
Original file line number Diff line number Diff line change 322322 {
323323 "type" : " object" ,
324324 "properties" : {
325+ "name" : {"type" : " string" },
325326 "mode" : {"type" : " string" },
326327 "host_ip" : {"type" : " string" },
327328 "target" : {"type" : " integer" },
Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ type ServiceNetworkConfig struct {
433433
434434// ServicePortConfig is the port configuration for a service
435435type 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"`
You can’t perform that action at this time.
0 commit comments