10BC0 api/t/network: generate more structs from Swagger · moby/moby@b895ee6 · GitHub
[go: up one dir, main page]

Skip to content

Commit b895ee6

Browse files
committed
api/t/network: generate more structs from Swagger
Replace hand-rolled struct definitions for api/types/network with types generated from the Swagger definitions: - ConfigReference - EndpointResource - NetworkingConfig - PeerInfo - ServiceInfo - Task Add Swagger definitions for ServiceInfo and Task. Signed-off-by: Cory Snider <csnider@mirantis.com>
1 parent d4f1d8d commit b895ee6

File tree

12 files changed

+255
-60
lines changed

12 files changed

+255
-60
lines changed

api/swagger.yaml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,54 @@ definitions:
26062606
hints:
26072607
nullable: false
26082608

2609+
ServiceInfo:
2610+
x-nullable: false
2611+
x-omitempty: false
2612+
description: >
2613+
represents service parameters with the list of service's tasks
2614+
type: "object"
2615+
properties:
2616+
VIP:
2617+
type: "string"
2618+
x-omitempty: false
2619+
Ports:
2620+
type: "array"
2621+
x-omitempty: false
2622+
items:
2623+
type: "string"
2624+
LocalLBIndex:
2625+
type: "integer"
2626+
format: "int"
2627+
x-omitempty: false
2628+
Tasks:
2629+
type: "array"
2630+
x-omitempty: false
2631+
items:
2632+
$ref: "#/definitions/NetworkTaskInfo"
2633+
2634+
NetworkTaskInfo:
2635+
x-nullable: false
2636+
x-omitempty: false
2637+
x-go-name: Task
2638+
description: >
2639+
carries the information about one backend task
2640+
type: "object"
2641+
properties:
2642+
Name:
2643+
type: "string"
2644+
x-omitempty: false
2645+
EndpointID:
2646+
type: "string"
2647+
x-omitempty: false
2648+
EndpointIP:
2649+
type: "string"
2650+
x-omitempty: false
2651+
Info:
2652+
type: "object"
2653+
x-omitempty: false
2654+
additionalProperties:
2655+
type: "string"
2656+
26092657
ConfigReference:
26102658
x-nullable: false
26112659
x-omitempty: false
@@ -2620,6 +2668,7 @@ definitions:
26202668
configuration. The specified network must be an existing config-only
26212669
network. Only network names are allowed, not network IDs.
26222670
type: "string"
2671+
x-omitempty: false
26232672
example: "config_only_network_01"
26242673

26252674
IPAM:
@@ -2669,38 +2718,48 @@ definitions:
26692718

26702719
EndpointResource:
26712720
type: "object"
2721+
description: >
2722+
contains network resources allocated and used for a
2723+
container in a network.
26722724
properties:
26732725
Name:
26742726
type: "string"
2727+
x-omitempty: false
26752728
example: "container_1"
26762729
EndpointID:
26772730
type: "string"
2731+
x-omitempty: false
26782732
example: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
26792733
MacAddress:
26802734
type: "string"
2735+
x-omitempty: false
26812736
example: "02:42:ac:13:00:02"
26822737
IPv4Address:
26832738
type: "string"
2739+
x-omitempty: false
26842740
example: "172.19.0.2/16"
26852741
IPv6Address:
26862742
type: "string"
2743+
x-omitempty: false
26872744
example: ""
26882745

26892746
PeerInfo:
2690-
description: |
2691-
PeerInfo represents one peer of an overlay network.
2747+
description: >
2748+
represents one peer of an overlay network.
26922749
type: "object"
26932750
x-nullable: false
26942751
properties:
26952752
Name:
26962753
description:
26972754
ID of the peer-node in the Swarm cluster.
26982755
type: "string"
2756+
x-omitempty: false
26992757
example: "6869d7c1732b"
27002758
IP:
27012759
description:
27022760
IP-address of the peer-node in the Swarm cluster.
27032761
type: "string"
2762+
x-omitempty: false
27042763
example: "10.133.77.91"
27052764

27062765
NetworkCreateResponse:

api/types/network/config_reference.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types/network/endpoint_resource.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types/network/network_types.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,6 @@ type Address struct {
4040
PrefixLen int
4141
}
4242

43-
// PeerInfo represents one peer of an overlay network
44-
type PeerInfo struct {
45-
Name string
46-
IP string
47-
}
48-
49-
// Task carries the information about one backend task
50-
type Task struct {
51-
Name string
52-
EndpointID string
53-
EndpointIP string
54-
Info map[string]string
55-
}
56-
5743
// ServiceInfo represents service parameters with the list of service's tasks
5844
type ServiceInfo struct {
5945
VIP string
@@ -62,27 +48,12 @@ type ServiceInfo struct {
6248
Tasks []Task
6349
}
6450

65-
// EndpointResource contains network resources allocated and used for a
66-
// container in a network.
67-
type EndpointResource struct {
68-
Name string
69-
EndpointID string
70-
MacAddress string
71-
IPv4Address string
72-
IPv6Address string
73-
}
74-
7551
// NetworkingConfig represents the container's networking configuration for each of its interfaces
7652
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
7753
type NetworkingConfig struct {
7854
EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
7955
}
8056

81-
// ConfigReference specifies the source which provides a network's configuration
82-
type ConfigReference struct {
83-
Network string
84-
}
85-
8657
// PruneReport contains the response for Engine API:
8758
// POST "/networks/prune"
8859
type PruneReport struct {

api/types/network/peer_info.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types/network/task.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/generate-swagger-api.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ EOT
6060
# See https://github.com/moby/moby/pull/47526#discussion_r1551800022
6161

6262
generate_model types/network --keep-spec-order <<- 'EOT'
63+
ConfigReference
64+
EndpointResource
6365
Network
6466
NetworkCreateResponse
6567
NetworkInspect
6668
NetworkSummary
69+
NetworkTaskInfo
70+
PeerInfo
6771
EOT
6872

6973
generate_model types/plugin <<- 'EOT'

vendor/github.com/moby/moby/api/types/network/config_reference.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/network/endpoint_resource.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/moby/moby/api/types/network/network_types.go

Lines changed: 0 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0