mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/swarm: move UpdateFlags type to client
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -229,13 +229,6 @@ type Peer struct {
|
||||
Addr string
|
||||
}
|
||||
|
||||
// UpdateFlags contains flags for SwarmUpdate.
|
||||
type UpdateFlags struct {
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
}
|
||||
|
||||
// UnlockKeyResponse contains the response for Engine API:
|
||||
// GET /swarm/unlockkey
|
||||
type UnlockKeyResponse struct {
|
||||
|
||||
@@ -181,7 +181,7 @@ type SwarmAPIClient interface {
|
||||
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
||||
SwarmLeave(ctx context.Context, force bool) error
|
||||
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
||||
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error
|
||||
}
|
||||
|
||||
// SystemAPIClient defines API client methods for the system
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// SwarmUpdate updates the swarm.
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error {
|
||||
query := url.Values{}
|
||||
query.Set("version", version.String())
|
||||
query.Set("rotateWorkerToken", strconv.FormatBool(flags.RotateWorkerToken))
|
||||
|
||||
8
client/swarm_update_flags.go
Normal file
8
client/swarm_update_flags.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package client
|
||||
|
||||
// SwarmUpdateFlags contains flags for SwarmUpdate.
|
||||
type SwarmUpdateFlags struct {
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
}
|
||||
@@ -20,7 +20,7 @@ func TestSwarmUpdateError(t *testing.T) {
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
|
||||
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, swarm.UpdateFlags{})
|
||||
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, SwarmUpdateFlags{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
}
|
||||
|
||||
@@ -42,6 +42,6 @@ func TestSwarmUpdate(t *testing.T) {
|
||||
}),
|
||||
}
|
||||
|
||||
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, swarm.UpdateFlags{})
|
||||
err := client.SwarmUpdate(context.Background(), swarm.Version{}, swarm.Spec{}, SwarmUpdateFlags{})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/moby/moby/v2/daemon/internal/stack"
|
||||
"github.com/moby/moby/v2/daemon/pkg/opts"
|
||||
"github.com/moby/moby/v2/daemon/server/backend"
|
||||
"github.com/moby/moby/v2/daemon/server/swarmbackend"
|
||||
"github.com/moby/moby/v2/errdefs"
|
||||
swarmapi "github.com/moby/swarmkit/v2/api"
|
||||
"github.com/moby/swarmkit/v2/manager/encryption"
|
||||
@@ -240,7 +241,7 @@ func (c *Cluster) inspect(ctx context.Context, state nodeState) (types.Swarm, er
|
||||
}
|
||||
|
||||
// Update updates configuration of a managed swarm cluster.
|
||||
func (c *Cluster) Update(version uint64, spec types.Spec, flags types.UpdateFlags) error {
|
||||
func (c *Cluster) Update(version uint64, spec types.Spec, flags swarmbackend.UpdateFlags) error {
|
||||
return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
|
||||
swarm, err := getSwarm(ctx, state.controlClient)
|
||||
if err != nil {
|
||||
|
||||
@@ -15,7 +15,7 @@ type Backend interface {
|
||||
Join(req swarm.JoinRequest) error
|
||||
Leave(ctx context.Context, force bool) error
|
||||
Inspect() (swarm.Swarm, error)
|
||||
Update(uint64, swarm.Spec, swarm.UpdateFlags) error
|
||||
Update(uint64, swarm.Spec, swarmbackend.UpdateFlags) error
|
||||
GetUnlockKey() (string, error)
|
||||
UnlockSwarm(req swarm.UnlockRequest) error
|
||||
GetServices(swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||
|
||||
@@ -82,7 +82,7 @@ func (sr *swarmRouter) updateCluster(ctx context.Context, w http.ResponseWriter,
|
||||
return errdefs.InvalidParameter(err)
|
||||
}
|
||||
|
||||
var flags types.UpdateFlags
|
||||
var flags swarmbackend.UpdateFlags
|
||||
|
||||
if value := r.URL.Query().Get("rotateWorkerToken"); value != "" {
|
||||
rot, err := strconv.ParseBool(value)
|
||||
|
||||
@@ -13,3 +13,9 @@ type NodeListOptions struct {
|
||||
type TaskListOptions struct {
|
||||
Filters filters.Args
|
||||
}
|
||||
|
||||
type UpdateFlags struct {
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/pkg/errors"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
@@ -177,7 +178,7 @@ func (d *Daemon) UpdateSwarm(t testing.TB, f ...SpecConstructor) {
|
||||
fn(&sw.Spec)
|
||||
}
|
||||
|
||||
err := cli.SwarmUpdate(context.Background(), sw.Version, sw.Spec, swarm.UpdateFlags{})
|
||||
err := cli.SwarmUpdate(context.Background(), sw.Version, sw.Spec, client.SwarmUpdateFlags{})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
@@ -190,7 +191,7 @@ func (d *Daemon) RotateTokens(t testing.TB) {
|
||||
sw, err := cli.SwarmInspect(context.Background())
|
||||
assert.NilError(t, err)
|
||||
|
||||
flags := swarm.UpdateFlags{
|
||||
flags := client.SwarmUpdateFlags{
|
||||
RotateManagerToken: true,
|
||||
RotateWorkerToken: true,
|
||||
}
|
||||
|
||||
7
vendor/github.com/moby/moby/api/types/swarm/swarm.go
generated
vendored
7
vendor/github.com/moby/moby/api/types/swarm/swarm.go
generated
vendored
@@ -229,13 +229,6 @@ type Peer struct {
|
||||
Addr string
|
||||
}
|
||||
|
||||
// UpdateFlags contains flags for SwarmUpdate.
|
||||
type UpdateFlags struct {
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
}
|
||||
|
||||
// UnlockKeyResponse contains the response for Engine API:
|
||||
// GET /swarm/unlockkey
|
||||
type UnlockKeyResponse struct {
|
||||
|
||||
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -181,7 +181,7 @@ type SwarmAPIClient interface {
|
||||
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
||||
SwarmLeave(ctx context.Context, force bool) error
|
||||
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
||||
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error
|
||||
}
|
||||
|
||||
// SystemAPIClient defines API client methods for the system
|
||||
|
||||
2
vendor/github.com/moby/moby/client/swarm_update.go
generated
vendored
2
vendor/github.com/moby/moby/client/swarm_update.go
generated
vendored
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
// SwarmUpdate updates the swarm.
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
|
||||
func (cli *Client) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags SwarmUpdateFlags) error {
|
||||
query := url.Values{}
|
||||
query.Set("version", version.String())
|
||||
query.Set("rotateWorkerToken", strconv.FormatBool(flags.RotateWorkerToken))
|
||||
|
||||
8
vendor/github.com/moby/moby/client/swarm_update_flags.go
generated
vendored
Normal file
8
vendor/github.com/moby/moby/client/swarm_update_flags.go
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
package client
|
||||
|
||||
// SwarmUpdateFlags contains flags for SwarmUpdate.
|
||||
type SwarmUpdateFlags struct {
|
||||
RotateWorkerToken bool
|
||||
RotateManagerToken bool
|
||||
RotateManagerUnlockKey bool
|
||||
}
|
||||
Reference in New Issue
Block a user