diff --git a/cmd/scw/testdata/test-all-usage-fip-mac-move-usage.golden b/cmd/scw/testdata/test-all-usage-fip-mac-move-usage.golden new file mode 100644 index 0000000000..cec10797da --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-fip-mac-move-usage.golden @@ -0,0 +1,20 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Move a Virtual MAC from a given Flexible IP onto another Flexible IP. + +USAGE: + scw fip mac move [arg=value ...] + +ARGS: + fip-id + [dst-fip-id] + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | nl-ams-1) + +FLAGS: + -h, --help help for move + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-fip-mac-usage.golden b/cmd/scw/testdata/test-all-usage-fip-mac-usage.golden index 6d45355733..5e20df6bc5 100644 --- a/cmd/scw/testdata/test-all-usage-fip-mac-usage.golden +++ b/cmd/scw/testdata/test-all-usage-fip-mac-usage.golden @@ -9,6 +9,7 @@ AVAILABLE COMMANDS: create Generate a virtual MAC on a given Flexible IP delete Remove a virtual MAC from a Flexible IP duplicate Duplicate a Virtual MAC + move Move a virtual MAC FLAGS: -h, --help help for mac diff --git a/docs/commands/fip.md b/docs/commands/fip.md index 4dd7567ef5..112786bc6f 100644 --- a/docs/commands/fip.md +++ b/docs/commands/fip.md @@ -14,6 +14,7 @@ Flexible IP API. - [Generate a virtual MAC on a given Flexible IP](#generate-a-virtual-mac-on-a-given-flexible-ip) - [Remove a virtual MAC from a Flexible IP](#remove-a-virtual-mac-from-a-flexible-ip) - [Duplicate a Virtual MAC](#duplicate-a-virtual-mac) + - [Move a virtual MAC](#move-a-virtual-mac) ## Flexible IP management commands @@ -244,3 +245,24 @@ scw fip mac duplicate [arg=value ...] +### Move a virtual MAC + +Move a Virtual MAC from a given Flexible IP onto another Flexible IP. + +**Usage:** + +``` +scw fip mac move [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| fip-id | Required | | +| dst-fip-id | | | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config | + + + diff --git a/go.mod b/go.mod index daf68728b0..d8be6c9060 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/moby/buildkit v0.11.4 github.com/opencontainers/go-digest v1.0.0 github.com/pkg/errors v0.9.1 - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11 + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 804bb8495c..6e7b8faa97 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11 h1:tZBnGI0NIyTUV9+UYQrTFw1gqIcY/TcUBCfLrC/IvKY= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322094918-cd420ebc2d11/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689 h1:QPpApIAOwB3/9ZPu+SOu5bjoN7keDalTCpyCf2VYx4w= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230322175238-aa881483e689/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= diff --git a/internal/namespaces/flexibleip/v1alpha1/flexibleip_cli.go b/internal/namespaces/flexibleip/v1alpha1/flexibleip_cli.go index c08b8e058d..d581b15a80 100644 --- a/internal/namespaces/flexibleip/v1alpha1/flexibleip_cli.go +++ b/internal/namespaces/flexibleip/v1alpha1/flexibleip_cli.go @@ -31,6 +31,7 @@ func GetGeneratedCommands() *core.Commands { fipIPDetach(), fipMacCreate(), fipMacDuplicate(), + fipMacMove(), fipMacDelete(), ) } @@ -491,6 +492,41 @@ func fipMacDuplicate() *core.Command { } } +func fipMacMove() *core.Command { + return &core.Command{ + Short: `Move a virtual MAC`, + Long: `Move a Virtual MAC from a given Flexible IP onto another Flexible IP.`, + Namespace: "fip", + Resource: "mac", + Verb: "move", + // Deprecated: false, + ArgsType: reflect.TypeOf(flexibleip.MoveMACAddrRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "fip-id", + Required: true, + Deprecated: false, + Positional: false, + }, + { + Name: "dst-fip-id", + Required: false, + Deprecated: false, + Positional: false, + }, + core.ZoneArgSpec(scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*flexibleip.MoveMACAddrRequest) + + client := core.ExtractClient(ctx) + api := flexibleip.NewAPI(client) + return api.MoveMACAddr(request) + + }, + } +} + func fipMacDelete() *core.Command { return &core.Command{ Short: `Remove a virtual MAC from a Flexible IP`, diff --git a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden index d62f81b84a..407096e02b 100644 --- a/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden +++ b/internal/namespaces/k8s/v1/testdata/test-get-cluster-simple.golden @@ -96,6 +96,7 @@ ID NAME STATUS VERSION NODE TYPE MIN "required_claim": [] }, "apiserver_cert_sans": [], + "private_network_id": null, "pools": [ { "id": "42b228cf-ad4b-458e-b69b-046f8aa3c10c", diff --git a/internal/namespaces/k8s/v1/testdata/test-wait-cluster-wait-for-pools.golden b/internal/namespaces/k8s/v1/testdata/test-wait-cluster-wait-for-pools.golden index 81b6f4b2f1..26ecdc4871 100644 --- a/internal/namespaces/k8s/v1/testdata/test-wait-cluster-wait-for-pools.golden +++ b/internal/namespaces/k8s/v1/testdata/test-wait-cluster-wait-for-pools.golden @@ -91,5 +91,6 @@ GroupsPrefix - "groups_prefix": "", "required_claim": [] }, - "apiserver_cert_sans": [] + "apiserver_cert_sans": [], + "private_network_id": null }