Skip to content

Commit 7e8f630

Browse files
committed
api/types: move SwarmUnlockKeyResponse to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f008d85 commit 7e8f630

7 files changed

Lines changed: 21 additions & 15 deletions

File tree

api/server/router/swarm/cluster_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (sr *swarmRouter) getUnlockKey(ctx context.Context, w http.ResponseWriter,
140140
return err
141141
}
142142

143-
return httputils.WriteJSON(w, http.StatusOK, &basictypes.SwarmUnlockKeyResponse{
143+
return httputils.WriteJSON(w, http.StatusOK, &types.UnlockKeyResponse{
144144
UnlockKey: unlockKey,
145145
})
146146
}

api/types/client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ type PluginInstallOptions struct {
137137
Args []string
138138
}
139139

140-
// SwarmUnlockKeyResponse contains the response for Engine API:
141-
// GET /swarm/unlockkey
142-
type SwarmUnlockKeyResponse struct {
143-
// UnlockKey is the unlock key in ASCII-armored format.
144-
UnlockKey string
145-
}
146-
147140
// PluginCreateOptions hold all options to plugin create.
148141
type PluginCreateOptions struct {
149142
RepoName string

api/types/swarm/swarm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,10 @@ type UpdateFlags struct {
235235
RotateManagerToken bool
236236
RotateManagerUnlockKey bool
237237
}
238+
239+
// UnlockKeyResponse contains the response for Engine API:
240+
// GET /swarm/unlockkey
241+
type UnlockKeyResponse struct {
242+
// UnlockKey is the unlock key in ASCII-armored format.
243+
UnlockKey string
244+
}

api/types/types_deprecated.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ type ServiceListOptions = swarm.ServiceListOptions
159159
// Deprecated: use [swarm.ServiceInspectOptions].
160160
type ServiceInspectOptions = swarm.ServiceInspectOptions
161161

162+
// SwarmUnlockKeyResponse contains the response for Engine API:
163+
// GET /swarm/unlockkey
164+
//
165+
// Deprecated: use [swarm.UnlockKeyResponse].
166+
type SwarmUnlockKeyResponse = swarm.UnlockKeyResponse
167+
162168
// BuildCache contains information about a build cache record.
163169
//
164170
// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead.

client/client_interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ type ServiceAPIClient interface {
191191
type SwarmAPIClient interface {
192192
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
193193
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
194-
SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
194+
SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)
195195
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
196196
SwarmLeave(ctx context.Context, force bool) error
197197
SwarmInspect(ctx context.Context) (swarm.Swarm, error)

client/swarm_get_unlock_key.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import (
44
"context"
55
"encoding/json"
66

7-
"github.com/docker/docker/api/types"
7+
"github.com/docker/docker/api/types/swarm"
88
)
99

1010
// SwarmGetUnlockKey retrieves the swarm's unlock key.
11-
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
11+
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) {
1212
resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil)
1313
defer ensureReaderClosed(resp)
1414
if err != nil {
15-
return types.SwarmUnlockKeyResponse{}, err
15+
return swarm.UnlockKeyResponse{}, err
1616
}
1717

18-
var response types.SwarmUnlockKeyResponse
18+
var response swarm.UnlockKeyResponse
1919
err = json.NewDecoder(resp.Body).Decode(&response)
2020
return response, err
2121
}

client/swarm_get_unlock_key_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/docker/docker/api/types"
13+
"github.com/docker/docker/api/types/swarm"
1414
"github.com/docker/docker/errdefs"
1515
"gotest.tools/v3/assert"
1616
is "gotest.tools/v3/assert/cmp"
@@ -38,7 +38,7 @@ func TestSwarmGetUnlockKey(t *testing.T) {
3838
return nil, fmt.Errorf("expected GET method, got %s", req.Method)
3939
}
4040

41-
key := types.SwarmUnlockKeyResponse{
41+
key := swarm.UnlockKeyResponse{
4242
UnlockKey: unlockKey,
4343
}
4444

0 commit comments

Comments
 (0)