diff --git a/api/server/router/swarm/cluster_routes.go b/api/server/router/swarm/cluster_routes.go index 6f77f99adc..c714ff184d 100644 --- a/api/server/router/swarm/cluster_routes.go +++ b/api/server/router/swarm/cluster_routes.go @@ -140,7 +140,7 @@ func (sr *swarmRouter) getUnlockKey(ctx context.Context, w http.ResponseWriter, return err } - return httputils.WriteJSON(w, http.StatusOK, &basictypes.SwarmUnlockKeyResponse{ + return httputils.WriteJSON(w, http.StatusOK, &types.UnlockKeyResponse{ UnlockKey: unlockKey, }) } diff --git a/api/types/client.go b/api/types/client.go index 4ab6ac687f..406b316046 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -137,13 +137,6 @@ type PluginInstallOptions struct { Args []string } -// SwarmUnlockKeyResponse contains the response for Engine API: -// GET /swarm/unlockkey -type SwarmUnlockKeyResponse struct { - // UnlockKey is the unlock key in ASCII-armored format. - UnlockKey string -} - // PluginCreateOptions hold all options to plugin create. type PluginCreateOptions struct { RepoName string diff --git a/api/types/swarm/swarm.go b/api/types/swarm/swarm.go index 1b4be6fffb..2711c9eac5 100644 --- a/api/types/swarm/swarm.go +++ b/api/types/swarm/swarm.go @@ -235,3 +235,10 @@ type UpdateFlags struct { RotateManagerToken bool RotateManagerUnlockKey bool } + +// UnlockKeyResponse contains the response for Engine API: +// GET /swarm/unlockkey +type UnlockKeyResponse struct { + // UnlockKey is the unlock key in ASCII-armored format. + UnlockKey string +} diff --git a/api/types/types_deprecated.go b/api/types/types_deprecated.go index c57c4fd3ba..cf3aed11a8 100644 --- a/api/types/types_deprecated.go +++ b/api/types/types_deprecated.go @@ -159,6 +159,12 @@ type ServiceListOptions = swarm.ServiceListOptions // Deprecated: use [swarm.ServiceInspectOptions]. type ServiceInspectOptions = swarm.ServiceInspectOptions +// SwarmUnlockKeyResponse contains the response for Engine API: +// GET /swarm/unlockkey +// +// Deprecated: use [swarm.UnlockKeyResponse]. +type SwarmUnlockKeyResponse = swarm.UnlockKeyResponse + // BuildCache contains information about a build cache record. // // Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead. diff --git a/client/client_interfaces.go b/client/client_interfaces.go index 5668459832..07929ae5a1 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -191,7 +191,7 @@ type ServiceAPIClient interface { type SwarmAPIClient interface { SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error - SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) + SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error SwarmLeave(ctx context.Context, force bool) error SwarmInspect(ctx context.Context) (swarm.Swarm, error) diff --git a/client/swarm_get_unlock_key.go b/client/swarm_get_unlock_key.go index 271fc08c95..6e30daf615 100644 --- a/client/swarm_get_unlock_key.go +++ b/client/swarm_get_unlock_key.go @@ -4,18 +4,18 @@ import ( "context" "encoding/json" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/swarm" ) // SwarmGetUnlockKey retrieves the swarm's unlock key. -func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) { +func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) { resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil) defer ensureReaderClosed(resp) if err != nil { - return types.SwarmUnlockKeyResponse{}, err + return swarm.UnlockKeyResponse{}, err } - var response types.SwarmUnlockKeyResponse + var response swarm.UnlockKeyResponse err = json.NewDecoder(resp.Body).Decode(&response) return response, err } diff --git a/client/swarm_get_unlock_key_test.go b/client/swarm_get_unlock_key_test.go index fb94cdaeaf..1bb4c5d39a 100644 --- a/client/swarm_get_unlock_key_test.go +++ b/client/swarm_get_unlock_key_test.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/errdefs" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -38,7 +38,7 @@ func TestSwarmGetUnlockKey(t *testing.T) { return nil, fmt.Errorf("expected GET method, got %s", req.Method) } - key := types.SwarmUnlockKeyResponse{ + key := swarm.UnlockKeyResponse{ UnlockKey: unlockKey, }