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:
3148
3148
assert .NilError (t , err )
3149
3149
assert .Equal (t , p .Name , "test-with-empty-file" )
3150
3150
}
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 322
322
{
323
323
"type" : " object" ,
324
324
"properties" : {
325
+ "name" : {"type" : " string" },
325
326
"mode" : {"type" : " string" },
326
327
"host_ip" : {"type" : " string" },
327
328
"target" : {"type" : " integer" },
Original file line number Diff line number Diff line change @@ -433,6 +433,7 @@ type ServiceNetworkConfig struct {
433
433
434
434
// ServicePortConfig is the port configuration for a service
435
435
type ServicePortConfig struct {
436
+ Name string `yaml:"name,omitempty" json:"name,omitempty"`
436
437
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
437
438
HostIP string `yaml:"host_ip,omitempty" json:"host_ip,omitempty"`
438
439
Target uint32 `yaml:"target,omitempty" json:"target,omitempty"`
You can’t perform that action at this time.
0 commit comments