2016-12-25 16:23:35 -05:00
|
|
|
package swarm
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
|
|
|
|
2016-12-25 16:23:35 -05:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2023-07-14 17:42:40 -04:00
|
|
|
"github.com/docker/docker/api/types/system"
|
2017-05-08 13:51:30 -04:00
|
|
|
"github.com/docker/docker/client"
|
2016-12-25 16:23:35 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type fakeClient struct {
|
|
|
|
client.Client
|
2023-07-14 17:42:40 -04:00
|
|
|
infoFunc func() (system.Info, error)
|
2016-12-25 16:23:35 -05:00
|
|
|
swarmInitFunc func() (string, error)
|
|
|
|
swarmInspectFunc func() (swarm.Swarm, error)
|
|
|
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
|
|
|
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
|
|
|
swarmJoinFunc func() error
|
|
|
|
swarmLeaveFunc func() error
|
|
|
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
|
|
|
swarmUnlockFunc func(req swarm.UnlockRequest) error
|
|
|
|
}
|
|
|
|
|
2023-07-14 17:42:40 -04:00
|
|
|
func (cli *fakeClient) Info(context.Context) (system.Info, error) {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.infoFunc != nil {
|
|
|
|
return cli.infoFunc()
|
|
|
|
}
|
2023-07-14 17:42:40 -04:00
|
|
|
return system.Info{}, nil
|
2016-12-25 16:23:35 -05:00
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.nodeInspectFunc != nil {
|
|
|
|
return cli.nodeInspectFunc()
|
|
|
|
}
|
|
|
|
return swarm.Node{}, []byte{}, nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmInit(context.Context, swarm.InitRequest) (string, error) {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmInitFunc != nil {
|
|
|
|
return cli.swarmInitFunc()
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmInspect(context.Context) (swarm.Swarm, error) {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmInspectFunc != nil {
|
|
|
|
return cli.swarmInspectFunc()
|
|
|
|
}
|
|
|
|
return swarm.Swarm{}, nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmGetUnlockKey(context.Context) (types.SwarmUnlockKeyResponse, error) {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmGetUnlockKeyFunc != nil {
|
|
|
|
return cli.swarmGetUnlockKeyFunc()
|
|
|
|
}
|
|
|
|
return types.SwarmUnlockKeyResponse{}, nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmJoin(context.Context, swarm.JoinRequest) error {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmJoinFunc != nil {
|
|
|
|
return cli.swarmJoinFunc()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmLeave(context.Context, bool) error {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmLeaveFunc != nil {
|
|
|
|
return cli.swarmLeaveFunc()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-11-20 11:38:50 -05:00
|
|
|
func (cli *fakeClient) SwarmUpdate(_ context.Context, _ swarm.Version, swarmSpec swarm.Spec, flags swarm.UpdateFlags) error {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmUpdateFunc != nil {
|
2023-11-20 11:38:50 -05:00
|
|
|
return cli.swarmUpdateFunc(swarmSpec, flags)
|
2016-12-25 16:23:35 -05:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
cli/command/swarm: fakeClient: remove name for unused arg (revive)
cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive)
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet {
^
cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) {
^
cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
^
cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) {
^
cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) {
^
cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
^
cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error {
^
cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error {
^
cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
^
cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error {
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-03-30 10:38:10 -04:00
|
|
|
func (cli *fakeClient) SwarmUnlock(_ context.Context, req swarm.UnlockRequest) error {
|
2016-12-25 16:23:35 -05:00
|
|
|
if cli.swarmUnlockFunc != nil {
|
|
|
|
return cli.swarmUnlockFunc(req)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|