Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -239,7 +239,7 @@ func (n *networkRouter) postNetworkConnect(ctx context.Context, w http.ResponseW |
| 239 | 239 |
return err |
| 240 | 240 |
} |
| 241 | 241 |
|
| 242 |
- var connect types.NetworkConnect |
|
| 242 |
+ var connect network.ConnectOptions |
|
| 243 | 243 |
if err := httputils.ReadJSON(r, &connect); err != nil {
|
| 244 | 244 |
return err |
| 245 | 245 |
} |
| ... | ... |
@@ -256,7 +256,7 @@ func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.Respon |
| 256 | 256 |
return err |
| 257 | 257 |
} |
| 258 | 258 |
|
| 259 |
- var disconnect types.NetworkDisconnect |
|
| 259 |
+ var disconnect network.DisconnectOptions |
|
| 260 | 260 |
if err := httputils.ReadJSON(r, &disconnect); err != nil {
|
| 261 | 261 |
return err |
| 262 | 262 |
} |
| ... | ... |
@@ -17,6 +17,20 @@ const ( |
| 17 | 17 |
NetworkNat = "nat" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 20 |
+// ConnectOptions represents the data to be used to connect a container to the |
|
| 21 |
+// network. |
|
| 22 |
+type ConnectOptions struct {
|
|
| 23 |
+ Container string |
|
| 24 |
+ EndpointConfig *EndpointSettings `json:",omitempty"` |
|
| 25 |
+} |
|
| 26 |
+ |
|
| 27 |
+// DisconnectOptions represents the data to be used to disconnect a container |
|
| 28 |
+// from the network. |
|
| 29 |
+type DisconnectOptions struct {
|
|
| 30 |
+ Container string |
|
| 31 |
+ Force bool |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 20 | 34 |
// Address represents an IP address |
| 21 | 35 |
type Address struct {
|
| 22 | 36 |
Addr string |
| ... | ... |
@@ -477,18 +477,6 @@ type NetworkCreateRequest struct {
|
| 477 | 477 |
Name string // Name is the requested name of the network. |
| 478 | 478 |
} |
| 479 | 479 |
|
| 480 |
-// NetworkConnect represents the data to be used to connect a container to the network |
|
| 481 |
-type NetworkConnect struct {
|
|
| 482 |
- Container string |
|
| 483 |
- EndpointConfig *network.EndpointSettings `json:",omitempty"` |
|
| 484 |
-} |
|
| 485 |
- |
|
| 486 |
-// NetworkDisconnect represents the data to be used to disconnect a container from the network |
|
| 487 |
-type NetworkDisconnect struct {
|
|
| 488 |
- Container string |
|
| 489 |
- Force bool |
|
| 490 |
-} |
|
| 491 |
- |
|
| 492 | 480 |
// NetworkInspectOptions holds parameters to inspect network |
| 493 | 481 |
type NetworkInspectOptions struct {
|
| 494 | 482 |
Scope string |
| ... | ... |
@@ -39,3 +39,13 @@ type ImageRemoveOptions = image.RemoveOptions |
| 39 | 39 |
// |
| 40 | 40 |
// Deprecated: use [network.CreateResponse]. |
| 41 | 41 |
type NetworkCreateResponse = network.CreateResponse |
| 42 |
+ |
|
| 43 |
+// NetworkConnect represents the data to be used to connect a container to the network |
|
| 44 |
+// |
|
| 45 |
+// Deprecated: use [network.ConnectOptions]. |
|
| 46 |
+type NetworkConnect = network.ConnectOptions |
|
| 47 |
+ |
|
| 48 |
+// NetworkDisconnect represents the data to be used to disconnect a container from the network |
|
| 49 |
+// |
|
| 50 |
+// Deprecated: use [network.DisconnectOptions]. |
|
| 51 |
+type NetworkDisconnect = network.DisconnectOptions |
| ... | ... |
@@ -3,13 +3,12 @@ package client // import "github.com/docker/docker/client" |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/types" |
|
| 7 | 6 |
"github.com/docker/docker/api/types/network" |
| 8 | 7 |
) |
| 9 | 8 |
|
| 10 | 9 |
// NetworkConnect connects a container to an existent network in the docker host. |
| 11 | 10 |
func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error {
|
| 12 |
- nc := types.NetworkConnect{
|
|
| 11 |
+ nc := network.ConnectOptions{
|
|
| 13 | 12 |
Container: containerID, |
| 14 | 13 |
EndpointConfig: config, |
| 15 | 14 |
} |
| ... | ... |
@@ -10,7 +10,6 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 |
- "github.com/docker/docker/api/types" |
|
| 14 | 13 |
"github.com/docker/docker/api/types/network" |
| 15 | 14 |
"github.com/docker/docker/errdefs" |
| 16 | 15 |
"gotest.tools/v3/assert" |
| ... | ... |
@@ -39,7 +38,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
|
| 39 | 39 |
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
- var connect types.NetworkConnect |
|
| 42 |
+ var connect network.ConnectOptions |
|
| 43 | 43 |
if err := json.NewDecoder(req.Body).Decode(&connect); err != nil {
|
| 44 | 44 |
return nil, err |
| 45 | 45 |
} |
| ... | ... |
@@ -78,7 +77,7 @@ func TestNetworkConnect(t *testing.T) {
|
| 78 | 78 |
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 |
- var connect types.NetworkConnect |
|
| 81 |
+ var connect network.ConnectOptions |
|
| 82 | 82 |
if err := json.NewDecoder(req.Body).Decode(&connect); err != nil {
|
| 83 | 83 |
return nil, err |
| 84 | 84 |
} |
| ... | ... |
@@ -3,12 +3,15 @@ package client // import "github.com/docker/docker/client" |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/types" |
|
| 6 |
+ "github.com/docker/docker/api/types/network" |
|
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
// NetworkDisconnect disconnects a container from an existent network in the docker host. |
| 10 | 10 |
func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error {
|
| 11 |
- nd := types.NetworkDisconnect{Container: containerID, Force: force}
|
|
| 11 |
+ nd := network.DisconnectOptions{
|
|
| 12 |
+ Container: containerID, |
|
| 13 |
+ Force: force, |
|
| 14 |
+ } |
|
| 12 | 15 |
resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) |
| 13 | 16 |
ensureReaderClosed(resp) |
| 14 | 17 |
return err |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"testing" |
| 12 | 12 |
|
| 13 |
- "github.com/docker/docker/api/types" |
|
| 13 |
+ "github.com/docker/docker/api/types/network" |
|
| 14 | 14 |
"github.com/docker/docker/errdefs" |
| 15 | 15 |
"gotest.tools/v3/assert" |
| 16 | 16 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -38,7 +38,7 @@ func TestNetworkDisconnect(t *testing.T) {
|
| 38 | 38 |
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
- var disconnect types.NetworkDisconnect |
|
| 41 |
+ var disconnect network.DisconnectOptions |
|
| 42 | 42 |
if err := json.NewDecoder(req.Body).Decode(&disconnect); err != nil {
|
| 43 | 43 |
return nil, err |
| 44 | 44 |
} |
| ... | ... |
@@ -290,23 +290,21 @@ func createNetwork(c *testing.T, config types.NetworkCreateRequest, expectedStat |
| 290 | 290 |
} |
| 291 | 291 |
|
| 292 | 292 |
func connectNetwork(c *testing.T, nid, cid string) {
|
| 293 |
- config := types.NetworkConnect{
|
|
| 293 |
+ resp, _, err := request.Post(testutil.GetContext(c), "/networks/"+nid+"/connect", request.JSONBody(network.ConnectOptions{
|
|
| 294 | 294 |
Container: cid, |
| 295 |
- } |
|
| 296 |
- |
|
| 297 |
- resp, _, err := request.Post(testutil.GetContext(c), "/networks/"+nid+"/connect", request.JSONBody(config)) |
|
| 298 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 295 |
+ })) |
|
| 299 | 296 |
assert.NilError(c, err) |
| 297 |
+ assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 300 | 298 |
} |
| 301 | 299 |
|
| 302 | 300 |
func disconnectNetwork(c *testing.T, nid, cid string) {
|
| 303 |
- config := types.NetworkConnect{
|
|
| 301 |
+ config := network.ConnectOptions{
|
|
| 304 | 302 |
Container: cid, |
| 305 | 303 |
} |
| 306 | 304 |
|
| 307 | 305 |
resp, _, err := request.Post(testutil.GetContext(c), "/networks/"+nid+"/disconnect", request.JSONBody(config)) |
| 308 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 309 | 306 |
assert.NilError(c, err) |
| 307 |
+ assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 310 | 308 |
} |
| 311 | 309 |
|
| 312 | 310 |
func deleteNetwork(c *testing.T, id string, shouldSucceed bool) {
|