Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -24,7 +24,7 @@ type Backend interface {
|
| 24 | 24 |
UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error) |
| 25 | 25 |
RemoveService(string) error |
| 26 | 26 |
ServiceLogs(context.Context, *backend.LogSelector, *container.LogsOptions) (<-chan *backend.LogMessage, error) |
| 27 |
- GetNodes(types.NodeListOptions) ([]swarm.Node, error) |
|
| 27 |
+ GetNodes(swarm.NodeListOptions) ([]swarm.Node, error) |
|
| 28 | 28 |
GetNode(string) (swarm.Node, error) |
| 29 | 29 |
UpdateNode(string, uint64, swarm.NodeSpec) error |
| 30 | 30 |
RemoveNode(string, bool) error |
| ... | ... |
@@ -314,7 +314,7 @@ func (sr *swarmRouter) getNodes(ctx context.Context, w http.ResponseWriter, r *h |
| 314 | 314 |
return err |
| 315 | 315 |
} |
| 316 | 316 |
|
| 317 |
- nodes, err := sr.backend.GetNodes(basictypes.NodeListOptions{Filters: filter})
|
|
| 317 |
+ nodes, err := sr.backend.GetNodes(types.NodeListOptions{Filters: filter})
|
|
| 318 | 318 |
if err != nil {
|
| 319 | 319 |
log.G(ctx).WithContext(ctx).WithError(err).Debug("Error getting nodes")
|
| 320 | 320 |
return err |
| ... | ... |
@@ -48,16 +48,6 @@ func (h *HijackedResponse) CloseWrite() error {
|
| 48 | 48 |
return nil |
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 |
-// NodeListOptions holds parameters to list nodes with. |
|
| 52 |
-type NodeListOptions struct {
|
|
| 53 |
- Filters filters.Args |
|
| 54 |
-} |
|
| 55 |
- |
|
| 56 |
-// NodeRemoveOptions holds parameters to remove nodes with. |
|
| 57 |
-type NodeRemoveOptions struct {
|
|
| 58 |
- Force bool |
|
| 59 |
-} |
|
| 60 |
- |
|
| 61 | 51 |
// ServiceCreateOptions contains the options to use when creating a service. |
| 62 | 52 |
type ServiceCreateOptions struct {
|
| 63 | 53 |
// EncodedRegistryAuth is the encoded registry authorization credentials to |
| ... | ... |
@@ -1,4 +1,5 @@ |
| 1 | 1 |
package swarm // import "github.com/docker/docker/api/types/swarm" |
| 2 |
+import "github.com/docker/docker/api/types/filters" |
|
| 2 | 3 |
|
| 3 | 4 |
// Node represents a node. |
| 4 | 5 |
type Node struct {
|
| ... | ... |
@@ -137,3 +138,13 @@ const ( |
| 137 | 137 |
type Topology struct {
|
| 138 | 138 |
Segments map[string]string `json:",omitempty"` |
| 139 | 139 |
} |
| 140 |
+ |
|
| 141 |
+// NodeListOptions holds parameters to list nodes with. |
|
| 142 |
+type NodeListOptions struct {
|
|
| 143 |
+ Filters filters.Args |
|
| 144 |
+} |
|
| 145 |
+ |
|
| 146 |
+// NodeRemoveOptions holds parameters to remove nodes with. |
|
| 147 |
+type NodeRemoveOptions struct {
|
|
| 148 |
+ Force bool |
|
| 149 |
+} |
| ... | ... |
@@ -138,6 +138,16 @@ type ConfigCreateResponse = swarm.ConfigCreateResponse |
| 138 | 138 |
// Deprecated: use [swarm.ConfigListOptions]. |
| 139 | 139 |
type ConfigListOptions = swarm.ConfigListOptions |
| 140 | 140 |
|
| 141 |
+// NodeListOptions holds parameters to list nodes with. |
|
| 142 |
+// |
|
| 143 |
+// Deprecated: use [swarm.NodeListOptions]. |
|
| 144 |
+type NodeListOptions = swarm.NodeListOptions |
|
| 145 |
+ |
|
| 146 |
+// NodeRemoveOptions holds parameters to remove nodes with. |
|
| 147 |
+// |
|
| 148 |
+// Deprecated: use [swarm.NodeRemoveOptions]. |
|
| 149 |
+type NodeRemoveOptions = swarm.NodeRemoveOptions |
|
| 150 |
+ |
|
| 141 | 151 |
// ServiceListOptions holds parameters to list services with. |
| 142 | 152 |
// |
| 143 | 153 |
// Deprecated: use [swarm.ServiceListOptions]. |
| ... | ... |
@@ -155,8 +155,8 @@ type NetworkAPIClient interface {
|
| 155 | 155 |
// NodeAPIClient defines API client methods for the nodes |
| 156 | 156 |
type NodeAPIClient interface {
|
| 157 | 157 |
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) |
| 158 |
- NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) |
|
| 159 |
- NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error |
|
| 158 |
+ NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) |
|
| 159 |
+ NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error |
|
| 160 | 160 |
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error |
| 161 | 161 |
} |
| 162 | 162 |
|
| ... | ... |
@@ -5,13 +5,12 @@ import ( |
| 5 | 5 |
"encoding/json" |
| 6 | 6 |
"net/url" |
| 7 | 7 |
|
| 8 |
- "github.com/docker/docker/api/types" |
|
| 9 | 8 |
"github.com/docker/docker/api/types/filters" |
| 10 | 9 |
"github.com/docker/docker/api/types/swarm" |
| 11 | 10 |
) |
| 12 | 11 |
|
| 13 | 12 |
// NodeList returns the list of nodes. |
| 14 |
-func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
|
| 13 |
+func (cli *Client) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
|
| 15 | 14 |
query := url.Values{}
|
| 16 | 15 |
|
| 17 | 16 |
if options.Filters.Len() > 0 {
|
| ... | ... |
@@ -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/filters" |
| 15 | 14 |
"github.com/docker/docker/api/types/swarm" |
| 16 | 15 |
"github.com/docker/docker/errdefs" |
| ... | ... |
@@ -23,7 +22,7 @@ func TestNodeListError(t *testing.T) {
|
| 23 | 23 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
- _, err := client.NodeList(context.Background(), types.NodeListOptions{})
|
|
| 26 |
+ _, err := client.NodeList(context.Background(), swarm.NodeListOptions{})
|
|
| 27 | 27 |
assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) |
| 28 | 28 |
} |
| 29 | 29 |
|
| ... | ... |
@@ -31,17 +30,17 @@ func TestNodeList(t *testing.T) {
|
| 31 | 31 |
const expectedURL = "/nodes" |
| 32 | 32 |
|
| 33 | 33 |
listCases := []struct {
|
| 34 |
- options types.NodeListOptions |
|
| 34 |
+ options swarm.NodeListOptions |
|
| 35 | 35 |
expectedQueryParams map[string]string |
| 36 | 36 |
}{
|
| 37 | 37 |
{
|
| 38 |
- options: types.NodeListOptions{},
|
|
| 38 |
+ options: swarm.NodeListOptions{},
|
|
| 39 | 39 |
expectedQueryParams: map[string]string{
|
| 40 | 40 |
"filters": "", |
| 41 | 41 |
}, |
| 42 | 42 |
}, |
| 43 | 43 |
{
|
| 44 |
- options: types.NodeListOptions{
|
|
| 44 |
+ options: swarm.NodeListOptions{
|
|
| 45 | 45 |
Filters: filters.NewArgs( |
| 46 | 46 |
filters.Arg("label", "label1"),
|
| 47 | 47 |
filters.Arg("label", "label2"),
|
| ... | ... |
@@ -4,11 +4,11 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"net/url" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/types" |
|
| 7 |
+ "github.com/docker/docker/api/types/swarm" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
// NodeRemove removes a Node. |
| 11 |
-func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
|
|
| 11 |
+func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error {
|
|
| 12 | 12 |
nodeID, err := trimID("node", nodeID)
|
| 13 | 13 |
if err != nil {
|
| 14 | 14 |
return err |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
"strings" |
| 10 | 10 |
"testing" |
| 11 | 11 |
|
| 12 |
- "github.com/docker/docker/api/types" |
|
| 12 |
+ "github.com/docker/docker/api/types/swarm" |
|
| 13 | 13 |
"github.com/docker/docker/errdefs" |
| 14 | 14 |
"gotest.tools/v3/assert" |
| 15 | 15 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -20,14 +20,14 @@ func TestNodeRemoveError(t *testing.T) {
|
| 20 | 20 |
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
- err := client.NodeRemove(context.Background(), "node_id", types.NodeRemoveOptions{Force: false})
|
|
| 23 |
+ err := client.NodeRemove(context.Background(), "node_id", swarm.NodeRemoveOptions{Force: false})
|
|
| 24 | 24 |
assert.Check(t, is.ErrorType(err, errdefs.IsSystem)) |
| 25 | 25 |
|
| 26 |
- err = client.NodeRemove(context.Background(), "", types.NodeRemoveOptions{Force: false})
|
|
| 26 |
+ err = client.NodeRemove(context.Background(), "", swarm.NodeRemoveOptions{Force: false})
|
|
| 27 | 27 |
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) |
| 28 | 28 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 29 | 29 |
|
| 30 |
- err = client.NodeRemove(context.Background(), " ", types.NodeRemoveOptions{Force: false})
|
|
| 30 |
+ err = client.NodeRemove(context.Background(), " ", swarm.NodeRemoveOptions{Force: false})
|
|
| 31 | 31 |
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter)) |
| 32 | 32 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 33 | 33 |
} |
| ... | ... |
@@ -69,7 +69,7 @@ func TestNodeRemove(t *testing.T) {
|
| 69 | 69 |
}), |
| 70 | 70 |
} |
| 71 | 71 |
|
| 72 |
- err := client.NodeRemove(context.Background(), "node_id", types.NodeRemoveOptions{Force: removeCase.force})
|
|
| 72 |
+ err := client.NodeRemove(context.Background(), "node_id", swarm.NodeRemoveOptions{Force: removeCase.force})
|
|
| 73 | 73 |
assert.NilError(t, err) |
| 74 | 74 |
} |
| 75 | 75 |
} |
| ... | ... |
@@ -3,7 +3,6 @@ package cluster // import "github.com/docker/docker/daemon/cluster" |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
- apitypes "github.com/docker/docker/api/types" |
|
| 7 | 6 |
types "github.com/docker/docker/api/types/swarm" |
| 8 | 7 |
"github.com/docker/docker/daemon/cluster/convert" |
| 9 | 8 |
"github.com/docker/docker/errdefs" |
| ... | ... |
@@ -12,7 +11,7 @@ import ( |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 | 14 |
// GetNodes returns a list of all nodes known to a cluster. |
| 15 |
-func (c *Cluster) GetNodes(options apitypes.NodeListOptions) ([]types.Node, error) {
|
|
| 15 |
+func (c *Cluster) GetNodes(options types.NodeListOptions) ([]types.Node, error) {
|
|
| 16 | 16 |
c.mu.RLock() |
| 17 | 17 |
defer c.mu.RUnlock() |
| 18 | 18 |
|
| ... | ... |
@@ -178,7 +178,7 @@ func (d *Daemon) CheckLeader(ctx context.Context) func(t *testing.T) (interface{
|
| 178 | 178 |
|
| 179 | 179 |
errList := "could not get node list" |
| 180 | 180 |
|
| 181 |
- ls, err := cli.NodeList(ctx, types.NodeListOptions{})
|
|
| 181 |
+ ls, err := cli.NodeList(ctx, swarm.NodeListOptions{})
|
|
| 182 | 182 |
if err != nil {
|
| 183 | 183 |
return err, errList |
| 184 | 184 |
} |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"testing" |
| 7 | 7 |
"time" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/types" |
|
| 10 | 9 |
"github.com/docker/docker/api/types/swarm" |
| 11 | 10 |
"gotest.tools/v3/assert" |
| 12 | 11 |
) |
| ... | ... |
@@ -39,7 +38,7 @@ func (d *Daemon) RemoveNode(ctx context.Context, t testing.TB, id string, force |
| 39 | 39 |
cli := d.NewClientT(t) |
| 40 | 40 |
defer cli.Close() |
| 41 | 41 |
|
| 42 |
- options := types.NodeRemoveOptions{
|
|
| 42 |
+ options := swarm.NodeRemoveOptions{
|
|
| 43 | 43 |
Force: force, |
| 44 | 44 |
} |
| 45 | 45 |
err := cli.NodeRemove(ctx, id, options) |
| ... | ... |
@@ -74,7 +73,7 @@ func (d *Daemon) ListNodes(ctx context.Context, t testing.TB) []swarm.Node {
|
| 74 | 74 |
cli := d.NewClientT(t) |
| 75 | 75 |
defer cli.Close() |
| 76 | 76 |
|
| 77 |
- nodes, err := cli.NodeList(ctx, types.NodeListOptions{})
|
|
| 77 |
+ nodes, err := cli.NodeList(ctx, swarm.NodeListOptions{})
|
|
| 78 | 78 |
assert.NilError(t, err) |
| 79 | 79 |
|
| 80 | 80 |
return nodes |