mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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>
This commit is contained in:
@@ -2606,6 +2606,54 @@ definitions:
|
||||
hints:
|
||||
nullable: false
|
||||
|
||||
ServiceInfo:
|
||||
x-nullable: false
|
||||
x-omitempty: false
|
||||
description: >
|
||||
represents service parameters with the list of service's tasks
|
||||
type: "object"
|
||||
properties:
|
||||
VIP:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
Ports:
|
||||
type: "array"
|
||||
x-omitempty: false
|
||||
items:
|
||||
type: "string"
|
||||
LocalLBIndex:
|
||||
type: "integer"
|
||||
format: "int"
|
||||
x-omitempty: false
|
||||
Tasks:
|
||||
type: "array"
|
||||
x-omitempty: false
|
||||
items:
|
||||
$ref: "#/definitions/NetworkTaskInfo"
|
||||
|
||||
NetworkTaskInfo:
|
||||
x-nullable: false
|
||||
x-omitempty: false
|
||||
x-go-name: Task
|
||||
description: >
|
||||
carries the information about one backend task
|
||||
type: "object"
|
||||
properties:
|
||||
Name:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
EndpointID:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
EndpointIP:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
Info:
|
||||
type: "object"
|
||||
x-omitempty: false
|
||||
additionalProperties:
|
||||
type: "string"
|
||||
|
||||
ConfigReference:
|
||||
x-nullable: false
|
||||
x-omitempty: false
|
||||
@@ -2620,6 +2668,7 @@ definitions:
|
||||
configuration. The specified network must be an existing config-only
|
||||
network. Only network names are allowed, not network IDs.
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "config_only_network_01"
|
||||
|
||||
IPAM:
|
||||
@@ -2669,26 +2718,34 @@ definitions:
|
||||
|
||||
EndpointResource:
|
||||
type: "object"
|
||||
description: >
|
||||
contains network resources allocated and used for a
|
||||
container in a network.
|
||||
properties:
|
||||
Name:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "container_1"
|
||||
EndpointID:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a"
|
||||
MacAddress:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "02:42:ac:13:00:02"
|
||||
IPv4Address:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "172.19.0.2/16"
|
||||
IPv6Address:
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: ""
|
||||
|
||||
PeerInfo:
|
||||
description: |
|
||||
PeerInfo represents one peer of an overlay network.
|
||||
description: >
|
||||
represents one peer of an overlay network.
|
||||
type: "object"
|
||||
x-nullable: false
|
||||
properties:
|
||||
@@ -2696,11 +2753,13 @@ definitions:
|
||||
description:
|
||||
ID of the peer-node in the Swarm cluster.
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "6869d7c1732b"
|
||||
IP:
|
||||
description:
|
||||
IP-address of the peer-node in the Swarm cluster.
|
||||
type: "string"
|
||||
x-omitempty: false
|
||||
example: "10.133.77.91"
|
||||
|
||||
NetworkCreateResponse:
|
||||
|
||||
20
api/types/network/config_reference.go
Normal file
20
api/types/network/config_reference.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// ConfigReference The config-only network source to provide the configuration for
|
||||
// this network.
|
||||
//
|
||||
// swagger:model ConfigReference
|
||||
type ConfigReference struct {
|
||||
|
||||
// The name of the config-only network that provides the network's
|
||||
// configuration. The specified network must be an existing config-only
|
||||
// network. Only network names are allowed, not network IDs.
|
||||
//
|
||||
// Example: config_only_network_01
|
||||
Network string `json:"Network"`
|
||||
}
|
||||
31
api/types/network/endpoint_resource.go
Normal file
31
api/types/network/endpoint_resource.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a container in a network.
|
||||
//
|
||||
// swagger:model EndpointResource
|
||||
type EndpointResource struct {
|
||||
|
||||
// name
|
||||
// Example: container_1
|
||||
Name string `json:"Name"`
|
||||
|
||||
// endpoint ID
|
||||
// Example: 628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a
|
||||
EndpointID string `json:"EndpointID"`
|
||||
|
||||
// mac address
|
||||
// Example: 02:42:ac:13:00:02
|
||||
MacAddress string `json:"MacAddress"`
|
||||
|
||||
// IPv4 address
|
||||
// Example: 172.19.0.2/16
|
||||
IPv4Address string `json:"IPv4Address"`
|
||||
|
||||
// IPv6 address
|
||||
IPv6Address string `json:"IPv6Address"`
|
||||
}
|
||||
@@ -40,20 +40,6 @@ type Address struct {
|
||||
PrefixLen int
|
||||
}
|
||||
|
||||
// PeerInfo represents one peer of an overlay network
|
||||
type PeerInfo struct {
|
||||
Name string
|
||||
IP string
|
||||
}
|
||||
|
||||
// Task carries the information about one backend task
|
||||
type Task struct {
|
||||
Name string
|
||||
EndpointID string
|
||||
EndpointIP string
|
||||
Info map[string]string
|
||||
}
|
||||
|
||||
// ServiceInfo represents service parameters with the list of service's tasks
|
||||
type ServiceInfo struct {
|
||||
VIP string
|
||||
@@ -62,27 +48,12 @@ type ServiceInfo struct {
|
||||
Tasks []Task
|
||||
}
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a
|
||||
// container in a network.
|
||||
type EndpointResource struct {
|
||||
Name string
|
||||
EndpointID string
|
||||
MacAddress string
|
||||
IPv4Address string
|
||||
IPv6Address string
|
||||
}
|
||||
|
||||
// NetworkingConfig represents the container's networking configuration for each of its interfaces
|
||||
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
|
||||
type NetworkingConfig struct {
|
||||
EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
|
||||
}
|
||||
|
||||
// ConfigReference specifies the source which provides a network's configuration
|
||||
type ConfigReference struct {
|
||||
Network string
|
||||
}
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/networks/prune"
|
||||
type PruneReport struct {
|
||||
|
||||
20
api/types/network/peer_info.go
Normal file
20
api/types/network/peer_info.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PeerInfo represents one peer of an overlay network.
|
||||
//
|
||||
// swagger:model PeerInfo
|
||||
type PeerInfo struct {
|
||||
|
||||
// ID of the peer-node in the Swarm cluster.
|
||||
// Example: 6869d7c1732b
|
||||
Name string `json:"Name"`
|
||||
|
||||
// IP-address of the peer-node in the Swarm cluster.
|
||||
// Example: 10.133.77.91
|
||||
IP string `json:"IP"`
|
||||
}
|
||||
24
api/types/network/task.go
Normal file
24
api/types/network/task.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// Task carries the information about one backend task
|
||||
//
|
||||
// swagger:model Task
|
||||
type Task struct {
|
||||
|
||||
// name
|
||||
Name string `json:"Name"`
|
||||
|
||||
// endpoint ID
|
||||
EndpointID string `json:"EndpointID"`
|
||||
|
||||
// endpoint IP
|
||||
EndpointIP string `json:"EndpointIP"`
|
||||
|
||||
// info
|
||||
Info map[string]string `json:"Info"`
|
||||
}
|
||||
@@ -61,10 +61,14 @@ EOT
|
||||
# See https://github.com/moby/moby/pull/47526#discussion_r1551800022
|
||||
|
||||
generate_model types/network --keep-spec-order <<- 'EOT'
|
||||
ConfigReference
|
||||
EndpointResource
|
||||
Network
|
||||
NetworkCreateResponse
|
||||
NetworkInspect
|
||||
NetworkSummary
|
||||
NetworkTaskInfo
|
||||
PeerInfo
|
||||
EOT
|
||||
|
||||
generate_model types/plugin <<- 'EOT'
|
||||
|
||||
20
vendor/github.com/moby/moby/api/types/network/config_reference.go
generated
vendored
Normal file
20
vendor/github.com/moby/moby/api/types/network/config_reference.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// ConfigReference The config-only network source to provide the configuration for
|
||||
// this network.
|
||||
//
|
||||
// swagger:model ConfigReference
|
||||
type ConfigReference struct {
|
||||
|
||||
// The name of the config-only network that provides the network's
|
||||
// configuration. The specified network must be an existing config-only
|
||||
// network. Only network names are allowed, not network IDs.
|
||||
//
|
||||
// Example: config_only_network_01
|
||||
Network string `json:"Network"`
|
||||
}
|
||||
31
vendor/github.com/moby/moby/api/types/network/endpoint_resource.go
generated
vendored
Normal file
31
vendor/github.com/moby/moby/api/types/network/endpoint_resource.go
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a container in a network.
|
||||
//
|
||||
// swagger:model EndpointResource
|
||||
type EndpointResource struct {
|
||||
|
||||
// name
|
||||
// Example: container_1
|
||||
Name string `json:"Name"`
|
||||
|
||||
// endpoint ID
|
||||
// Example: 628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a
|
||||
EndpointID string `json:"EndpointID"`
|
||||
|
||||
// mac address
|
||||
// Example: 02:42:ac:13:00:02
|
||||
MacAddress string `json:"MacAddress"`
|
||||
|
||||
// IPv4 address
|
||||
// Example: 172.19.0.2/16
|
||||
IPv4Address string `json:"IPv4Address"`
|
||||
|
||||
// IPv6 address
|
||||
IPv6Address string `json:"IPv6Address"`
|
||||
}
|
||||
29
vendor/github.com/moby/moby/api/types/network/network_types.go
generated
vendored
29
vendor/github.com/moby/moby/api/types/network/network_types.go
generated
vendored
@@ -40,20 +40,6 @@ type Address struct {
|
||||
PrefixLen int
|
||||
}
|
||||
|
||||
// PeerInfo represents one peer of an overlay network
|
||||
type PeerInfo struct {
|
||||
Name string
|
||||
IP string
|
||||
}
|
||||
|
||||
// Task carries the information about one backend task
|
||||
type Task struct {
|
||||
Name string
|
||||
EndpointID string
|
||||
EndpointIP string
|
||||
Info map[string]string
|
||||
}
|
||||
|
||||
// ServiceInfo represents service parameters with the list of service's tasks
|
||||
type ServiceInfo struct {
|
||||
VIP string
|
||||
@@ -62,27 +48,12 @@ type ServiceInfo struct {
|
||||
Tasks []Task
|
||||
}
|
||||
|
||||
// EndpointResource contains network resources allocated and used for a
|
||||
// container in a network.
|
||||
type EndpointResource struct {
|
||||
Name string
|
||||
EndpointID string
|
||||
MacAddress string
|
||||
IPv4Address string
|
||||
IPv6Address string
|
||||
}
|
||||
|
||||
// NetworkingConfig represents the container's networking configuration for each of its interfaces
|
||||
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
|
||||
type NetworkingConfig struct {
|
||||
EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
|
||||
}
|
||||
|
||||
// ConfigReference specifies the source which provides a network's configuration
|
||||
type ConfigReference struct {
|
||||
Network string
|
||||
}
|
||||
|
||||
// PruneReport contains the response for Engine API:
|
||||
// POST "/networks/prune"
|
||||
type PruneReport struct {
|
||||
|
||||
20
vendor/github.com/moby/moby/api/types/network/peer_info.go
generated
vendored
Normal file
20
vendor/github.com/moby/moby/api/types/network/peer_info.go
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// PeerInfo represents one peer of an overlay network.
|
||||
//
|
||||
// swagger:model PeerInfo
|
||||
type PeerInfo struct {
|
||||
|
||||
// ID of the peer-node in the Swarm cluster.
|
||||
// Example: 6869d7c1732b
|
||||
Name string `json:"Name"`
|
||||
|
||||
// IP-address of the peer-node in the Swarm cluster.
|
||||
// Example: 10.133.77.91
|
||||
IP string `json:"IP"`
|
||||
}
|
||||
24
vendor/github.com/moby/moby/api/types/network/task.go
generated
vendored
Normal file
24
vendor/github.com/moby/moby/api/types/network/task.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package network
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// Task carries the information about one backend task
|
||||
//
|
||||
// swagger:model Task
|
||||
type Task struct {
|
||||
|
||||
// name
|
||||
Name string `json:"Name"`
|
||||
|
||||
// endpoint ID
|
||||
EndpointID string `json:"EndpointID"`
|
||||
|
||||
// endpoint IP
|
||||
EndpointIP string `json:"EndpointIP"`
|
||||
|
||||
// info
|
||||
Info map[string]string `json:"Info"`
|
||||
}
|
||||
Reference in New Issue
Block a user