diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 35dc689e83..429353c383 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,7 @@ jobs: uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: latest + version: v2.9.0 args: --timeout 10m spelling: diff --git a/Dockerfile b/Dockerfile index ddbb3b71c5..5f101618b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.25-alpine3.21 AS builder +FROM golang:1.26-alpine3.23 AS builder ENV BUILD_IN_DOCKER=true ARG VERSION diff --git a/core/human/marshal.go b/core/human/marshal.go index d452d07b19..d0824a0f49 100644 --- a/core/human/marshal.go +++ b/core/human/marshal.go @@ -461,8 +461,7 @@ func computeMaxCols(grid [][]string) int { func getDefaultFieldsOpt(t reflect.Type) []*MarshalFieldOpt { results := []*MarshalFieldOpt(nil) // Loop through all struct field - for fieldIdx := range t.NumField() { - field := t.Field(fieldIdx) + for field := range t.Fields() { fieldType := field.Type if field.Anonymous { diff --git a/core/reflect.go b/core/reflect.go index 218801382a..ac98e88b5b 100644 --- a/core/reflect.go +++ b/core/reflect.go @@ -15,23 +15,21 @@ import ( // becomes struct{FieldName string `json:"field_name"`} func newObjectWithForcedJSONTags(t reflect.Type) any { structFieldsCopy := []reflect.StructField(nil) - for i := range t.NumField() { - fieldCopy := t.Field(i) + for fieldCopy := range t.Fields() { if fieldCopy.Anonymous { anonymousType := fieldCopy.Type if anonymousType.Kind() == reflect.Ptr { anonymousType = anonymousType.Elem() } - for i := range anonymousType.NumField() { - fieldCopy := anonymousType.Field(i) - fieldCopy.Tag = reflect.StructTag( + for field := range anonymousType.Fields() { + field.Tag = reflect.StructTag( `json:"` + strings.ReplaceAll( - strcase.ToBashArg(fieldCopy.Name), + strcase.ToBashArg(field.Name), "-", "_", ) + `"`, ) - structFieldsCopy = append(structFieldsCopy, fieldCopy) + structFieldsCopy = append(structFieldsCopy, field) } } else { fieldCopy.Tag = reflect.StructTag( diff --git a/core/testing.go b/core/testing.go index 0e24906726..90e57248a1 100644 --- a/core/testing.go +++ b/core/testing.go @@ -343,7 +343,7 @@ func Test(config *TestConfig) func(t *testing.T) { } // We need to set up this variable to ensure that relative date parsing stay consistent - args.TestForceNow = scw.TimePtr(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)) + args.TestForceNow = new(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)) // Because human marshal of date is relative (e.g 3 minutes ago) we must make sure it stay consistent for golden to works. // Here we return a constant string. We may need to find a better place to put this. diff --git a/go.mod b/go.mod index fe417bd6e7..5cc9cd2ac2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/scaleway/scaleway-cli/v2 -go 1.25.5 +go 1.26.0 require ( github.com/aws/aws-sdk-go-v2 v1.41.1 diff --git a/internal/args/args.go b/internal/args/args.go index df48fdb841..4756f3e6f7 100644 --- a/internal/args/args.go +++ b/internal/args/args.go @@ -297,8 +297,7 @@ func listArgTypeFields(base string, argType reflect.Type) []string { case reflect.Struct: fields := []string(nil) - for i := range argType.NumField() { - field := argType.Field(i) + for field := range argType.Fields() { fieldBase := base // If this is an embedded struct, skip adding its name to base diff --git a/internal/args/unmarshal_test.go b/internal/args/unmarshal_test.go index f69acb8ec3..ee3cb84808 100644 --- a/internal/args/unmarshal_test.go +++ b/internal/args/unmarshal_test.go @@ -13,7 +13,7 @@ import ( ) func init() { - args.TestForceNow = scw.TimePtr(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)) + args.TestForceNow = new(time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)) } func TestUnmarshalStruct(t *testing.T) { @@ -205,7 +205,7 @@ func TestUnmarshalStruct(t *testing.T) { }, expected: &Slice{ Strings: []string(nil), - SlicePtr: scw.StringsPtr([]string{}), + SlicePtr: new([]string{}), StringsPtr: []*string(nil), }, })) diff --git a/internal/editor/reflect_test.go b/internal/editor/reflect_test.go index f44ffba8d1..55f99cc380 100644 --- a/internal/editor/reflect_test.go +++ b/internal/editor/reflect_test.go @@ -78,7 +78,7 @@ func Test_valueMapperPointersWithPointers(t *testing.T) { src := struct { Arg1 *string Arg2 *int32 - }{scw.StringPtr("1"), scw.Int32Ptr(1)} + }{new("1"), scw.Int32Ptr(1)} dest := struct { Arg1 *string Arg2 *int32 diff --git a/internal/gofields/gofields.go b/internal/gofields/gofields.go index ccdff74e5a..456e81a3bf 100644 --- a/internal/gofields/gofields.go +++ b/internal/gofields/gofields.go @@ -178,9 +178,7 @@ func listFields(t reflect.Type, parents []string, filter ListFieldFilter) []stri return listFields(t.Elem(), append(parents, ""), filter) case reflect.Struct: res := []string(nil) - for i := range t.NumField() { - field := t.Field(i) - + for field := range t.Fields() { if !isFieldPublic(field) { continue } diff --git a/internal/namespaces/applesilicon/v1alpha1/custom_server.go b/internal/namespaces/applesilicon/v1alpha1/custom_server.go index 4a01925ad0..1ee06e8fb0 100644 --- a/internal/namespaces/applesilicon/v1alpha1/custom_server.go +++ b/internal/namespaces/applesilicon/v1alpha1/custom_server.go @@ -74,7 +74,7 @@ func waitForServerFunc(action int) core.WaitFunc { WaitForServer(&applesilicon.WaitForServerRequest{ Zone: respI.(*applesilicon.Server).Zone, ServerID: respI.(*applesilicon.Server).ID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) diff --git a/internal/namespaces/baremetal/v1/custom_server.go b/internal/namespaces/baremetal/v1/custom_server.go index 0a3bfb9924..62e64c8afe 100644 --- a/internal/namespaces/baremetal/v1/custom_server.go +++ b/internal/namespaces/baremetal/v1/custom_server.go @@ -57,7 +57,7 @@ func serverWaitCommand() *core.Command { server, err := api.WaitForServer(&baremetal.WaitForServerRequest{ ServerID: args.ServerID, Zone: args.Zone, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -79,7 +79,7 @@ func serverWaitCommand() *core.Command { server, err = api.WaitForServerInstall(&baremetal.WaitForServerInstallRequest{ ServerID: args.ServerID, Zone: args.Zone, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -125,7 +125,7 @@ func serverStartBuilder(c *core.Command) *core.Command { return api.WaitForServer(&baremetal.WaitForServerRequest{ Zone: argsI.(*baremetal.StartServerRequest).Zone, ServerID: respI.(*baremetal.Server).ID, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -141,7 +141,7 @@ func serverStopBuilder(c *core.Command) *core.Command { return api.WaitForServer(&baremetal.WaitForServerRequest{ Zone: argsI.(*baremetal.StopServerRequest).Zone, ServerID: respI.(*baremetal.Server).ID, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -159,7 +159,7 @@ func serverRebootBuilder(c *core.Command) *core.Command { return api.WaitForServer(&baremetal.WaitForServerRequest{ Zone: argsI.(*baremetal.RebootServerRequest).Zone, ServerID: respI.(*baremetal.Server).ID, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/baremetal/v1/custom_server_create.go b/internal/namespaces/baremetal/v1/custom_server_create.go index b75e68548e..19574fa9ad 100644 --- a/internal/namespaces/baremetal/v1/custom_server_create.go +++ b/internal/namespaces/baremetal/v1/custom_server_create.go @@ -101,7 +101,7 @@ func serverCreateBuilder(c *core.Command) *core.Command { return api.WaitForServer(&baremetal.WaitForServerRequest{ Zone: argsI.(*baremetalCreateServerRequestCustom).Zone, ServerID: respI.(*baremetal.Server).ID, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/baremetal/v1/custom_server_delete.go b/internal/namespaces/baremetal/v1/custom_server_delete.go index cefd0e4eb7..94fe3c1796 100644 --- a/internal/namespaces/baremetal/v1/custom_server_delete.go +++ b/internal/namespaces/baremetal/v1/custom_server_delete.go @@ -16,7 +16,7 @@ func serverDeleteBuilder(c *core.Command) *core.Command { WaitForServer(&baremetal.WaitForServerRequest{ ServerID: argsI.(*baremetal.DeleteServerRequest).ServerID, Zone: argsI.(*baremetal.DeleteServerRequest).Zone, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/baremetal/v1/custom_server_install.go b/internal/namespaces/baremetal/v1/custom_server_install.go index 6c22f743fd..84b14e1305 100644 --- a/internal/namespaces/baremetal/v1/custom_server_install.go +++ b/internal/namespaces/baremetal/v1/custom_server_install.go @@ -57,7 +57,7 @@ func serverInstallBuilder(c *core.Command) *core.Command { return api.WaitForServerInstall(&baremetal.WaitForServerInstallRequest{ Zone: argsI.(*baremetalInstallServerRequestCustom).Zone, ServerID: respI.(*baremetal.Server).ID, - Timeout: scw.TimeDurationPtr(ServerActionTimeout), + Timeout: new(ServerActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot.go b/internal/namespaces/block/v1alpha1/custom_snapshot.go index dbf6ea3967..8daddc27ed 100644 --- a/internal/namespaces/block/v1alpha1/custom_snapshot.go +++ b/internal/namespaces/block/v1alpha1/custom_snapshot.go @@ -45,7 +45,7 @@ func snapshotWaitCommand() *core.Command { WaitForSnapshot(&block.WaitForSnapshotRequest{ Zone: args.Zone, SnapshotID: args.SnapshotID, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, TerminalStatus: args.TerminalStatus, diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index ebef628fd3..11705e9d87 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -44,7 +44,7 @@ func volumeWaitCommand() *core.Command { return block.NewAPI(core.ExtractClient(ctx)).WaitForVolume(&block.WaitForVolumeRequest{ Zone: args.Zone, VolumeID: args.VolumeID, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, TerminalStatus: args.TerminalStatus, diff --git a/internal/namespaces/config/commands.go b/internal/namespaces/config/commands.go index a056990fe5..3dec727ae9 100644 --- a/internal/namespaces/config/commands.go +++ b/internal/namespaces/config/commands.go @@ -887,13 +887,12 @@ func getProfileField(profile *scw.Profile, key string) (reflect.Value, error) { func getProfileKeys() []string { t := reflect.TypeOf(scw.Profile{}) keys := []string{} - for i := range t.NumField() { - field := t.Field(i) + for field := range t.Fields() { switch field.Name { case "APIURL": keys = append(keys, "api-url") default: - keys = append(keys, strcase.ToBashArg(t.Field(i).Name)) + keys = append(keys, strcase.ToBashArg(field.Name)) } } diff --git a/internal/namespaces/config/commands_test.go b/internal/namespaces/config/commands_test.go index 2547449e6b..f5f6d5780f 100644 --- a/internal/namespaces/config/commands_test.go +++ b/internal/namespaces/config/commands_test.go @@ -417,35 +417,35 @@ func beforeFuncCreateConfigFile(c *scw.Config) core.BeforeFunc { func beforeFuncCreateFullConfig() core.BeforeFunc { return beforeFuncCreateConfigFile(&scw.Config{ Profile: scw.Profile{ - AccessKey: scw.StringPtr("SCWXXXXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - APIURL: scw.StringPtr("https://mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWXXXXXXXXXXXXXXXXX"), + SecretKey: new("11111111-1111-1111-1111-111111111111"), + APIURL: new("https://mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("11111111-1111-1111-1111-111111111111"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, Profiles: map[string]*scw.Profile{ "p1": { - AccessKey: scw.StringPtr("SCWP1XXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - APIURL: scw.StringPtr("https://p1-mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWP1XXXXXXXXXXXXXXX"), + SecretKey: new("11111111-1111-1111-1111-111111111111"), + APIURL: new("https://p1-mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("11111111-1111-1111-1111-111111111111"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, "p2": { - AccessKey: scw.StringPtr("SCWP2XXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - APIURL: scw.StringPtr("https://p2-mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWP2XXXXXXXXXXXXXXX"), + SecretKey: new("11111111-1111-1111-1111-111111111111"), + APIURL: new("https://p2-mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("11111111-1111-1111-1111-111111111111"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, }, }) @@ -454,25 +454,25 @@ func beforeFuncCreateFullConfig() core.BeforeFunc { func beforeFuncCreateInvalidConfig() core.BeforeFunc { return beforeFuncCreateConfigFile(&scw.Config{ Profile: scw.Profile{ - AccessKey: scw.StringPtr("invalidAccessKey"), - SecretKey: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - APIURL: scw.StringPtr("https://mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("invalidAccessKey"), + SecretKey: new("11111111-1111-1111-1111-111111111111"), + APIURL: new("https://mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("11111111-1111-1111-1111-111111111111"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, Profiles: map[string]*scw.Profile{ "p1": { - AccessKey: scw.StringPtr("SCWP1XXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr("invalidSecretKey"), - APIURL: scw.StringPtr("https://p1-mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("11111111-1111-1111-1111-111111111111"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWP1XXXXXXXXXXXXXXX"), + SecretKey: new("invalidSecretKey"), + APIURL: new("https://p1-mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("11111111-1111-1111-1111-111111111111"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, }, }) diff --git a/internal/namespaces/container/v1beta1/custom_container.go b/internal/namespaces/container/v1beta1/custom_container.go index a230f77298..4cab9543a6 100644 --- a/internal/namespaces/container/v1beta1/custom_container.go +++ b/internal/namespaces/container/v1beta1/custom_container.go @@ -36,7 +36,7 @@ func waitForContainer(ctx context.Context, _, respI any) (any, error) { return api.WaitForContainer(&container.WaitForContainerRequest{ ContainerID: c.ID, Region: c.Region, - Timeout: scw.TimeDurationPtr(containerDeployTimeout), + Timeout: new(containerDeployTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/container/v1beta1/custom_deploy.go b/internal/namespaces/container/v1beta1/custom_deploy.go index 20b3ca4ae5..82df11bcce 100644 --- a/internal/namespaces/container/v1beta1/custom_deploy.go +++ b/internal/namespaces/container/v1beta1/custom_deploy.go @@ -476,8 +476,8 @@ func DeployStepCreateContainer( Region: data.Args.Region, ContainerID: targetContainer.ID, RegistryImage: &data.Tag, - Port: scw.Uint32Ptr(data.Args.Port), - Redeploy: scw.BoolPtr(false), + Port: new(data.Args.Port), + Redeploy: new(false), }, scw.WithContext(t.Ctx)) if err != nil { return nil, fmt.Errorf("could not update container: %w", err) diff --git a/internal/namespaces/container/v1beta1/custom_namespace.go b/internal/namespaces/container/v1beta1/custom_namespace.go index 60d0cbab0c..774c897da7 100644 --- a/internal/namespaces/container/v1beta1/custom_namespace.go +++ b/internal/namespaces/container/v1beta1/custom_namespace.go @@ -8,7 +8,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" container "github.com/scaleway/scaleway-sdk-go/api/container/v1beta1" - "github.com/scaleway/scaleway-sdk-go/scw" ) var ( @@ -34,7 +33,7 @@ func waitForContainerNamespace(ctx context.Context, _, respI any) (any, error) { return api.WaitForNamespace(&container.WaitForNamespaceRequest{ NamespaceID: ns.ID, Region: ns.Region, - Timeout: scw.TimeDurationPtr(containerNamespaceActionTimeout), + Timeout: new(containerNamespaceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -60,7 +59,7 @@ func containerNamespaceDeleteBuilder(c *core.Command) *core.Command { _, err := api.WaitForNamespace(&container.WaitForNamespaceRequest{ NamespaceID: req.NamespaceID, Region: req.Region, - Timeout: scw.TimeDurationPtr(containerNamespaceActionTimeout), + Timeout: new(containerNamespaceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/flexibleip/v1alpha1/custom_ip.go b/internal/namespaces/flexibleip/v1alpha1/custom_ip.go index 849b042f30..2639d79551 100644 --- a/internal/namespaces/flexibleip/v1alpha1/custom_ip.go +++ b/internal/namespaces/flexibleip/v1alpha1/custom_ip.go @@ -8,7 +8,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" flexibleip "github.com/scaleway/scaleway-sdk-go/api/flexibleip/v1alpha1" - "github.com/scaleway/scaleway-sdk-go/scw" ) var ipStatusMarshalSpecs = human.EnumMarshalSpecs{ @@ -33,7 +32,7 @@ func createIPBuilder(c *core.Command) *core.Command { return api.WaitForFlexibleIP(&flexibleip.WaitForFlexibleIPRequest{ FipID: getResp.ID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(FlexibleIPTimeout), + Timeout: new(FlexibleIPTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/function/v1beta1/custom_deploy.go b/internal/namespaces/function/v1beta1/custom_deploy.go index 93aac3880e..c8025f086e 100644 --- a/internal/namespaces/function/v1beta1/custom_deploy.go +++ b/internal/namespaces/function/v1beta1/custom_deploy.go @@ -306,7 +306,7 @@ func DeployStepFunctionDeploy( Region: fc.Region, FunctionID: fc.ID, Runtime: runtime, - Redeploy: scw.BoolPtr(true), + Redeploy: new(true), }) if err != nil { return nil, err diff --git a/internal/namespaces/inference/v1/custom_deployment.go b/internal/namespaces/inference/v1/custom_deployment.go index 867c356225..fb06562d6a 100644 --- a/internal/namespaces/inference/v1/custom_deployment.go +++ b/internal/namespaces/inference/v1/custom_deployment.go @@ -125,7 +125,7 @@ func waitForDeploymentFunc(action int) core.WaitFunc { WaitForDeployment(&inference.WaitForDeploymentRequest{ DeploymentID: respI.(*inference.Deployment).ID, Region: respI.(*inference.Deployment).Region, - Timeout: scw.TimeDurationPtr(deploymentActionTimeout), + Timeout: new(deploymentActionTimeout), RetryInterval: core.DefaultRetryInterval, }) diff --git a/internal/namespaces/init/init.go b/internal/namespaces/init/init.go index 4868605ab5..7b6ea597f5 100644 --- a/internal/namespaces/init/init.go +++ b/internal/namespaces/init/init.go @@ -226,8 +226,8 @@ Default path for configuration file is based on the following priority order: profile := &scw.Profile{ AccessKey: &args.AccessKey, SecretKey: &args.SecretKey, - DefaultZone: scw.StringPtr(args.Zone.String()), - DefaultRegion: scw.StringPtr(args.Region.String()), + DefaultZone: new(args.Zone.String()), + DefaultRegion: new(args.Region.String()), DefaultOrganizationID: &args.OrganizationID, DefaultProjectID: &args.ProjectID, // An API key is always bound to a project. } diff --git a/internal/namespaces/init/init_test.go b/internal/namespaces/init/init_test.go index f702509a76..40367cfa05 100644 --- a/internal/namespaces/init/init_test.go +++ b/internal/namespaces/init/init_test.go @@ -124,7 +124,7 @@ func TestInit(t *testing.T) { "test": { AccessKey: &dummyAccessKey, SecretKey: &dummySecretKey, - DefaultZone: scw.StringPtr("fr-test"), // Used to check profile override + DefaultZone: new("fr-test"), // Used to check profile override }, }, } diff --git a/internal/namespaces/init/prompt.go b/internal/namespaces/init/prompt.go index 3aff73b965..9647665ec2 100644 --- a/internal/namespaces/init/prompt.go +++ b/internal/namespaces/init/prompt.go @@ -119,7 +119,7 @@ func promptTelemetry(ctx context.Context) (*bool, error) { return nil, err } - return scw.BoolPtr(sendTelemetry), nil + return new(sendTelemetry), nil } func promptAutocomplete(ctx context.Context) (*bool, error) { @@ -137,7 +137,7 @@ func promptAutocomplete(ctx context.Context) (*bool, error) { return nil, err } - return scw.BoolPtr(installAutocomplete), nil + return new(installAutocomplete), nil } func promptSecretKey(ctx context.Context) (string, error) { diff --git a/internal/namespaces/instance/v1/custom_image.go b/internal/namespaces/instance/v1/custom_image.go index ebc7d102e0..688ce48409 100644 --- a/internal/namespaces/instance/v1/custom_image.go +++ b/internal/namespaces/instance/v1/custom_image.go @@ -188,7 +188,7 @@ func imageListBuilder(c *core.Command) *core.Command { req := &instance.ListImagesRequest{ Organization: args.OrganizationID, Name: args.Name, - Public: scw.BoolPtr(false), + Public: new(false), Arch: args.Arch, Project: args.ProjectID, Tags: args.Tags, diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 8426ad71c5..d20cd56d39 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -325,13 +325,13 @@ func serverUpdateBuilder(c *core.Command) *core.Command { if volumeIsFromSBS(block.NewAPI(client), customRequest.Zone, volumeID) { volumes[index] = &instance.VolumeServerTemplate{ - ID: scw.StringPtr(volumeID), + ID: new(volumeID), VolumeType: instance.VolumeVolumeTypeSbsVolume, } } else { volumes[index] = &instance.VolumeServerTemplate{ - ID: scw.StringPtr(volumeID), - Name: scw.StringPtr(getServerResponse.Server.Name + "-" + index), + ID: new(volumeID), + Name: new(getServerResponse.Server.Name + "-" + index), } } } @@ -787,7 +787,7 @@ func serverWaitCommand() *core.Command { WaitForServer(&instance.WaitForServerRequest{ Zone: args.Zone, ServerID: args.ServerID, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, }) }, diff --git a/internal/namespaces/instance/v1/custom_server_action.go b/internal/namespaces/instance/v1/custom_server_action.go index 3cfed907bb..7b3832ba72 100644 --- a/internal/namespaces/instance/v1/custom_server_action.go +++ b/internal/namespaces/instance/v1/custom_server_action.go @@ -210,7 +210,7 @@ Once your image is ready you will be able to create a new server based on this i return api.WaitForImage(&instance.WaitForImageRequest{ ImageID: resp.Image.ID, Zone: resp.Image.Zone, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) }, @@ -322,7 +322,7 @@ func serverTerminateCommand() *core.Command { _, err := api.WaitForServer(&instance.WaitForServerRequest{ Zone: server.Zone, ServerID: server.ID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -568,7 +568,7 @@ func waitForServerFunc() core.WaitFunc { WaitForServer(&instance.WaitForServerRequest{ Zone: argsI.(*instanceUniqueActionRequest).Zone, ServerID: argsI.(*instanceUniqueActionRequest).ServerID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -612,7 +612,7 @@ func serverActionCommand() *core.Command { WaitForServer(&instance.WaitForServerRequest{ Zone: argsI.(*instanceActionRequest).Zone, ServerID: argsI.(*instanceActionRequest).ServerID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) }, diff --git a/internal/namespaces/instance/v1/custom_server_create.go b/internal/namespaces/instance/v1/custom_server_create.go index f432fe8abb..2776b3034a 100644 --- a/internal/namespaces/instance/v1/custom_server_create.go +++ b/internal/namespaces/instance/v1/custom_server_create.go @@ -207,7 +207,7 @@ func instanceWaitServerCreateRun() core.WaitFunc { WaitForServer(&instance.WaitForServerRequest{ Zone: argsI.(*instanceCreateServerRequest).Zone, ServerID: serverID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) @@ -231,7 +231,7 @@ func instanceServerCreateRun(ctx context.Context, argsI any) (i any, e error) { serverBuilder := NewServerBuilder(client, args.Name, args.Zone, args.Type). AddOrganizationID(args.OrganizationID). AddProjectID(args.ProjectID). - AddEnableIPv6(scw.BoolPtr(args.IPv6)). + AddEnableIPv6(new(args.IPv6)). AddTags(args.Tags). AddRoutedIPEnabled(args.RoutedIPEnabled). AddDynamicIPRequired(args.DynamicIPRequired). @@ -502,7 +502,7 @@ func sanitizeVolumeMap( m := make(map[string]*instance.VolumeServerTemplate) for index, v := range volumes { - v.Name = scw.StringPtr(serverName + "-" + index) + v.Name = new(serverName + "-" + index) // Remove extra data for API validation. switch { diff --git a/internal/namespaces/instance/v1/custom_server_create_builder.go b/internal/namespaces/instance/v1/custom_server_create_builder.go index b03a4f5265..6549d17ee3 100644 --- a/internal/namespaces/instance/v1/custom_server_create_builder.go +++ b/internal/namespaces/instance/v1/custom_server_create_builder.go @@ -194,7 +194,7 @@ func (sb *ServerBuilder) AddIP(ip string) (*ServerBuilder, error) { Type: instance.IPTypeRoutedIPv6, }} case validation.IsUUID(ip): - sb.createReq.PublicIP = scw.StringPtr(ip) + sb.createReq.PublicIP = new(ip) case net.ParseIP(ip) != nil: logger.Debugf("finding public IP UUID from address: %s", ip) res, err := sb.apiInstance.GetIP(&instance.GetIPRequest{ @@ -204,12 +204,12 @@ func (sb *ServerBuilder) AddIP(ip string) (*ServerBuilder, error) { if err != nil { // FIXME: isNotFoundError return sb, fmt.Errorf("%s does not belong to you", ip) } - sb.createReq.PublicIP = scw.StringPtr(res.IP.ID) + sb.createReq.PublicIP = new(res.IP.ID) case ip == "dynamic": - sb.createReq.DynamicIPRequired = scw.BoolPtr(true) + sb.createReq.DynamicIPRequired = new(true) case ip == "none": - sb.createReq.DynamicIPRequired = scw.BoolPtr(false) + sb.createReq.DynamicIPRequired = new(false) default: return sb, fmt.Errorf( `invalid IP "%s", should be either 'new', 'ipv4', 'ipv6', 'both', 'dynamic', 'none', an IP address ID or a reserved flexible IP address`, @@ -350,7 +350,7 @@ func (sb *ServerBuilder) BuildVolumes() error { return fmt.Errorf("failed to build volume template: %w", err) } index := strconv.Itoa(i + 1) - volumeTemplate.Name = scw.StringPtr(sb.createReq.Name + "-" + index) + volumeTemplate.Name = new(sb.createReq.Name + "-" + index) volumes[index] = volumeTemplate } // Sanitize the volume map to respect API schemas @@ -564,7 +564,7 @@ func NewVolumeBuilder(zone scw.Zone, flagV string) (*VolumeBuilder, error) { if err != nil { return nil, fmt.Errorf("invalid volume iops %s in %s volume", parts[2], flagV) } - vb.IOPS = scw.Uint32Ptr(uint32(iops)) + vb.IOPS = new(uint32(iops)) parts = parts[0:2] } @@ -582,13 +582,13 @@ func NewVolumeBuilder(zone scw.Zone, flagV string) (*VolumeBuilder, error) { } if validation.IsUUID(parts[1]) { - vb.SnapshotID = scw.StringPtr(parts[1]) + vb.SnapshotID = new(parts[1]) } else { size, err := humanize.ParseBytes(parts[1]) if err != nil { return nil, fmt.Errorf("invalid size format %s in %s volume", parts[1], flagV) } - vb.Size = scw.SizePtr(scw.Size(size)) + vb.Size = new(scw.Size(size)) } return vb, nil @@ -596,7 +596,7 @@ func NewVolumeBuilder(zone scw.Zone, flagV string) (*VolumeBuilder, error) { // UUID format. if len(parts) == 1 && validation.IsUUID(parts[0]) { - vb.VolumeID = scw.StringPtr(parts[0]) + vb.VolumeID = new(parts[0]) return vb, nil } diff --git a/internal/namespaces/instance/v1/custom_server_delete.go b/internal/namespaces/instance/v1/custom_server_delete.go index fe66217659..8fa832d065 100644 --- a/internal/namespaces/instance/v1/custom_server_delete.go +++ b/internal/namespaces/instance/v1/custom_server_delete.go @@ -101,7 +101,7 @@ func serverDeleteCommand() *core.Command { _, err := api.WaitForServer(&instance.WaitForServerRequest{ Zone: server.Zone, ServerID: server.ID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -131,7 +131,7 @@ func serverDeleteCommand() *core.Command { finalStateServer, err := api.WaitForServer(&instance.WaitForServerRequest{ Zone: deleteServerArgs.Zone, ServerID: deleteServerArgs.ServerID, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -143,7 +143,7 @@ func serverDeleteCommand() *core.Command { Zone: deleteServerArgs.Zone, ServerID: deleteServerArgs.ServerID, Action: instance.ServerActionPoweroff, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/instance/v1/custom_snapshot.go b/internal/namespaces/instance/v1/custom_snapshot.go index e333416e15..79f1c9de52 100644 --- a/internal/namespaces/instance/v1/custom_snapshot.go +++ b/internal/namespaces/instance/v1/custom_snapshot.go @@ -7,7 +7,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -74,7 +73,7 @@ func snapshotCreateBuilder(c *core.Command) *core.Command { return api.WaitForSnapshot(&instance.WaitForSnapshotRequest{ SnapshotID: respI.(*instance.CreateSnapshotResponse).Snapshot.ID, Zone: argsI.(*customCreateSnapshotRequest).Zone, - Timeout: scw.TimeDurationPtr(serverActionTimeout), + Timeout: new(serverActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -159,7 +158,7 @@ func snapshotUpdateBuilder(c *core.Command) *core.Command { return api.WaitForSnapshot(&instance.WaitForSnapshotRequest{ SnapshotID: snapshot.ID, Zone: snapshot.Zone, - Timeout: scw.TimeDurationPtr(snapshotActionTimeout), + Timeout: new(snapshotActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/instance/v1/custom_volume.go b/internal/namespaces/instance/v1/custom_volume.go index 52fc6f7eef..bc7f104c27 100644 --- a/internal/namespaces/instance/v1/custom_volume.go +++ b/internal/namespaces/instance/v1/custom_volume.go @@ -127,7 +127,7 @@ func volumeWaitCommand() *core.Command { WaitForVolume(&instance.WaitForVolumeRequest{ Zone: args.Zone, VolumeID: args.VolumeID, - Timeout: scw.TimeDurationPtr(args.Timeout), + Timeout: new(args.Timeout), RetryInterval: core.DefaultRetryInterval, }) }, diff --git a/internal/namespaces/iot/v1/custom_hub.go b/internal/namespaces/iot/v1/custom_hub.go index f16b12e635..d47b468418 100644 --- a/internal/namespaces/iot/v1/custom_hub.go +++ b/internal/namespaces/iot/v1/custom_hub.go @@ -8,7 +8,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" "github.com/scaleway/scaleway-sdk-go/api/iot/v1" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -30,7 +29,7 @@ func hubCreateBuilder(c *core.Command) *core.Command { return api.WaitForHub(&iot.WaitForHubRequest{ HubID: respI.(*iot.Hub).ID, Region: respI.(*iot.Hub).Region, - Timeout: scw.TimeDurationPtr(hubActionTimeout), + Timeout: new(hubActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/k8s/v1/custom_cluster.go b/internal/namespaces/k8s/v1/custom_cluster.go index 1a0512bc5d..d3d3e5c33d 100644 --- a/internal/namespaces/k8s/v1/custom_cluster.go +++ b/internal/namespaces/k8s/v1/custom_cluster.go @@ -158,7 +158,7 @@ func clusterCreateBuilder(c *core.Command) *core.Command { if err != nil { return nil, err } - request.PrivateNetworkID = scw.StringPtr(pn.ID) + request.PrivateNetworkID = new(pn.ID) pnCreated = true } else { pn, err = vpcAPI.GetPrivateNetwork(&vpc.GetPrivateNetworkRequest{ @@ -335,7 +335,7 @@ func waitForClusterFunc(action int) core.WaitFunc { WaitForCluster(&k8s.WaitForClusterRequest{ Region: clusterResponse.Region, ClusterID: clusterResponse.ID, - Timeout: scw.TimeDurationPtr(clusterActionTimeout), + Timeout: new(clusterActionTimeout), RetryInterval: core.DefaultRetryInterval, }) switch action { diff --git a/internal/namespaces/k8s/v1/custom_execcredentials_test.go b/internal/namespaces/k8s/v1/custom_execcredentials_test.go index b5394899c8..3b3779d91e 100644 --- a/internal/namespaces/k8s/v1/custom_execcredentials_test.go +++ b/internal/namespaces/k8s/v1/custom_execcredentials_test.go @@ -137,38 +137,38 @@ func beforeFuncCreateConfigFile(c *scw.Config) core.BeforeFunc { func beforeFuncCreateFullConfig() core.BeforeFunc { return beforeFuncCreateConfigFile(&scw.Config{ Profile: scw.Profile{ - AccessKey: scw.StringPtr("SCWXXXXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr(p1Secret), - APIURL: scw.StringPtr("https://mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultProjectID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWXXXXXXXXXXXXXXXXX"), + SecretKey: new(p1Secret), + APIURL: new("https://mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultProjectID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, Profiles: map[string]*scw.Profile{ "p2": { - AccessKey: scw.StringPtr("SCWP2XXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr(p2Secret), - APIURL: scw.StringPtr("https://p2-mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultProjectID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWP2XXXXXXXXXXXXXXX"), + SecretKey: new(p2Secret), + APIURL: new("https://p2-mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultProjectID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, "p3": { - AccessKey: scw.StringPtr("SCWP3XXXXXXXXXXXXXXX"), - SecretKey: scw.StringPtr(p3Secret), - APIURL: scw.StringPtr("https://p3-mock-api-url.com"), - Insecure: scw.BoolPtr(true), - DefaultOrganizationID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultProjectID: scw.StringPtr("deadbeef-dead-dead-dead-deaddeafbeef"), - DefaultRegion: scw.StringPtr("fr-par"), - DefaultZone: scw.StringPtr("fr-par-1"), - SendTelemetry: scw.BoolPtr(true), + AccessKey: new("SCWP3XXXXXXXXXXXXXXX"), + SecretKey: new(p3Secret), + APIURL: new("https://p3-mock-api-url.com"), + Insecure: new(true), + DefaultOrganizationID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultProjectID: new("deadbeef-dead-dead-dead-deaddeafbeef"), + DefaultRegion: new("fr-par"), + DefaultZone: new("fr-par-1"), + SendTelemetry: new(true), }, }, }) diff --git a/internal/namespaces/k8s/v1/custom_kubeconfig_get.go b/internal/namespaces/k8s/v1/custom_kubeconfig_get.go index 531d2d4235..7631984fff 100644 --- a/internal/namespaces/k8s/v1/custom_kubeconfig_get.go +++ b/internal/namespaces/k8s/v1/custom_kubeconfig_get.go @@ -72,7 +72,7 @@ func k8sKubeconfigGetRun(ctx context.Context, argsI any) (i any, e error) { GetClusterKubeConfig(&k8s.GetClusterKubeConfigRequest{ Region: request.Region, ClusterID: request.ClusterID, - Redacted: scw.BoolPtr( + Redacted: new( request.AuthMethod != authMethodLegacy, ), // put true after legacy deprecation }) diff --git a/internal/namespaces/k8s/v1/custom_kubeconfig_install.go b/internal/namespaces/k8s/v1/custom_kubeconfig_install.go index 06abf5cbb1..02d30bb571 100644 --- a/internal/namespaces/k8s/v1/custom_kubeconfig_install.go +++ b/internal/namespaces/k8s/v1/custom_kubeconfig_install.go @@ -86,7 +86,7 @@ func k8sKubeconfigInstallRun(ctx context.Context, argsI any) (i any, e error) { GetClusterKubeConfig(&k8s.GetClusterKubeConfigRequest{ Region: request.Region, ClusterID: request.ClusterID, - Redacted: scw.BoolPtr( + Redacted: new( request.AuthMethod != authMethodLegacy, ), // put true after legacy deprecation }) diff --git a/internal/namespaces/k8s/v1/custom_node.go b/internal/namespaces/k8s/v1/custom_node.go index eca08a8918..95d7269695 100644 --- a/internal/namespaces/k8s/v1/custom_node.go +++ b/internal/namespaces/k8s/v1/custom_node.go @@ -9,7 +9,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" k8s "github.com/scaleway/scaleway-sdk-go/api/k8s/v1" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -41,7 +40,7 @@ func waitForNodeFunc(action int) core.WaitFunc { node, err := k8s.NewAPI(core.ExtractClient(ctx)).WaitForNode(&k8s.WaitForNodeRequest{ Region: respI.(*k8s.Node).Region, NodeID: respI.(*k8s.Node).ID, - Timeout: scw.TimeDurationPtr(nodeActionTimeout), + Timeout: new(nodeActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if action == nodeActionReboot { diff --git a/internal/namespaces/k8s/v1/custom_pool.go b/internal/namespaces/k8s/v1/custom_pool.go index 05c208bf56..87a098f25d 100644 --- a/internal/namespaces/k8s/v1/custom_pool.go +++ b/internal/namespaces/k8s/v1/custom_pool.go @@ -76,7 +76,7 @@ func waitForPoolFunc(action int) core.WaitFunc { pool, err := k8s.NewAPI(core.ExtractClient(ctx)).WaitForPool(&k8s.WaitForPoolRequest{ Region: respI.(*k8s.Pool).Region, PoolID: respI.(*k8s.Pool).ID, - Timeout: scw.TimeDurationPtr(poolActionTimeout), + Timeout: new(poolActionTimeout), RetryInterval: core.DefaultRetryInterval, }) switch action { diff --git a/internal/namespaces/k8s/v1/helpers_test.go b/internal/namespaces/k8s/v1/helpers_test.go index a6ec99f5d7..749c033b2d 100644 --- a/internal/namespaces/k8s/v1/helpers_test.go +++ b/internal/namespaces/k8s/v1/helpers_test.go @@ -11,7 +11,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" go_api "github.com/scaleway/scaleway-cli/v2/internal/namespaces/k8s/v1/types" k8s "github.com/scaleway/scaleway-sdk-go/api/k8s/v1" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -56,7 +55,7 @@ func fetchClusterKubeconfigMetadata( GetClusterKubeConfig(&k8s.GetClusterKubeConfigRequest{ Region: cluster.Region, ClusterID: cluster.ID, - Redacted: scw.BoolPtr(redacted), + Redacted: new(redacted), }) if err != nil { return err diff --git a/internal/namespaces/lb/v1/custom_lb.go b/internal/namespaces/lb/v1/custom_lb.go index 955cfc1884..00bf0dabc7 100644 --- a/internal/namespaces/lb/v1/custom_lb.go +++ b/internal/namespaces/lb/v1/custom_lb.go @@ -174,7 +174,7 @@ func lbUpdateBuilder(c *core.Command) *core.Command { waitRequest := &lb.ZonedAPIWaitForLBRequest{ LBID: request.LBID, Zone: request.Zone, - Timeout: scw.TimeDurationPtr(defaultLBTimeout), + Timeout: new(defaultLBTimeout), RetryInterval: core.DefaultRetryInterval, } res, err := lbAPI.WaitForLb(waitRequest, scw.WithContext(ctx)) diff --git a/internal/namespaces/mongodb/v1alpha1/custom_instance.go b/internal/namespaces/mongodb/v1alpha1/custom_instance.go index 426325e383..e14d665624 100644 --- a/internal/namespaces/mongodb/v1alpha1/custom_instance.go +++ b/internal/namespaces/mongodb/v1alpha1/custom_instance.go @@ -66,7 +66,7 @@ func instanceCreateBuilder(c *core.Command) *core.Command { return api.WaitForInstance(&mongodb.WaitForInstanceRequest{ InstanceID: getResp.ID, Region: getResp.Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -145,7 +145,7 @@ func instanceWaitCommand() *core.Command { return api.WaitForInstance(&mongodb.WaitForInstanceRequest{ Region: argsI.(*serverWaitRequest).Region, InstanceID: argsI.(*serverWaitRequest).InstanceID, - Timeout: scw.TimeDurationPtr(argsI.(*serverWaitRequest).Timeout), + Timeout: new(argsI.(*serverWaitRequest).Timeout), RetryInterval: core.DefaultRetryInterval, }) }, diff --git a/internal/namespaces/object/v1/custom_bucket.go b/internal/namespaces/object/v1/custom_bucket.go index 04687178e9..4377f6c83d 100644 --- a/internal/namespaces/object/v1/custom_bucket.go +++ b/internal/namespaces/object/v1/custom_bucket.go @@ -77,7 +77,7 @@ func bucketCreateCommand() *core.Command { CreateBucketConfiguration: &types.CreateBucketConfiguration{ LocationConstraint: types.BucketLocationConstraint(args.Region), }, - ObjectLockEnabledForBucket: scw.BoolPtr(false), + ObjectLockEnabledForBucket: new(false), }) if err != nil { return nil, fmt.Errorf("could not create bucket: %w", err) diff --git a/internal/namespaces/object/v1/custom_bucket_test.go b/internal/namespaces/object/v1/custom_bucket_test.go index 360cf0e6d3..96fba6f291 100644 --- a/internal/namespaces/object/v1/custom_bucket_test.go +++ b/internal/namespaces/object/v1/custom_bucket_test.go @@ -59,12 +59,12 @@ func Test_BucketCreate(t *testing.T) { assert.False(t, bucket.EnableVersioning) assert.Equal(t, []types.Tag{ { - Key: scw.StringPtr("key1"), - Value: scw.StringPtr("value1"), + Key: new("key1"), + Value: new("value1"), }, { - Key: scw.StringPtr("key2"), - Value: scw.StringPtr("value2"), + Key: new("key2"), + Value: new("value2"), }, }, bucket.Tags) checkACL(t, "private", bucket.ACL, bucket.Owner) @@ -214,8 +214,8 @@ func Test_BucketUpdate(t *testing.T) { assert.False(t, bucket.EnableVersioning) assert.Equal(t, []types.Tag{ { - Key: scw.StringPtr("key1"), - Value: scw.StringPtr("value1"), + Key: new("key1"), + Value: new("value1"), }, }, bucket.Tags) checkACL(t, "private", bucket.ACL, bucket.Owner) @@ -243,12 +243,12 @@ func Test_BucketUpdate(t *testing.T) { assert.True(t, bucket.EnableVersioning) assert.Equal(t, []types.Tag{ { - Key: scw.StringPtr("key1"), - Value: scw.StringPtr("value1"), + Key: new("key1"), + Value: new("value1"), }, { - Key: scw.StringPtr("key2"), - Value: scw.StringPtr("value2"), + Key: new("key2"), + Value: new("value2"), }, }, bucket.Tags) checkACL(t, "public-read-write", bucket.ACL, bucket.Owner) diff --git a/internal/namespaces/object/v1/s3_helpers.go b/internal/namespaces/object/v1/s3_helpers.go index ae90925659..abe6b31f6d 100644 --- a/internal/namespaces/object/v1/s3_helpers.go +++ b/internal/namespaces/object/v1/s3_helpers.go @@ -42,7 +42,7 @@ func newS3Client(ctx context.Context, region scw.Region) *s3.Client { SecretAccessKey: secretKey, }, nil }), - BaseEndpoint: scw.StringPtr(customEndpoint), + BaseEndpoint: new(customEndpoint), Region: region.String(), HTTPClient: httpClient, }) @@ -87,10 +87,10 @@ func awsACLToCustomGrants(output *s3.GetBucketAclOutput) []CustomS3ACLGrant { var grantee *string switch grant.Grantee.Type { case types.TypeCanonicalUser: - grantee = scw.StringPtr(normalizeOwnerID(grant.Grantee.ID)) + grantee = new(normalizeOwnerID(grant.Grantee.ID)) case types.TypeGroup: split := strings.Split(*grant.Grantee.URI, "/") - grantee = scw.StringPtr(split[len(split)-1]) + grantee = new(split[len(split)-1]) } customGrants = append(customGrants, CustomS3ACLGrant{ Grantee: grantee, diff --git a/internal/namespaces/rdb/v1/custom_acl.go b/internal/namespaces/rdb/v1/custom_acl.go index 567a2f7cf3..64e8a97387 100644 --- a/internal/namespaces/rdb/v1/custom_acl.go +++ b/internal/namespaces/rdb/v1/custom_acl.go @@ -144,7 +144,7 @@ func aclAddBuilder(c *core.Command) *core.Command { _, err := api.WaitForInstance(&rdb.WaitForInstanceRequest{ InstanceID: args.InstanceID, Region: args.Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -272,7 +272,7 @@ func aclDeleteBuilder(c *core.Command) *core.Command { _, err := api.WaitForInstance(&rdb.WaitForInstanceRequest{ InstanceID: args.InstanceID, Region: args.Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -358,7 +358,7 @@ func aclSetBuilder(c *core.Command) *core.Command { _, err := api.WaitForInstance(&rdb.WaitForInstanceRequest{ InstanceID: args.InstanceID, Region: args.Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/rdb/v1/custom_backup.go b/internal/namespaces/rdb/v1/custom_backup.go index ebb997dfd2..354e8ceda5 100644 --- a/internal/namespaces/rdb/v1/custom_backup.go +++ b/internal/namespaces/rdb/v1/custom_backup.go @@ -76,7 +76,7 @@ func backupWaitCommand() *core.Command { return api.WaitForDatabaseBackup(&rdb.WaitForDatabaseBackupRequest{ DatabaseBackupID: argsI.(*backupWaitRequest).BackupID, Region: argsI.(*backupWaitRequest).Region, - Timeout: scw.TimeDurationPtr(argsI.(*backupWaitRequest).Timeout), + Timeout: new(argsI.(*backupWaitRequest).Timeout), RetryInterval: core.DefaultRetryInterval, }) }, @@ -402,7 +402,7 @@ func backupDownloadCommand() *core.Command { backupRequest := &rdb.WaitForDatabaseBackupRequest{ DatabaseBackupID: args.BackupID, Region: args.Region, - Timeout: scw.TimeDurationPtr(backupActionTimeout), + Timeout: new(backupActionTimeout), RetryInterval: core.DefaultRetryInterval, } diff --git a/internal/namespaces/rdb/v1/custom_endpoint_test.go b/internal/namespaces/rdb/v1/custom_endpoint_test.go index 75c37d7ae6..d696fb389e 100644 --- a/internal/namespaces/rdb/v1/custom_endpoint_test.go +++ b/internal/namespaces/rdb/v1/custom_endpoint_test.go @@ -268,7 +268,7 @@ func checkEndpoints( Region: instance.Region, ResourceID: &instance.ID, ResourceType: "rdb_instance", - IsIPv6: scw.BoolPtr(false), + IsIPv6: new(false), }, scw.WithAllPages()) if err != nil { t.Errorf("could not list IPs: %v", err) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index 00482f8c6a..9f860ce10d 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -198,7 +198,7 @@ func instanceCloneBuilder(c *core.Command) *core.Command { return api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ InstanceID: respI.(*rdbSDK.Instance).ID, Region: respI.(*rdbSDK.Instance).Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -318,7 +318,7 @@ func instanceCreateBuilder(c *core.Command) *core.Command { instance, err := api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ InstanceID: respI.(CreateInstanceResult).ID, Region: respI.(CreateInstanceResult).Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -510,7 +510,7 @@ func instanceUpgradeBuilder(c *core.Command) *core.Command { return api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ InstanceID: instance.ID, Region: instance.Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -669,7 +669,7 @@ func instanceUpdateBuilder(_ *core.Command) *core.Command { return api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ InstanceID: respI.(*rdbSDK.Instance).ID, Region: respI.(*rdbSDK.Instance).Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) }, @@ -696,7 +696,7 @@ func instanceDeleteBuilder(c *core.Command) *core.Command { instance, err := api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ InstanceID: respI.(*rdbSDK.Instance).ID, Region: respI.(*rdbSDK.Instance).Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -732,7 +732,7 @@ func instanceWaitCommand() *core.Command { return api.WaitForInstance(&rdbSDK.WaitForInstanceRequest{ Region: argsI.(*serverWaitRequest).Region, InstanceID: argsI.(*serverWaitRequest).InstanceID, - Timeout: scw.TimeDurationPtr(argsI.(*serverWaitRequest).Timeout), + Timeout: new(argsI.(*serverWaitRequest).Timeout), RetryInterval: core.DefaultRetryInterval, }) }, diff --git a/internal/namespaces/rdb/v1/custom_log.go b/internal/namespaces/rdb/v1/custom_log.go index 48ff713ee9..396892b21a 100644 --- a/internal/namespaces/rdb/v1/custom_log.go +++ b/internal/namespaces/rdb/v1/custom_log.go @@ -39,7 +39,7 @@ func logPrepareBuilder(c *core.Command) *core.Command { logs, err := api.WaitForInstanceLog(&rdb.WaitForInstanceLogRequest{ InstanceLogID: getResp.InstanceLogs[i].ID, Region: getResp.InstanceLogs[i].Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -172,7 +172,7 @@ func logDownloadCommand() *core.Command { logs, err := api.WaitForInstanceLog(&rdb.WaitForInstanceLogRequest{ InstanceLogID: prepareResp.InstanceLogs[i].ID, Region: prepareResp.InstanceLogs[i].Region, - Timeout: scw.TimeDurationPtr(instanceActionTimeout), + Timeout: new(instanceActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/redis/v1/custom_acl.go b/internal/namespaces/redis/v1/custom_acl.go index 6a9fbf1508..d5a6a7cba8 100644 --- a/internal/namespaces/redis/v1/custom_acl.go +++ b/internal/namespaces/redis/v1/custom_acl.go @@ -73,7 +73,7 @@ func redisACLUpdateCommand() *core.Command { waitReq := &redis.WaitForClusterRequest{ ClusterID: args.ClusterID, Zone: scw.Zone(args.Zone), - Timeout: scw.TimeDurationPtr(redisActionTimeout), + Timeout: new(redisActionTimeout), } _, err = api.WaitForCluster(waitReq) if err != nil { diff --git a/internal/namespaces/redis/v1/custom_cluster.go b/internal/namespaces/redis/v1/custom_cluster.go index 7c2ae62e08..d6dce37412 100644 --- a/internal/namespaces/redis/v1/custom_cluster.go +++ b/internal/namespaces/redis/v1/custom_cluster.go @@ -58,7 +58,7 @@ func clusterCreateBuilder(c *core.Command) *core.Command { cluster, err := api.WaitForCluster(&redis.WaitForClusterRequest{ ClusterID: respI.(*redis.Cluster).ID, Zone: respI.(*redis.Cluster).Zone, - Timeout: scw.TimeDurationPtr(redisActionTimeout), + Timeout: new(redisActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { @@ -121,7 +121,7 @@ func clusterDeleteBuilder(c *core.Command) *core.Command { cluster, err := api.WaitForCluster(&redis.WaitForClusterRequest{ ClusterID: respI.(*redis.Cluster).ID, Zone: respI.(*redis.Cluster).Zone, - Timeout: scw.TimeDurationPtr(redisActionTimeout), + Timeout: new(redisActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/vpcgw/v1/custom_gateway.go b/internal/namespaces/vpcgw/v1/custom_gateway.go index 333848dcba..6bb7d1b399 100644 --- a/internal/namespaces/vpcgw/v1/custom_gateway.go +++ b/internal/namespaces/vpcgw/v1/custom_gateway.go @@ -8,7 +8,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" "github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -35,7 +34,7 @@ func gatewayCreateBuilder(c *core.Command) *core.Command { return api.WaitForGateway(&vpcgw.WaitForGatewayRequest{ GatewayID: getResp.ID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/vpcgw/v1/custom_gateway_network.go b/internal/namespaces/vpcgw/v1/custom_gateway_network.go index c1d87788cd..6c7a08cd0c 100644 --- a/internal/namespaces/vpcgw/v1/custom_gateway_network.go +++ b/internal/namespaces/vpcgw/v1/custom_gateway_network.go @@ -30,7 +30,7 @@ func gatewayNetworkCreateBuilder(c *core.Command) *core.Command { return api.WaitForGatewayNetwork(&vpcgw.WaitForGatewayNetworkRequest{ GatewayNetworkID: getResp.ID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -45,7 +45,7 @@ func gatewayNetworkDeleteBuilder(c *core.Command) *core.Command { gwNetwork, err := api.WaitForGatewayNetwork(&vpcgw.WaitForGatewayNetworkRequest{ GatewayNetworkID: getResp.GatewayNetworkID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/namespaces/vpcgw/v2/custom_gateway.go b/internal/namespaces/vpcgw/v2/custom_gateway.go index e80165d528..a89b198719 100644 --- a/internal/namespaces/vpcgw/v2/custom_gateway.go +++ b/internal/namespaces/vpcgw/v2/custom_gateway.go @@ -8,7 +8,6 @@ import ( "github.com/scaleway/scaleway-cli/v2/core" "github.com/scaleway/scaleway-cli/v2/core/human" "github.com/scaleway/scaleway-sdk-go/api/vpcgw/v2" - "github.com/scaleway/scaleway-sdk-go/scw" ) const ( @@ -35,7 +34,7 @@ func gatewayCreateBuilder(c *core.Command) *core.Command { return api.WaitForGateway(&vpcgw.WaitForGatewayRequest{ GatewayID: getResp.ID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } diff --git a/internal/namespaces/vpcgw/v2/custom_gateway_network.go b/internal/namespaces/vpcgw/v2/custom_gateway_network.go index e8d5ede3dc..d563b9ac38 100644 --- a/internal/namespaces/vpcgw/v2/custom_gateway_network.go +++ b/internal/namespaces/vpcgw/v2/custom_gateway_network.go @@ -29,7 +29,7 @@ func gatewayNetworkCreateBuilder(c *core.Command) *core.Command { return api.WaitForGatewayNetwork(&vpcgw.WaitForGatewayNetworkRequest{ GatewayNetworkID: getResp.ID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) } @@ -44,7 +44,7 @@ func gatewayNetworkDeleteBuilder(c *core.Command) *core.Command { gwNetwork, err := api.WaitForGatewayNetwork(&vpcgw.WaitForGatewayNetworkRequest{ GatewayNetworkID: getResp.GatewayNetworkID, Zone: getResp.Zone, - Timeout: scw.TimeDurationPtr(gatewayActionTimeout), + Timeout: new(gatewayActionTimeout), RetryInterval: core.DefaultRetryInterval, }) if err != nil { diff --git a/internal/platform/terminal/terminal_client.go b/internal/platform/terminal/terminal_client.go index c0f95149b3..4beb93aeeb 100644 --- a/internal/platform/terminal/terminal_client.go +++ b/internal/platform/terminal/terminal_client.go @@ -66,7 +66,7 @@ func (p *Platform) CreateClient( logger.Debugf("guess region from %s zone", zone) region := zone[:len(zone)-2] if validation.IsRegion(region) { - profile.DefaultRegion = scw.StringPtr(region) + profile.DefaultRegion = new(region) } else { logger.Debugf("invalid guessed region '%s'", region) }