Skip to content

Commit e12b749

Browse files
committed
api/types: move Port to api/types/container
This moves the `Port` type to the container package, and deprecates the old location. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5517322 commit e12b749

5 files changed

Lines changed: 14 additions & 9 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package types
1+
package container
22

33
// This file was generated by the swagger tool.
44
// Editing this file might prove futile when you re-run the swagger generate command

api/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ type Container struct {
143143
ImageID string
144144
Command string
145145
Created int64
146-
Ports []Port
146+
Ports []container.Port
147147
SizeRw int64 `json:",omitempty"`
148148
SizeRootFs int64 `json:",omitempty"`
149149
Labels map[string]string

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,8 @@ type HealthcheckResult = container.HealthcheckResult
255255
//
256256
// Deprecated: use [container.MountPoint].
257257
type MountPoint = container.MountPoint
258+
259+
// Port An open port on a container
260+
//
261+
// Deprecated: use [container.Port].
262+
type Port = container.Port

container/view.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
310310
ID: ctr.ID,
311311
Names: v.getNames(ctr.ID),
312312
ImageID: ctr.ImageID.String(),
313-
Ports: []types.Port{},
313+
Ports: []container.Port{},
314314
Mounts: ctr.GetMountPoints(),
315315
State: ctr.State.StateString(),
316316
Status: ctr.State.String(),
@@ -366,7 +366,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
366366
snapshot.Command = ctr.Path
367367
}
368368

369-
snapshot.Ports = []types.Port{}
369+
snapshot.Ports = []container.Port{}
370370
networks := make(map[string]*network.EndpointSettings)
371371
if ctr.NetworkSettings != nil {
372372
for name, netw := range ctr.NetworkSettings.Networks {
@@ -398,7 +398,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
398398
continue
399399
}
400400
if len(bindings) == 0 {
401-
snapshot.Ports = append(snapshot.Ports, types.Port{
401+
snapshot.Ports = append(snapshot.Ports, container.Port{
402402
PrivatePort: uint16(p),
403403
Type: port.Proto(),
404404
})
@@ -410,7 +410,7 @@ func (v *View) transform(ctr *Container) *Snapshot {
410410
log.G(context.TODO()).WithError(err).Warn("invalid host port map")
411411
continue
412412
}
413-
snapshot.Ports = append(snapshot.Ports, types.Port{
413+
snapshot.Ports = append(snapshot.Ports, container.Port{
414414
PrivatePort: uint16(p),
415415
PublicPort: uint16(h),
416416
Type: port.Proto(),

hack/generate-swagger-api.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ swagger generate model -f api/swagger.yaml \
1010
-n PluginDevice \
1111
-n PluginMount \
1212
-n PluginEnv \
13-
-n PluginInterfaceType \
14-
-n Port
13+
-n PluginInterfaceType
1514

1615
swagger generate model -f api/swagger.yaml \
1716
-t api -m types/container --skip-validator -C api/swagger-gen.yaml \
1817
-n ContainerCreateResponse \
1918
-n ContainerWaitResponse \
2019
-n ContainerWaitExitError \
2120
-n ChangeType \
22-
-n FilesystemChange
21+
-n FilesystemChange \
22+
-n Port
2323

2424
swagger generate model -f api/swagger.yaml \
2525
-t api -m types/image --skip-validator -C api/swagger-gen.yaml \

0 commit comments

Comments
 (0)