diff --git a/core/bootstrap_test.go b/core/bootstrap_test.go index 5e14c8a5eb..3519595efe 100644 --- a/core/bootstrap_test.go +++ b/core/bootstrap_test.go @@ -21,7 +21,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "interrupt", Verb: "error", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return nil, &interactive.InterruptError{} }, @@ -38,7 +38,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "code", Verb: "error", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return nil, &core.CliError{Code: 99} }, @@ -55,7 +55,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "empty", Verb: "error", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return nil, &core.CliError{Code: 99, Empty: true} }, @@ -75,7 +75,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "empty", Verb: "error", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return nil, &core.CliError{Code: 99, Empty: true} }, @@ -95,7 +95,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "empty", Verb: "success", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{ Empty: true, @@ -118,7 +118,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "empty", Verb: "success", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{ Empty: true, @@ -141,7 +141,7 @@ func TestInterruptError(t *testing.T) { Namespace: "test", Resource: "empty", Verb: "success", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (i any, e error) { return []int(nil), nil }, diff --git a/core/build_info_test.go b/core/build_info_test.go index 7c6ac47c96..81ab12c3b2 100644 --- a/core/build_info_test.go +++ b/core/build_info_test.go @@ -17,7 +17,7 @@ import ( var fakeCommand = &core.Command{ Namespace: "plop", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{}, nil diff --git a/core/checks_test.go b/core/checks_test.go index d48d232ff2..ed4f599ef1 100644 --- a/core/checks_test.go +++ b/core/checks_test.go @@ -20,7 +20,7 @@ func TestCheckAPIKey(t *testing.T) { &core.Command{ Namespace: "test", ArgSpecs: core.ArgSpecs{}, - ArgsType: reflect.TypeOf(testType{}), + ArgsType: reflect.TypeFor[testType](), Run: func(ctx context.Context, _ any) (i any, e error) { // Test command reload the client so the profile used is the edited one return "", core.ReloadClient(ctx) diff --git a/core/cobra_usage_builder_test.go b/core/cobra_usage_builder_test.go index f369c2a763..4c2f9efe72 100644 --- a/core/cobra_usage_builder_test.go +++ b/core/cobra_usage_builder_test.go @@ -41,7 +41,7 @@ func Test_buildUsageArgs(t *testing.T) { [additional-volumes.{index}.name] Additional volume name` got := core.BuildUsageArgs(t.Context(), &core.Command{ - ArgsType: reflect.TypeOf(instanceListServerArgs{}), + ArgsType: reflect.TypeFor[instanceListServerArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", diff --git a/core/cobra_utils_test.go b/core/cobra_utils_test.go index aa7fa157f4..5af334c3f5 100644 --- a/core/cobra_utils_test.go +++ b/core/cobra_utils_test.go @@ -37,7 +37,7 @@ func testGetCommands() *core.Commands { }, }, AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(testType{}), + ArgsType: reflect.TypeFor[testType](), Run: func(_ context.Context, _ any) (i any, e error) { return "", nil }, @@ -55,7 +55,7 @@ func testGetCommands() *core.Commands { }, }, AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(testType{}), + ArgsType: reflect.TypeFor[testType](), Run: func(_ context.Context, argsI any) (i any, e error) { return argsI, nil }, @@ -74,7 +74,7 @@ func testGetCommands() *core.Commands { }, AcceptMultiplePositionalArgs: true, AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(testAcceptMultiPositionalArgsType{}), + ArgsType: reflect.TypeFor[testAcceptMultiPositionalArgsType](), Run: func(_ context.Context, argsI any) (i any, e error) { return argsI, nil }, @@ -82,7 +82,7 @@ func testGetCommands() *core.Commands { &core.Command{ Namespace: "test", Resource: "raw-args", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, argsI any) (i any, e error) { rawArgs := *argsI.(*args.RawArgs) @@ -93,7 +93,7 @@ func testGetCommands() *core.Commands { &core.Command{ Namespace: "test", Resource: "date", - ArgsType: reflect.TypeOf(testDate{}), + ArgsType: reflect.TypeFor[testDate](), AllowAnonymousClient: true, Run: func(_ context.Context, argsI any) (i any, e error) { a := argsI.(*testDate) diff --git a/core/human/marshal.go b/core/human/marshal.go index 2f33dafb6b..8231053e7c 100644 --- a/core/human/marshal.go +++ b/core/human/marshal.go @@ -68,15 +68,15 @@ func Marshal(data any, opt *MarshalOpt) (string, error) { return marshalerFunc(rValue.Interface(), opt) // Handle special well known interface - case rType.Implements(reflect.TypeOf((*Marshaler)(nil)).Elem()): + case rType.Implements(reflect.TypeFor[Marshaler]()): return rValue.Interface().(Marshaler).MarshalHuman() // Handle errors - case rType.Implements(reflect.TypeOf((*error)(nil)).Elem()): + case rType.Implements(reflect.TypeFor[error]()): return terminal.Style(Capitalize(rValue.Interface().(error).Error()), color.FgRed), nil // Handle stringers - case rType.Implements(reflect.TypeOf((*fmt.Stringer)(nil)).Elem()): + case rType.Implements(reflect.TypeFor[fmt.Stringer]()): return rValue.Interface().(fmt.Stringer).String(), nil // If data is a pointer dereference an call Marshal again @@ -143,7 +143,7 @@ func marshalStruct(value reflect.Value, opt *MarshalOpt) (string, error) { return [][]string{{strings.Join(keys, "."), str}}, err // If data is a stringers - case rType.Implements(reflect.TypeOf((*fmt.Stringer)(nil)).Elem()): + case rType.Implements(reflect.TypeFor[fmt.Stringer]()): return [][]string{ {strings.Join(keys, "."), value.Interface().(fmt.Stringer).String()}, }, nil diff --git a/core/human/marshal_func.go b/core/human/marshal_func.go index 6bbe41f891..9cffd61e05 100644 --- a/core/human/marshal_func.go +++ b/core/human/marshal_func.go @@ -22,12 +22,12 @@ type MarshalerFunc func(any, *MarshalOpt) (string, error) var marshalerFuncs sync.Map func init() { - marshalerFuncs.Store(reflect.TypeOf(int(0)), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(int32(0)), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(int64(0)), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(uint32(0)), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(uint64(0)), defaultMarshalerFunc) - marshalerFuncs.Store(reflect.TypeOf(string("")), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[int](), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[int32](), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[int64](), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[uint32](), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[uint64](), defaultMarshalerFunc) + marshalerFuncs.Store(reflect.TypeFor[string](), defaultMarshalerFunc) marshalerFuncs.Store( reflect.TypeOf(bool(false)), func(i any, _ *MarshalOpt) (string, error) { @@ -40,13 +40,13 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(time.Time{}), + reflect.TypeFor[time.Time](), func(i any, _ *MarshalOpt) (string, error) { return humanize.Time(i.(time.Time)), nil }, ) marshalerFuncs.Store( - reflect.TypeOf(&time.Time{}), + reflect.TypeFor[*time.Time](), func(i any, _ *MarshalOpt) (string, error) { t := i.(*time.Time) if t == nil { @@ -57,7 +57,7 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(scw.Size(0)), + reflect.TypeFor[scw.Size](), func(i any, _ *MarshalOpt) (string, error) { size := uint64(i.(scw.Size)) @@ -69,7 +69,7 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(new(scw.Size(0))), + reflect.TypeFor[*scw.Size](), func(i any, _ *MarshalOpt) (string, error) { size := uint64(*i.(*scw.Size)) @@ -81,7 +81,7 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf([]scw.Size{}), + reflect.TypeFor[[]scw.Size](), func(i any, _ *MarshalOpt) (string, error) { sizes := i.([]scw.Size) strs := []string(nil) @@ -97,19 +97,19 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(net.IP{}), + reflect.TypeFor[net.IP](), func(i any, _ *MarshalOpt) (string, error) { return fmt.Sprintf("%v", i.(net.IP)), nil }, ) marshalerFuncs.Store( - reflect.TypeOf([]net.IP{}), + reflect.TypeFor[[]net.IP](), func(i any, _ *MarshalOpt) (string, error) { return fmt.Sprintf("%v", i), nil }, ) marshalerFuncs.Store( - reflect.TypeOf(scw.IPNet{}), + reflect.TypeFor[scw.IPNet](), func(i any, _ *MarshalOpt) (string, error) { v := i.(scw.IPNet) str := v.String() @@ -121,7 +121,7 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(version.Version{}), + reflect.TypeFor[version.Version](), func(i any, _ *MarshalOpt) (string, error) { v := i.(version.Version) @@ -129,7 +129,7 @@ func init() { }, ) marshalerFuncs.Store( - reflect.TypeOf(scw.Duration{}), + reflect.TypeFor[scw.Duration](), func(i any, _ *MarshalOpt) (string, error) { v := i.(scw.Duration) const ( @@ -232,9 +232,9 @@ func isMarshalable(t reflect.Type) bool { return (t.Kind() != reflect.Struct && t.Kind() != reflect.Map && t.Kind() != reflect.Pointer) || hasMarshalerFunc || - t.Implements(reflect.TypeOf((*Marshaler)(nil)).Elem()) || - t.Implements(reflect.TypeOf((*error)(nil)).Elem()) || - t.Implements(reflect.TypeOf((*fmt.Stringer)(nil)).Elem()) || + t.Implements(reflect.TypeFor[Marshaler]()) || + t.Implements(reflect.TypeFor[error]()) || + t.Implements(reflect.TypeFor[fmt.Stringer]()) || (t.Kind() == reflect.Pointer && isMarshalable(t.Elem())) } diff --git a/core/validate_test.go b/core/validate_test.go index 977d7eda31..39a609c2d1 100644 --- a/core/validate_test.go +++ b/core/validate_test.go @@ -370,7 +370,7 @@ func Test_ValidateDeprecated(t *testing.T) { t.Run("Deprecated", core.Test(&core.TestConfig{ Commands: core.NewCommands(&core.Command{ Namespace: "plop", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{}, nil @@ -738,7 +738,7 @@ func Test_ValidateOneOf(t *testing.T) { t.Run("Simple one-of validation check", core.Test(&core.TestConfig{ Commands: core.NewCommands(&core.Command{ Namespace: "oneof", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{}, nil @@ -763,7 +763,7 @@ func Test_ValidateOneOf(t *testing.T) { core.Test(&core.TestConfig{ Commands: core.NewCommands(&core.Command{ Namespace: "oneof", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{}, nil @@ -792,7 +792,7 @@ func Test_ValidateOneOf(t *testing.T) { core.Test(&core.TestConfig{ Commands: core.NewCommands(&core.Command{ Namespace: "oneof", - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), AllowAnonymousClient: true, Run: func(_ context.Context, _ any) (i any, e error) { return &core.SuccessResult{}, nil diff --git a/internal/args/args_test.go b/internal/args/args_test.go index 78d51164e4..88df2a6ff2 100644 --- a/internal/args/args_test.go +++ b/internal/args/args_test.go @@ -193,47 +193,47 @@ func TestGetArgType(t *testing.T) { } t.Run("Simple", run(&TestCase{ - ArgType: reflect.TypeOf(&Basic{}), + ArgType: reflect.TypeFor[*Basic](), Name: "string", ExpectedKind: reflect.String, })) t.Run("Simple int", run(&TestCase{ - ArgType: reflect.TypeOf(&Basic{}), + ArgType: reflect.TypeFor[*Basic](), Name: "int-64", ExpectedKind: reflect.Int64, })) t.Run("Ptr", run(&TestCase{ - ArgType: reflect.TypeOf(&Basic{}), + ArgType: reflect.TypeFor[*Basic](), Name: "string-ptr", ExpectedKind: reflect.String, })) t.Run("simple slice", run(&TestCase{ - ArgType: reflect.TypeOf(&Slice{}), + ArgType: reflect.TypeFor[*Slice](), Name: "strings.{index}", ExpectedKind: reflect.String, })) t.Run("simple slice ptr", run(&TestCase{ - ArgType: reflect.TypeOf(&Slice{}), + ArgType: reflect.TypeFor[*Slice](), Name: "slice-ptr.{index}", ExpectedKind: reflect.String, })) t.Run("nested simple", run(&TestCase{ - ArgType: reflect.TypeOf(&Nested{}), + ArgType: reflect.TypeFor[*Nested](), Name: "basic.string", ExpectedKind: reflect.String, })) t.Run("nested empty", run(&TestCase{ - ArgType: reflect.TypeOf(&Nested{}), + ArgType: reflect.TypeFor[*Nested](), Name: "empty", ExpectedKind: reflect.Struct, })) t.Run("merge simple", run(&TestCase{ - ArgType: reflect.TypeOf(&Merge{}), + ArgType: reflect.TypeFor[*Merge](), Name: "merge1", ExpectedKind: reflect.String, })) t.Run("merge simple all", run(&TestCase{ - ArgType: reflect.TypeOf(&Merge{}), + ArgType: reflect.TypeFor[*Merge](), Name: "all", ExpectedKind: reflect.String, })) diff --git a/internal/args/marshal.go b/internal/args/marshal.go index 8baebf0f7a..98ff7da991 100644 --- a/internal/args/marshal.go +++ b/internal/args/marshal.go @@ -24,14 +24,14 @@ type Marshaler interface { type MarshalFunc func(src any) (string, error) var marshalFuncs = map[reflect.Type]MarshalFunc{ - reflect.TypeOf((*scw.Size)(nil)).Elem(): func(src any) (s string, e error) { + reflect.TypeFor[scw.Size](): func(src any) (s string, e error) { v := src.(*scw.Size) value := humanize.Bytes(uint64(*v)) value = strings.ReplaceAll(value, " ", "") return value, nil }, - reflect.TypeOf((*time.Time)(nil)).Elem(): func(src any) (string, error) { + reflect.TypeFor[time.Time](): func(src any) (string, error) { v := src.(*time.Time) return v.Format(time.RFC3339), nil diff --git a/internal/args/unmarshal.go b/internal/args/unmarshal.go index 3703826be3..b592e49f88 100644 --- a/internal/args/unmarshal.go +++ b/internal/args/unmarshal.go @@ -30,7 +30,7 @@ type UnmarshalFunc func(value string, dest any) error var TestForceNow *time.Time var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ - reflect.TypeOf((*scw.Size)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[scw.Size](): func(value string, dest any) error { // Only support G, GB for now (case insensitive). value = strings.ToLower(value) if !strings.HasSuffix(value, "g") && !strings.HasSuffix(value, "gb") { @@ -46,11 +46,11 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ return nil }, - reflect.TypeOf((*scw.IPNet)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[scw.IPNet](): func(value string, dest any) error { return dest.(*scw.IPNet).UnmarshalJSON([]byte(`"` + value + `"`)) }, - reflect.TypeOf((*net.IP)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[net.IP](): func(value string, dest any) error { ip := net.ParseIP(value) if ip == nil { return fmt.Errorf("%s is not a valid IP", value) @@ -60,13 +60,13 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ return nil }, - reflect.TypeOf((*io.Reader)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[io.Reader](): func(value string, dest any) error { *dest.(*io.Reader) = strings.NewReader(value) return nil }, - reflect.TypeOf((*time.Time)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[time.Time](): func(value string, dest any) error { // Handle absolute time absoluteTimeParsed, absoluteErr := time.Parse(time.RFC3339, value) if absoluteErr == nil { @@ -103,7 +103,7 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ } }, - reflect.TypeOf((*time.Duration)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[time.Duration](): func(value string, dest any) error { duration, err := time.ParseDuration(value) if err != nil { return fmt.Errorf("failed to parse duration: %w", err) @@ -112,7 +112,7 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ return nil }, - reflect.TypeOf((*scw.JSONObject)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[scw.JSONObject](): func(value string, dest any) error { jsonObject, err := scw.DecodeJSONObject(value, scw.NoEscape) if err != nil { return fmt.Errorf("failed to parse json object: %w", err) @@ -121,12 +121,12 @@ var unmarshalFuncs = map[reflect.Type]UnmarshalFunc{ return nil }, - reflect.TypeOf((*[]byte)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[[]byte](): func(value string, dest any) error { *dest.(*[]byte) = []byte(value) return nil }, - reflect.TypeOf((*scw.Duration)(nil)).Elem(): func(value string, dest any) error { + reflect.TypeFor[scw.Duration](): func(value string, dest any) error { duration, err := time.ParseDuration(value) if err != nil { return fmt.Errorf("failed to parse duration: %w", err) diff --git a/internal/editor/request_test.go b/internal/editor/request_test.go index 9f39178df8..fb92eecfa9 100644 --- a/internal/editor/request_test.go +++ b/internal/editor/request_test.go @@ -18,6 +18,6 @@ func Test_createGetResourceRequest(t *testing.T) { }{"uuid", ""} expectedRequest := &GetRequest{"uuid"} - actualRequest := editor.CreateGetRequest(updateRequest, reflect.TypeOf(GetRequest{})) + actualRequest := editor.CreateGetRequest(updateRequest, reflect.TypeFor[GetRequest]()) assert.Equal(t, expectedRequest, actualRequest) } diff --git a/internal/gofields/gofields_test.go b/internal/gofields/gofields_test.go index a2a5aac344..791e368928 100644 --- a/internal/gofields/gofields_test.go +++ b/internal/gofields/gofields_test.go @@ -166,58 +166,58 @@ func TestGetType(t *testing.T) { } t.Run("Simple", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Name", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("Nested", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Address.Zip", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("Slice", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Friends.0.Name", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("Map", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Pets.rex.Name", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("UnknownField", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Unknown", Expected: "field Unknown does not exist in $", })) t.Run("UnknownNestedField", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Address.Unknown", Expected: "field Unknown does not exist in $.Address", })) t.Run("InvalidSliceIndex", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Friends.NotANumber", Expected: "trying to access array $.Friends but NotANumber is not a numerical index", })) t.Run("OutOfRangeSliceIndex", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Friends.13.Name", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("UnknownMapKey", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Pets.unknown.Name", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("AnonymousField", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Pets.rex.Species", - Expected: reflect.TypeOf(""), + Expected: reflect.TypeFor[string](), })) t.Run("PrivateField", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Path: "Address.digicode", Expected: "field digicode is private in $.Address", })) @@ -238,7 +238,7 @@ func TestListFields(t *testing.T) { } t.Run("Simple", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Expected: []string{ "Name", "Address.Zip", @@ -265,7 +265,7 @@ func TestListFieldsWithFilter(t *testing.T) { } t.Run("Simple", run(&TestCase{ - Data: reflect.TypeOf(&User{}), + Data: reflect.TypeFor[*User](), Expected: []string{"Address.Zip"}, Filter: func(_ reflect.Type, s string) bool { return strings.Contains(s, "Zip") diff --git a/internal/namespaces/alias/alias.go b/internal/namespaces/alias/alias.go index 4b27618272..09c0d54a4b 100644 --- a/internal/namespaces/alias/alias.go +++ b/internal/namespaces/alias/alias.go @@ -87,7 +87,7 @@ func aliasCreateCommand() *core.Command { Short: "Command to create an alias for", }, }, - ArgsType: reflect.TypeOf(CreateRequest{}), + ArgsType: reflect.TypeFor[CreateRequest](), Run: func(ctx context.Context, argsI any) (any, error) { args := argsI.(*CreateRequest) cfg := core.ExtractCliConfig(ctx) @@ -180,7 +180,7 @@ func aliasListCommand() *core.Command { Short: "filter alias", }, }, - ArgsType: reflect.TypeOf(ListRequest{}), + ArgsType: reflect.TypeFor[ListRequest](), Run: func(ctx context.Context, argsI any) (any, error) { args := argsI.(*ListRequest) aliasCfg := core.ExtractAliases(ctx) @@ -232,7 +232,7 @@ func aliasDeleteCommand() *core.Command { Short: "alias name", }, }, - ArgsType: reflect.TypeOf(DeleteRequest{}), + ArgsType: reflect.TypeFor[DeleteRequest](), Run: func(ctx context.Context, argsI any) (any, error) { args := argsI.(*DeleteRequest) cfg := core.ExtractCliConfig(ctx) diff --git a/internal/namespaces/applesilicon/v1alpha1/custom_server.go b/internal/namespaces/applesilicon/v1alpha1/custom_server.go index 148a137b35..ba1f6f7a73 100644 --- a/internal/namespaces/applesilicon/v1alpha1/custom_server.go +++ b/internal/namespaces/applesilicon/v1alpha1/custom_server.go @@ -115,7 +115,7 @@ func serverWaitCommand() *core.Command { Resource: "server", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(customServerWaitArgs{}), + ArgsType: reflect.TypeFor[customServerWaitArgs](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*customServerWaitArgs) diff --git a/internal/namespaces/applesilicon/v1alpha1/custom_server_ssh.go b/internal/namespaces/applesilicon/v1alpha1/custom_server_ssh.go index ae821b3311..6aac5d106e 100644 --- a/internal/namespaces/applesilicon/v1alpha1/custom_server_ssh.go +++ b/internal/namespaces/applesilicon/v1alpha1/custom_server_ssh.go @@ -29,7 +29,7 @@ func serverSSHCommand() *core.Command { Verb: "ssh", Resource: "server", Groups: []string{"utility"}, - ArgsType: reflect.TypeOf(serverSSHConnectRequest{}), + ArgsType: reflect.TypeFor[serverSSHConnectRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/autocomplete/autocomplete.go b/internal/namespaces/autocomplete/autocomplete.go index da0df7378f..601d7d8317 100644 --- a/internal/namespaces/autocomplete/autocomplete.go +++ b/internal/namespaces/autocomplete/autocomplete.go @@ -161,7 +161,7 @@ func autocompleteInstallCommand() *core.Command { }, }, }, - ArgsType: reflect.TypeOf(InstallArgs{}), + ArgsType: reflect.TypeFor[InstallArgs](), Run: InstallCommandRun, } } @@ -289,7 +289,7 @@ func autocompleteCompleteBashCommand() *core.Command { AllowAnonymousClient: false, Hidden: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(ctx context.Context, argsI any) (i any, e error) { rawArgs := *argsI.(*args.RawArgs) if len(rawArgs) < 3 { @@ -336,7 +336,7 @@ func autocompleteCompleteFishCommand() *core.Command { AllowAnonymousClient: false, Hidden: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(ctx context.Context, argsI any) (i any, e error) { rawArgs := *argsI.(*args.RawArgs) if len(rawArgs) < 4 { @@ -374,7 +374,7 @@ func autocompleteCompleteZshCommand() *core.Command { AllowAnonymousClient: false, Hidden: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(ctx context.Context, argsI any) (i any, e error) { rawArgs := *argsI.(*args.RawArgs) if len(rawArgs) < 2 { @@ -438,7 +438,7 @@ func autocompleteScriptCommand() *core.Command { }, }, }, - ArgsType: reflect.TypeOf(autocompleteShowArgs{}), + ArgsType: reflect.TypeFor[autocompleteShowArgs](), Run: func(ctx context.Context, argsI any) (i any, e error) { shell := filepath.Base(argsI.(*autocompleteShowArgs).Shell) basename := argsI.(*autocompleteShowArgs).Basename diff --git a/internal/namespaces/baremetal/v1/custom_server.go b/internal/namespaces/baremetal/v1/custom_server.go index 62e64c8afe..02b4f0b40a 100644 --- a/internal/namespaces/baremetal/v1/custom_server.go +++ b/internal/namespaces/baremetal/v1/custom_server.go @@ -48,7 +48,7 @@ func serverWaitCommand() *core.Command { Resource: "server", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(serverWaitRequest{}), + ArgsType: reflect.TypeFor[serverWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*serverWaitRequest) diff --git a/internal/namespaces/baremetal/v1/custom_server_create.go b/internal/namespaces/baremetal/v1/custom_server_create.go index 19574fa9ad..25b3c17e0d 100644 --- a/internal/namespaces/baremetal/v1/custom_server_create.go +++ b/internal/namespaces/baremetal/v1/custom_server_create.go @@ -29,7 +29,7 @@ func serverCreateBuilder(c *core.Command) *core.Command { Install *baremetal.CreateServerRequestInstall } - c.ArgsType = reflect.TypeOf(baremetalCreateServerRequestCustom{}) + c.ArgsType = reflect.TypeFor[baremetalCreateServerRequestCustom]() c.ArgSpecs.DeleteByName("offer-id") diff --git a/internal/namespaces/baremetal/v1/custom_server_fip.go b/internal/namespaces/baremetal/v1/custom_server_fip.go index 955de8885e..a6e1e954a3 100644 --- a/internal/namespaces/baremetal/v1/custom_server_fip.go +++ b/internal/namespaces/baremetal/v1/custom_server_fip.go @@ -28,7 +28,7 @@ func serverAddFlexibleIP() *core.Command { Resource: "server", Verb: "add-flexible-ip", Groups: []string{"utility"}, - ArgsType: reflect.TypeOf(serverAddFlexibleIPRequest{}), + ArgsType: reflect.TypeFor[serverAddFlexibleIPRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/baremetal/v1/custom_server_install.go b/internal/namespaces/baremetal/v1/custom_server_install.go index 84b14e1305..edb15d9ee9 100644 --- a/internal/namespaces/baremetal/v1/custom_server_install.go +++ b/internal/namespaces/baremetal/v1/custom_server_install.go @@ -16,7 +16,7 @@ func serverInstallBuilder(c *core.Command) *core.Command { AllSSHKeys *bool } - c.ArgsType = reflect.TypeOf(baremetalInstallServerRequestCustom{}) + c.ArgsType = reflect.TypeFor[baremetalInstallServerRequestCustom]() c.ArgSpecs.AddBefore("ssh-key-ids.{index}", &core.ArgSpec{ Name: "all-ssh-keys", diff --git a/internal/namespaces/billing/v2beta1/custom_invoice_download.go b/internal/namespaces/billing/v2beta1/custom_invoice_download.go index 07ac19fe87..716f195ab1 100644 --- a/internal/namespaces/billing/v2beta1/custom_invoice_download.go +++ b/internal/namespaces/billing/v2beta1/custom_invoice_download.go @@ -26,7 +26,7 @@ type billingDownloadRequest struct { } func invoiceDownloadBuilder(command *core.Command) *core.Command { - command.ArgsType = reflect.TypeOf(billingDownloadRequest{}) + command.ArgsType = reflect.TypeFor[billingDownloadRequest]() command.ArgSpecs = core.ArgSpecs{ { Name: "invoice-id", diff --git a/internal/namespaces/billing/v2beta1/custom_invoice_export.go b/internal/namespaces/billing/v2beta1/custom_invoice_export.go index b8be63dd5c..b4bd75d521 100644 --- a/internal/namespaces/billing/v2beta1/custom_invoice_export.go +++ b/internal/namespaces/billing/v2beta1/custom_invoice_export.go @@ -24,7 +24,7 @@ type billingExportRequest struct { } func invoiceExportBuilder(command *core.Command) *core.Command { - command.ArgsType = reflect.TypeOf(billingExportRequest{}) + command.ArgsType = reflect.TypeFor[billingExportRequest]() command.ArgSpecs = core.ArgSpecs{ { Name: "organization-id", diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot.go b/internal/namespaces/block/v1alpha1/custom_snapshot.go index 8daddc27ed..8e220f2144 100644 --- a/internal/namespaces/block/v1alpha1/custom_snapshot.go +++ b/internal/namespaces/block/v1alpha1/custom_snapshot.go @@ -37,7 +37,7 @@ func snapshotWaitCommand() *core.Command { Resource: "snapshot", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(snapshotWaitRequest{}), + ArgsType: reflect.TypeFor[snapshotWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*snapshotWaitRequest) diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index 11705e9d87..5de41d02be 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -37,7 +37,7 @@ func volumeWaitCommand() *core.Command { Resource: "volume", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(volumeWaitRequest{}), + ArgsType: reflect.TypeFor[volumeWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*volumeWaitRequest) diff --git a/internal/namespaces/cockpit/v1/custom_config_get.go b/internal/namespaces/cockpit/v1/custom_config_get.go index 559327fcef..1549477127 100644 --- a/internal/namespaces/cockpit/v1/custom_config_get.go +++ b/internal/namespaces/cockpit/v1/custom_config_get.go @@ -60,7 +60,7 @@ Supported tools: Use generate-token=true to create a new Cockpit token and inject it directly in the snippet. The token is created with the minimum required write scope for the data source type.`, - ArgsType: reflect.TypeOf(cockpitConfigGetRequest{}), + ArgsType: reflect.TypeFor[cockpitConfigGetRequest](), ArgSpecs: core.ArgSpecs{ { Name: "data-source-id", diff --git a/internal/namespaces/config/commands.go b/internal/namespaces/config/commands.go index fd058f3230..4d35e6a3da 100644 --- a/internal/namespaces/config/commands.go +++ b/internal/namespaces/config/commands.go @@ -128,7 +128,7 @@ func configGetCommand() *core.Command { Namespace: "config", Resource: "get", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configGetArgs{}), + ArgsType: reflect.TypeFor[configGetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "key", @@ -191,7 +191,7 @@ The only allowed attributes are access_key, secret_key, default_organization_id, Namespace: "config", Resource: "set", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(scw.Profile{}), + ArgsType: reflect.TypeFor[scw.Profile](), ArgSpecs: core.ArgSpecs{ { Name: "access-key", @@ -347,7 +347,7 @@ func configUnsetCommand() *core.Command { Namespace: "config", Resource: "unset", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configUnsetArgs{}), + ArgsType: reflect.TypeFor[configUnsetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "key", @@ -397,7 +397,7 @@ func configDumpCommand() *core.Command { Namespace: "config", Resource: "dump", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configDumpArgs{}), + ArgsType: reflect.TypeFor[configDumpArgs](), SeeAlsos: []*core.SeeAlso{ { Short: "Config management help", @@ -487,7 +487,7 @@ func configDeleteProfileCommand() *core.Command { Resource: "profile", Verb: "delete", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configDeleteProfileArgs{}), + ArgsType: reflect.TypeFor[configDeleteProfileArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", @@ -532,7 +532,7 @@ func configActivateProfileCommand() *core.Command { Resource: "profile", Verb: "activate", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configActiveProfileArgs{}), + ArgsType: reflect.TypeFor[configActiveProfileArgs](), ArgSpecs: core.ArgSpecs{ { Name: "profile-name", @@ -580,7 +580,7 @@ func configResetCommand() *core.Command { Namespace: "config", Resource: "reset", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configResetArgs{}), + ArgsType: reflect.TypeFor[configResetArgs](), Run: func(_ context.Context, _ any) (i any, e error) { _, err := scw.LoadConfig() if err != nil { @@ -609,7 +609,7 @@ func configDestroyCommand() *core.Command { Namespace: "config", Resource: "destroy", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configDestroyArgs{}), + ArgsType: reflect.TypeFor[configDestroyArgs](), Run: func(ctx context.Context, _ any) (i any, e error) { configPath := core.ExtractConfigPath(ctx) err := os.Remove(configPath) @@ -634,7 +634,7 @@ func configInfoCommand() *core.Command { Namespace: "config", Resource: "info", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configInfoArgs{}), + ArgsType: reflect.TypeFor[configInfoArgs](), ArgSpecs: core.ArgSpecs{}, Examples: []*core.Example{ { @@ -720,7 +720,7 @@ func configImportCommand() *core.Command { Namespace: "config", Resource: "import", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configImportArgs{}), + ArgsType: reflect.TypeFor[configImportArgs](), ArgSpecs: core.ArgSpecs{ { Name: "file", @@ -792,7 +792,7 @@ The command goes through each profile present in the config file and validates i Namespace: "config", Resource: "validate", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(configValidateArgs{}), + ArgsType: reflect.TypeFor[configValidateArgs](), Run: func(ctx context.Context, _ any) (i any, e error) { configPath := core.ExtractConfigPath(ctx) config, err := scw.LoadConfigFromPath(configPath) @@ -828,7 +828,7 @@ func configEditCommand() *core.Command { Resource: "edit", Short: "Edit the configuration file", Long: "Edit the configuration file with the default editor", - ArgsType: reflect.TypeOf(configEditArgs{}), + ArgsType: reflect.TypeFor[configEditArgs](), AllowAnonymousClient: true, Run: func(ctx context.Context, _ any) (i any, e error) { configPath := core.ExtractConfigPath(ctx) @@ -882,7 +882,7 @@ func getProfileField(profile *scw.Profile, key string) (reflect.Value, error) { } func getProfileKeys() []string { - t := reflect.TypeOf(scw.Profile{}) + t := reflect.TypeFor[scw.Profile]() keys := []string{} for field := range t.Fields() { switch field.Name { diff --git a/internal/namespaces/container/v1/custom_deploy.go b/internal/namespaces/container/v1/custom_deploy.go index d9f60eb811..d9713f00e7 100644 --- a/internal/namespaces/container/v1/custom_deploy.go +++ b/internal/namespaces/container/v1/custom_deploy.go @@ -59,7 +59,7 @@ func containerDeployCommand() *core.Command { Namespace: "container", Resource: "deploy", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(containerDeployRequest{}), + ArgsType: reflect.TypeFor[containerDeployRequest](), ArgSpecs: core.ArgSpecs{ { Name: "name", diff --git a/internal/namespaces/container/v1/custom_logs.go b/internal/namespaces/container/v1/custom_logs.go index 35ad1e6c13..0452059c23 100644 --- a/internal/namespaces/container/v1/custom_logs.go +++ b/internal/namespaces/container/v1/custom_logs.go @@ -32,7 +32,7 @@ func containerLogs() *core.Command { Resource: "container", Verb: "logs", Groups: []string{"utility"}, - ArgsType: reflect.TypeOf(containerLogsRequest{}), + ArgsType: reflect.TypeFor[containerLogsRequest](), ArgSpecs: core.ArgSpecs{ { Name: "container-id", diff --git a/internal/namespaces/domain/v2beta1/custom_record_add.go b/internal/namespaces/domain/v2beta1/custom_record_add.go index af748b47c4..4c8d31fb95 100644 --- a/internal/namespaces/domain/v2beta1/custom_record_add.go +++ b/internal/namespaces/domain/v2beta1/custom_record_add.go @@ -20,7 +20,7 @@ func dnsRecordAddCommand() *core.Command { Namespace: "dns", Verb: "add", Resource: "record", - ArgsType: reflect.TypeOf(dnsRecordAddRequest{}), + ArgsType: reflect.TypeFor[dnsRecordAddRequest](), ArgSpecs: core.ArgSpecs{ { Name: "dns-zone", diff --git a/internal/namespaces/domain/v2beta1/custom_record_delete.go b/internal/namespaces/domain/v2beta1/custom_record_delete.go index d730dcef56..9723ce52e8 100644 --- a/internal/namespaces/domain/v2beta1/custom_record_delete.go +++ b/internal/namespaces/domain/v2beta1/custom_record_delete.go @@ -23,7 +23,7 @@ func dnsRecordDeleteCommand() *core.Command { Namespace: "dns", Verb: "delete", Resource: "record", - ArgsType: reflect.TypeOf(dnsRecordDeleteRequest{}), + ArgsType: reflect.TypeFor[dnsRecordDeleteRequest](), ArgSpecs: core.ArgSpecs{ { Name: "dns-zone", diff --git a/internal/namespaces/domain/v2beta1/custom_record_set.go b/internal/namespaces/domain/v2beta1/custom_record_set.go index 6590d40499..6e3ce1e553 100644 --- a/internal/namespaces/domain/v2beta1/custom_record_set.go +++ b/internal/namespaces/domain/v2beta1/custom_record_set.go @@ -23,7 +23,7 @@ func dnsRecordSetCommand() *core.Command { Namespace: "dns", Verb: "set", Resource: "record", - ArgsType: reflect.TypeOf(dnsRecordSetRequest{}), + ArgsType: reflect.TypeFor[dnsRecordSetRequest](), ArgSpecs: core.ArgSpecs{ { Name: "dns-zone", diff --git a/internal/namespaces/edge_services/v1beta1/custom_route_rules.go b/internal/namespaces/edge_services/v1beta1/custom_route_rules.go index 5ef3426077..064e551557 100644 --- a/internal/namespaces/edge_services/v1beta1/custom_route_rules.go +++ b/internal/namespaces/edge_services/v1beta1/custom_route_rules.go @@ -61,7 +61,7 @@ Otherwise, opens the editor with full rules including backend_stage_id for each Namespace: "edge-services", Resource: "route-rules", Verb: "edit", - ArgsType: reflect.TypeOf(edgeServicesRouteRulesEditArgs{}), + ArgsType: reflect.TypeFor[edgeServicesRouteRulesEditArgs](), ArgSpecs: core.ArgSpecs{ { Name: "route-stage-id", diff --git a/internal/namespaces/function/v1beta1/custom_deploy.go b/internal/namespaces/function/v1beta1/custom_deploy.go index 9d79b80f87..819fbb7a3e 100644 --- a/internal/namespaces/function/v1beta1/custom_deploy.go +++ b/internal/namespaces/function/v1beta1/custom_deploy.go @@ -33,7 +33,7 @@ func functionDeploy() *core.Command { Namespace: "function", Resource: "deploy", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(functionDeployRequest{}), + ArgsType: reflect.TypeFor[functionDeployRequest](), ArgSpecs: []*core.ArgSpec{ { Name: "namespace-id", diff --git a/internal/namespaces/iam/v1alpha1/custom.go b/internal/namespaces/iam/v1alpha1/custom.go index d706e7a580..034124b81b 100644 --- a/internal/namespaces/iam/v1alpha1/custom.go +++ b/internal/namespaces/iam/v1alpha1/custom.go @@ -71,7 +71,7 @@ func initWithSSHCommand() *core.Command { Resource: "ssh-key", Verb: "init", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), ArgSpecs: core.ArgSpecs{}, Run: InitWithSSHKeyRun, ExcludeFromMCP: true, diff --git a/internal/namespaces/iam/v1alpha1/custom_iam.go b/internal/namespaces/iam/v1alpha1/custom_iam.go index 8aedda1208..d30567c585 100644 --- a/internal/namespaces/iam/v1alpha1/custom_iam.go +++ b/internal/namespaces/iam/v1alpha1/custom_iam.go @@ -208,7 +208,7 @@ var iamApiKeyCustomBuilder = struct { Positional: false, }, }, - argType: reflect.TypeOf(iamGetAPIKeyArgs{}), + argType: reflect.TypeFor[iamGetAPIKeyArgs](), run: func(ctx context.Context, args any) (i any, e error) { arguments := args.(*iamGetAPIKeyArgs) diff --git a/internal/namespaces/iam/v1alpha1/custom_rule.go b/internal/namespaces/iam/v1alpha1/custom_rule.go index 3f0545fd9b..db9cbf90bb 100644 --- a/internal/namespaces/iam/v1alpha1/custom_rule.go +++ b/internal/namespaces/iam/v1alpha1/custom_rule.go @@ -21,7 +21,7 @@ func iamRuleCreateCommand() *core.Command { Resource: "rule", Verb: "create", Short: "Create a rule for a specific IAM policy", - ArgsType: reflect.TypeOf(iamRuleCreateCommandRequest{}), + ArgsType: reflect.TypeFor[iamRuleCreateCommandRequest](), ArgSpecs: core.ArgSpecs{ { Name: "policy-id", @@ -99,7 +99,7 @@ func iamRuleDeleteCommand() *core.Command { Resource: "rule", Verb: "delete", Short: "Delete a rule for a specific IAM policy", - ArgsType: reflect.TypeOf(iamRuleDeleteCommandRequest{}), + ArgsType: reflect.TypeFor[iamRuleDeleteCommandRequest](), ArgSpecs: core.ArgSpecs{ { Name: "policy-id", diff --git a/internal/namespaces/inference/v1/custom_deployment.go b/internal/namespaces/inference/v1/custom_deployment.go index 501c925b57..de454a7468 100644 --- a/internal/namespaces/inference/v1/custom_deployment.go +++ b/internal/namespaces/inference/v1/custom_deployment.go @@ -71,7 +71,7 @@ func deploymentCreateBuilder(c *core.Command) *core.Command { Default: core.DefaultValueSetter("true"), }) - c.ArgsType = reflect.TypeOf(llmInferenceCreateDeploymentRequestCustom{}) + c.ArgsType = reflect.TypeFor[llmInferenceCreateDeploymentRequestCustom]() c.WaitFunc = waitForDeploymentFunc(deploymentActionCreate) diff --git a/internal/namespaces/info/custom.go b/internal/namespaces/info/custom.go index 477783ecc5..0c03d856e8 100644 --- a/internal/namespaces/info/custom.go +++ b/internal/namespaces/info/custom.go @@ -60,7 +60,7 @@ func infosRoot() *core.Command { Short: `Get info about current settings`, Namespace: "info", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(infoArgs{}), + ArgsType: reflect.TypeFor[infoArgs](), ArgSpecs: core.ArgSpecs{ { Name: "show-secret", diff --git a/internal/namespaces/init/init.go b/internal/namespaces/init/init.go index 2e2294ffcf..1d7b9df4d0 100644 --- a/internal/namespaces/init/init.go +++ b/internal/namespaces/init/init.go @@ -83,7 +83,7 @@ Default path for configuration file is based on the following priority order: - $USERPROFILE/.config/scw/config.yaml`, Namespace: "init", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(Args{}), + ArgsType: reflect.TypeFor[Args](), ArgSpecs: core.ArgSpecs{ { Name: "secret-key", diff --git a/internal/namespaces/instance/v1/custom_image.go b/internal/namespaces/instance/v1/custom_image.go index 9533c698c2..d5c1bc78ba 100644 --- a/internal/namespaces/instance/v1/custom_image.go +++ b/internal/namespaces/instance/v1/custom_image.go @@ -126,7 +126,7 @@ func imageCreateBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customCreateImageRequest{}) + c.ArgsType = reflect.TypeFor[customCreateImageRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -179,7 +179,7 @@ func imageListBuilder(c *core.Command) *core.Command { renameProjectIDArgSpec(c.ArgSpecs) c.ArgSpecs.DeleteByName("public") - c.ArgsType = reflect.TypeOf(customListImageRequest{}) + c.ArgsType = reflect.TypeFor[customListImageRequest]() c.Run = func(ctx context.Context, argsI any) (i any, e error) { // Get images @@ -282,7 +282,7 @@ func imageDeleteBuilder(c *core.Command) *core.Command { WithSnapshots bool } - c.ArgsType = reflect.TypeOf(customDeleteImageRequest{}) + c.ArgsType = reflect.TypeFor[customDeleteImageRequest]() c.ArgSpecs.AddBefore("zone", &core.ArgSpec{ Name: "with-snapshots", Short: "Delete the snapshots attached to this image", @@ -382,7 +382,7 @@ func imageWaitCommand() *core.Command { Resource: "image", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(instance.WaitForImageRequest{}), + ArgsType: reflect.TypeFor[instance.WaitForImageRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := instance.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/instance/v1/custom_ip.go b/internal/namespaces/instance/v1/custom_ip.go index d6cf2bc494..a69e6b6d89 100644 --- a/internal/namespaces/instance/v1/custom_ip.go +++ b/internal/namespaces/instance/v1/custom_ip.go @@ -25,7 +25,7 @@ func ipCreateBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customCreateIPRequest{}) + c.ArgsType = reflect.TypeFor[customCreateIPRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -55,7 +55,7 @@ func ipListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListIPsRequest{}) + c.ArgsType = reflect.TypeFor[customListIPsRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -91,7 +91,7 @@ func ipAttachCommand() *core.Command { Namespace: "instance", Resource: "ip", Verb: "attach", - ArgsType: reflect.TypeOf(customIPAttachRequest{}), + ArgsType: reflect.TypeFor[customIPAttachRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := instance.NewAPI(core.ExtractClient(ctx)) args := argsI.(*customIPAttachRequest) @@ -141,7 +141,7 @@ func ipDetachCommand() *core.Command { Namespace: "instance", Resource: "ip", Verb: "detach", - ArgsType: reflect.TypeOf(customIPDetachRequest{}), + ArgsType: reflect.TypeFor[customIPDetachRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*customIPDetachRequest) api := instance.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/instance/v1/custom_placement_group.go b/internal/namespaces/instance/v1/custom_placement_group.go index 790ef4b64f..5b4116f10b 100644 --- a/internal/namespaces/instance/v1/custom_placement_group.go +++ b/internal/namespaces/instance/v1/custom_placement_group.go @@ -62,7 +62,7 @@ func placementGroupCreateBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customCreatePlacementGroupRequest{}) + c.ArgsType = reflect.TypeFor[customCreatePlacementGroupRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -93,7 +93,7 @@ func placementGroupListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListPlacementGroupsRequest{}) + c.ArgsType = reflect.TypeFor[customListPlacementGroupsRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { diff --git a/internal/namespaces/instance/v1/custom_security_group.go b/internal/namespaces/instance/v1/custom_security_group.go index 4c1509e145..efb27ee0b3 100644 --- a/internal/namespaces/instance/v1/custom_security_group.go +++ b/internal/namespaces/instance/v1/custom_security_group.go @@ -205,7 +205,7 @@ func securityGroupCreateBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customCreateSecurityGroupRequest{}) + c.ArgsType = reflect.TypeFor[customCreateSecurityGroupRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -267,7 +267,7 @@ func securityGroupListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListSecurityGroupsRequest{}) + c.ArgsType = reflect.TypeFor[customListSecurityGroupsRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -353,7 +353,7 @@ func securityGroupClearCommand() *core.Command { Namespace: "instance", Resource: "security-group", Verb: "clear", - ArgsType: reflect.TypeOf(instanceResetSecurityGroupArgs{}), + ArgsType: reflect.TypeFor[instanceResetSecurityGroupArgs](), Examples: []*core.Example{ { Short: "Remove all rules of the given security group", @@ -432,7 +432,7 @@ func securityGroupEditCommand() *core.Command { Namespace: "instance", Resource: "security-group", Verb: "edit", - ArgsType: reflect.TypeOf(instanceSecurityGroupEditArgs{}), + ArgsType: reflect.TypeFor[instanceSecurityGroupEditArgs](), ArgSpecs: core.ArgSpecs{ { Name: "security-group-id", diff --git a/internal/namespaces/instance/v1/custom_server.go b/internal/namespaces/instance/v1/custom_server.go index 1dd8280c93..2855f6586b 100644 --- a/internal/namespaces/instance/v1/custom_server.go +++ b/internal/namespaces/instance/v1/custom_server.go @@ -180,7 +180,7 @@ func serverListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListServersRequest{}) + c.ArgsType = reflect.TypeFor[customListServersRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -211,7 +211,7 @@ func serverUpdateBuilder(c *core.Command) *core.Command { CloudInit string } - c.ArgsType = reflect.TypeOf(instanceUpdateServerRequestCustom{}) + c.ArgsType = reflect.TypeFor[instanceUpdateServerRequestCustom]() // Add completion functions c.ArgSpecs.GetByName("admin-password-encryption-ssh-key-id").AutoCompleteFunc = completeSSHKeyID @@ -638,7 +638,7 @@ func serverAttachIPCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "attach-ip", - ArgsType: reflect.TypeOf(customIPAttachRequest{}), + ArgsType: reflect.TypeFor[customIPAttachRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", @@ -718,7 +718,7 @@ func serverDetachIPCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "detach-ip", - ArgsType: reflect.TypeOf(customIPDetachRequest{}), + ArgsType: reflect.TypeFor[customIPDetachRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", @@ -785,7 +785,7 @@ func serverWaitCommand() *core.Command { Resource: "server", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(serverWaitRequest{}), + ArgsType: reflect.TypeFor[serverWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*serverWaitRequest) diff --git a/internal/namespaces/instance/v1/custom_server_action.go b/internal/namespaces/instance/v1/custom_server_action.go index 4fcecdaf7b..f30e282262 100644 --- a/internal/namespaces/instance/v1/custom_server_action.go +++ b/internal/namespaces/instance/v1/custom_server_action.go @@ -21,7 +21,7 @@ func serverStartCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "start", - ArgsType: reflect.TypeOf(instanceUniqueActionRequest{}), + ArgsType: reflect.TypeFor[instanceUniqueActionRequest](), Run: getRunServerAction(instance.ServerActionPoweron), WaitFunc: waitForServerFunc(), ArgSpecs: serverActionArgSpecs, @@ -44,7 +44,7 @@ func serverStopCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "stop", - ArgsType: reflect.TypeOf(instanceUniqueActionRequest{}), + ArgsType: reflect.TypeFor[instanceUniqueActionRequest](), Run: getRunServerAction(instance.ServerActionPoweroff), WaitFunc: waitForServerFunc(), ArgSpecs: serverActionArgSpecs, @@ -67,7 +67,7 @@ func serverStandbyCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "standby", - ArgsType: reflect.TypeOf(instanceUniqueActionRequest{}), + ArgsType: reflect.TypeFor[instanceUniqueActionRequest](), Run: getRunServerAction(instance.ServerActionStopInPlace), WaitFunc: waitForServerFunc(), ArgSpecs: serverActionArgSpecs, @@ -90,7 +90,7 @@ func serverRebootCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "reboot", - ArgsType: reflect.TypeOf(instanceUniqueActionRequest{}), + ArgsType: reflect.TypeFor[instanceUniqueActionRequest](), Run: getRunServerAction(instance.ServerActionReboot), WaitFunc: waitForServerFunc(), ArgSpecs: serverActionArgSpecs, @@ -117,7 +117,7 @@ https://www.scaleway.com/en/docs/compute/instances/api-cli/using-ip-mobility/ Namespace: "instance", Resource: "server", Verb: "enable-routed-ip", - ArgsType: reflect.TypeOf(instanceUniqueActionRequest{}), + ArgsType: reflect.TypeFor[instanceUniqueActionRequest](), Run: getRunServerAction("enable_routed_ip"), WaitFunc: waitForServerFunc(), ArgSpecs: serverActionArgSpecs, @@ -151,7 +151,7 @@ Once your image is ready you will be able to create a new server based on this i Namespace: "instance", Resource: "server", Verb: "backup", - ArgsType: reflect.TypeOf(instanceBackupRequest{}), + ArgsType: reflect.TypeFor[instanceBackupRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*instanceBackupRequest) @@ -263,7 +263,7 @@ func serverTerminateCommand() *core.Command { Namespace: "instance", Verb: "terminate", Resource: "server", - ArgsType: reflect.TypeOf(customTerminateServerRequest{}), + ArgsType: reflect.TypeFor[customTerminateServerRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", @@ -590,7 +590,7 @@ func serverActionCommand() *core.Command { Namespace: "instance", Resource: "server", Verb: "action", - ArgsType: reflect.TypeOf(instanceActionRequest{}), + ArgsType: reflect.TypeFor[instanceActionRequest](), Run: func(ctx context.Context, argsI any) (any, error) { args := argsI.(*instanceActionRequest) diff --git a/internal/namespaces/instance/v1/custom_server_console.go b/internal/namespaces/instance/v1/custom_server_console.go index 28458523f0..a20e359e34 100644 --- a/internal/namespaces/instance/v1/custom_server_console.go +++ b/internal/namespaces/instance/v1/custom_server_console.go @@ -29,7 +29,7 @@ func serverConsoleCommand() *core.Command { Namespace: "instance", Verb: "console", Resource: "server", - ArgsType: reflect.TypeOf(instanceConsoleServerArgs{}), + ArgsType: reflect.TypeFor[instanceConsoleServerArgs](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/instance/v1/custom_server_create.go b/internal/namespaces/instance/v1/custom_server_create.go index 2776b3034a..2e24b2c920 100644 --- a/internal/namespaces/instance/v1/custom_server_create.go +++ b/internal/namespaces/instance/v1/custom_server_create.go @@ -55,7 +55,7 @@ func serverCreateCommand() *core.Command { Namespace: "instance", Verb: "create", Resource: "server", - ArgsType: reflect.TypeOf(instanceCreateServerRequest{}), + ArgsType: reflect.TypeFor[instanceCreateServerRequest](), ArgSpecs: core.ArgSpecs{ { Name: "image", diff --git a/internal/namespaces/instance/v1/custom_server_delete.go b/internal/namespaces/instance/v1/custom_server_delete.go index 3191ff608b..eeb796b7d7 100644 --- a/internal/namespaces/instance/v1/custom_server_delete.go +++ b/internal/namespaces/instance/v1/custom_server_delete.go @@ -41,7 +41,7 @@ func serverDeleteCommand() *core.Command { Namespace: "instance", Verb: "delete", Resource: "server", - ArgsType: reflect.TypeOf(customDeleteServerRequest{}), + ArgsType: reflect.TypeFor[customDeleteServerRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/instance/v1/custom_server_rdp.go b/internal/namespaces/instance/v1/custom_server_rdp.go index 3fe86664c9..7db62819d8 100644 --- a/internal/namespaces/instance/v1/custom_server_rdp.go +++ b/internal/namespaces/instance/v1/custom_server_rdp.go @@ -38,7 +38,7 @@ func instanceServerGetRdpPassword() *core.Command { Namespace: "instance", Verb: "get-rdp-password", Resource: "server", - ArgsType: reflect.TypeOf(instanceServerGetRdpPasswordRequest{}), + ArgsType: reflect.TypeFor[instanceServerGetRdpPasswordRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/instance/v1/custom_server_ssh.go b/internal/namespaces/instance/v1/custom_server_ssh.go index 46bd65e9f0..30ce8ae5ee 100644 --- a/internal/namespaces/instance/v1/custom_server_ssh.go +++ b/internal/namespaces/instance/v1/custom_server_ssh.go @@ -28,7 +28,7 @@ func serverSSHCommand() *core.Command { Namespace: "instance", Verb: "ssh", Resource: "server", - ArgsType: reflect.TypeOf(instanceSSHServerRequest{}), + ArgsType: reflect.TypeFor[instanceSSHServerRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/instance/v1/custom_snapshot.go b/internal/namespaces/instance/v1/custom_snapshot.go index 79f1c9de52..e63abd3b80 100644 --- a/internal/namespaces/instance/v1/custom_snapshot.go +++ b/internal/namespaces/instance/v1/custom_snapshot.go @@ -31,7 +31,7 @@ func snapshotCreateBuilder(c *core.Command) *core.Command { Short: "Whether a snapshot is unified or not.", }) - c.ArgsType = reflect.TypeOf(customCreateSnapshotRequest{}) + c.ArgsType = reflect.TypeFor[customCreateSnapshotRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -91,7 +91,7 @@ func snapshotListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListSnapshotsRequest{}) + c.ArgsType = reflect.TypeFor[customListSnapshotsRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -120,7 +120,7 @@ func snapshotWaitCommand() *core.Command { Resource: "snapshot", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(instance.WaitForSnapshotRequest{}), + ArgsType: reflect.TypeFor[instance.WaitForSnapshotRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := instance.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/instance/v1/custom_ssh_config.go b/internal/namespaces/instance/v1/custom_ssh_config.go index 4834835ba4..918601c5f7 100644 --- a/internal/namespaces/instance/v1/custom_ssh_config.go +++ b/internal/namespaces/instance/v1/custom_ssh_config.go @@ -49,7 +49,7 @@ func sshConfigInstallCommand() *core.Command { Short: `Install a ssh config with all your servers as host It generate hosts for instance servers, baremetal, apple-silicon and bastions`, Long: "Path of the config will be $HOME/.ssh/scaleway.config", - ArgsType: reflect.TypeOf(sshConfigInstallRequest{}), + ArgsType: reflect.TypeFor[sshConfigInstallRequest](), ArgSpecs: core.ArgSpecs{ core.ProjectIDArgSpec(), core.ZoneArgSpec(availableZones...), diff --git a/internal/namespaces/instance/v1/custom_ssh_key.go b/internal/namespaces/instance/v1/custom_ssh_key.go index ea2e46452e..e6e97a724c 100644 --- a/internal/namespaces/instance/v1/custom_ssh_key.go +++ b/internal/namespaces/instance/v1/custom_ssh_key.go @@ -82,7 +82,7 @@ func sshAddKeyCommand() *core.Command { Key is expected in openssh format "(format) (key) (comment)". The comment will be used as key name or generated Lookup /root/.ssh/authorized_keys on your server for more information`, - ArgsType: reflect.TypeOf(sshAddKeyRequest{}), + ArgsType: reflect.TypeFor[sshAddKeyRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", @@ -151,7 +151,7 @@ func sshFetchKeysCommand() *core.Command { The command 'ssh -t -l scw-fetch-ssh-keys --upgrade' will be run on the servers matching the zone and project filters. Keep in mind that you need to be able to connect to your server with another key than the one you want to add. Keep in mind that SSH keys are scoped by project.`, - ArgsType: reflect.TypeOf(sshFetchKeysRequest{}), + ArgsType: reflect.TypeFor[sshFetchKeysRequest](), ArgSpecs: core.ArgSpecs{ { Name: "project-id", @@ -253,7 +253,7 @@ func sshListKeysCommand() *core.Command { Long: `List only keys added manually to a server using tags. The key comment is used as key name or generated Lookup /root/.ssh/authorized_keys on your server for more information`, - ArgsType: reflect.TypeOf(sshListKeysRequest{}), + ArgsType: reflect.TypeFor[sshListKeysRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", @@ -306,7 +306,7 @@ func sshRemoveKeyCommand() *core.Command { Long: `Key will be remove from server's tags and removed from root user on next restart. Keys are identified by their comment as in openssh format. Lookup /root/.ssh/authorized_keys on your server for more information`, - ArgsType: reflect.TypeOf(sshRemoveKeyRequest{}), + ArgsType: reflect.TypeFor[sshRemoveKeyRequest](), ArgSpecs: core.ArgSpecs{ { Name: "server-id", diff --git a/internal/namespaces/instance/v1/custom_volume.go b/internal/namespaces/instance/v1/custom_volume.go index bc7f104c27..87e52c6bfc 100644 --- a/internal/namespaces/instance/v1/custom_volume.go +++ b/internal/namespaces/instance/v1/custom_volume.go @@ -53,7 +53,7 @@ func volumeCreateBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customCreateVolumeRequest{}) + c.ArgsType = reflect.TypeFor[customCreateVolumeRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -84,7 +84,7 @@ func volumeListBuilder(c *core.Command) *core.Command { renameOrganizationIDArgSpec(c.ArgSpecs) renameProjectIDArgSpec(c.ArgSpecs) - c.ArgsType = reflect.TypeOf(customListVolumesRequest{}) + c.ArgsType = reflect.TypeFor[customListVolumesRequest]() c.AddInterceptors( func(ctx context.Context, argsI any, runner core.CommandRunner) (i any, err error) { @@ -119,7 +119,7 @@ func volumeWaitCommand() *core.Command { Resource: "volume", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(volumeWaitRequest{}), + ArgsType: reflect.TypeFor[volumeWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*volumeWaitRequest) diff --git a/internal/namespaces/jobs/v1alpha2/custom_job_run.go b/internal/namespaces/jobs/v1alpha2/custom_job_run.go index fe64717eb1..5bc7ec5426 100644 --- a/internal/namespaces/jobs/v1alpha2/custom_job_run.go +++ b/internal/namespaces/jobs/v1alpha2/custom_job_run.go @@ -17,7 +17,7 @@ func jobsRunWait() *core.Command { Resource: "run", Verb: "wait", // Deprecated: false, - ArgsType: reflect.TypeOf(jobs.WaitForJobRunRequest{}), + ArgsType: reflect.TypeFor[jobs.WaitForJobRunRequest](), ArgSpecs: core.ArgSpecs{ { Name: "job-run-id", diff --git a/internal/namespaces/k8s/v1/custom_cluster.go b/internal/namespaces/k8s/v1/custom_cluster.go index af899139df..d1b4ae166d 100644 --- a/internal/namespaces/k8s/v1/custom_cluster.go +++ b/internal/namespaces/k8s/v1/custom_cluster.go @@ -375,7 +375,7 @@ func k8sClusterWaitCommand() *core.Command { Resource: "cluster", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(customClusterWaitArgs{}), + ArgsType: reflect.TypeFor[customClusterWaitArgs](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*customClusterWaitArgs) diff --git a/internal/namespaces/k8s/v1/custom_kubeconfig_get.go b/internal/namespaces/k8s/v1/custom_kubeconfig_get.go index 7631984fff..712a911dde 100644 --- a/internal/namespaces/k8s/v1/custom_kubeconfig_get.go +++ b/internal/namespaces/k8s/v1/custom_kubeconfig_get.go @@ -24,7 +24,7 @@ func k8sKubeconfigGetCommand() *core.Command { Namespace: "k8s", Verb: "get", Resource: "kubeconfig", - ArgsType: reflect.TypeOf(k8sKubeconfigGetRequest{}), + ArgsType: reflect.TypeFor[k8sKubeconfigGetRequest](), ArgSpecs: core.ArgSpecs{ { Name: "cluster-id", diff --git a/internal/namespaces/k8s/v1/custom_kubeconfig_install.go b/internal/namespaces/k8s/v1/custom_kubeconfig_install.go index 09656c29b6..691c6a34ea 100644 --- a/internal/namespaces/k8s/v1/custom_kubeconfig_install.go +++ b/internal/namespaces/k8s/v1/custom_kubeconfig_install.go @@ -32,7 +32,7 @@ It will merge the new kubeconfig in the file pointed by the KUBECONFIG variable. Namespace: "k8s", Verb: "install", Resource: "kubeconfig", - ArgsType: reflect.TypeOf(k8sKubeconfigInstallRequest{}), + ArgsType: reflect.TypeFor[k8sKubeconfigInstallRequest](), ArgSpecs: core.ArgSpecs{ { Name: "cluster-id", diff --git a/internal/namespaces/k8s/v1/custom_kubeconfig_uninstall.go b/internal/namespaces/k8s/v1/custom_kubeconfig_uninstall.go index 658cab40b8..f1523a6ce9 100644 --- a/internal/namespaces/k8s/v1/custom_kubeconfig_uninstall.go +++ b/internal/namespaces/k8s/v1/custom_kubeconfig_uninstall.go @@ -23,7 +23,7 @@ If the current context points to this cluster, it will be set to an empty contex Namespace: "k8s", Verb: "uninstall", Resource: "kubeconfig", - ArgsType: reflect.TypeOf(k8sKubeconfigUninstallRequest{}), + ArgsType: reflect.TypeFor[k8sKubeconfigUninstallRequest](), ArgSpecs: core.ArgSpecs{ { Name: "cluster-id", diff --git a/internal/namespaces/k8s/v1/custom_node.go b/internal/namespaces/k8s/v1/custom_node.go index 95d7269695..ed1cf95acc 100644 --- a/internal/namespaces/k8s/v1/custom_node.go +++ b/internal/namespaces/k8s/v1/custom_node.go @@ -59,7 +59,7 @@ func k8sNodeWaitCommand() *core.Command { Resource: "node", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(k8s.WaitForNodeRequest{}), + ArgsType: reflect.TypeFor[k8s.WaitForNodeRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := k8s.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/k8s/v1/custom_pool.go b/internal/namespaces/k8s/v1/custom_pool.go index 6435e57da3..5a6d821940 100644 --- a/internal/namespaces/k8s/v1/custom_pool.go +++ b/internal/namespaces/k8s/v1/custom_pool.go @@ -144,7 +144,7 @@ func k8sPoolWaitCommand() *core.Command { Resource: "pool", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(k8s.WaitForPoolRequest{}), + ArgsType: reflect.TypeFor[k8s.WaitForPoolRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := k8s.NewAPI(core.ExtractClient(ctx)) @@ -190,7 +190,7 @@ Keep in mind that your external node needs to have wget in order to download the Namespace: "k8s", Resource: "pool", Verb: "add-external-node", - ArgsType: reflect.TypeOf(k8sPoolAddExternalNodeRequest{}), + ArgsType: reflect.TypeFor[k8sPoolAddExternalNodeRequest](), ArgSpecs: core.ArgSpecs{ { Name: "node-ip", diff --git a/internal/namespaces/k8s/v1/custom_pool_labels.go b/internal/namespaces/k8s/v1/custom_pool_labels.go index 5acd59b456..512011e62b 100644 --- a/internal/namespaces/k8s/v1/custom_pool_labels.go +++ b/internal/namespaces/k8s/v1/custom_pool_labels.go @@ -24,7 +24,7 @@ func k8sPoolSetLabelCommand() *core.Command { Resource: "pool", Verb: "set-label", Groups: []string{"label"}, - ArgsType: reflect.TypeOf(k8sPoolSetLabelRequest{}), + ArgsType: reflect.TypeFor[k8sPoolSetLabelRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolSetLabelRequest) @@ -95,7 +95,7 @@ func k8sPoolRemoveLabelCommand() *core.Command { Resource: "pool", Verb: "remove-label", Groups: []string{"label"}, - ArgsType: reflect.TypeOf(k8sPoolRemoveLabelRequest{}), + ArgsType: reflect.TypeFor[k8sPoolRemoveLabelRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolRemoveLabelRequest) diff --git a/internal/namespaces/k8s/v1/custom_pool_taints.go b/internal/namespaces/k8s/v1/custom_pool_taints.go index e8e0fc1490..e63ebe1775 100644 --- a/internal/namespaces/k8s/v1/custom_pool_taints.go +++ b/internal/namespaces/k8s/v1/custom_pool_taints.go @@ -35,7 +35,7 @@ func k8sPoolSetTaintCommand() *core.Command { Resource: "pool", Verb: "set-taint", Groups: []string{"taint"}, - ArgsType: reflect.TypeOf(k8sPoolSetTaintRequest{}), + ArgsType: reflect.TypeFor[k8sPoolSetTaintRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolSetTaintRequest) @@ -125,7 +125,7 @@ func k8sPoolRemoveTaintCommand() *core.Command { Resource: "pool", Verb: "remove-taint", Groups: []string{"taint"}, - ArgsType: reflect.TypeOf(k8sPoolRemoveTaintRequest{}), + ArgsType: reflect.TypeFor[k8sPoolRemoveTaintRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolRemoveTaintRequest) @@ -197,7 +197,7 @@ func k8sPoolSetStartupTaintCommand() *core.Command { Resource: "pool", Verb: "set-startup-taint", Groups: []string{"taint"}, - ArgsType: reflect.TypeOf(k8sPoolSetStartupTaintRequest{}), + ArgsType: reflect.TypeFor[k8sPoolSetStartupTaintRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolSetStartupTaintRequest) @@ -287,7 +287,7 @@ func k8sPoolRemoveStartupTaintCommand() *core.Command { Resource: "pool", Verb: "remove-startup-taint", Groups: []string{"taint"}, - ArgsType: reflect.TypeOf(k8sPoolRemoveStartupTaintRequest{}), + ArgsType: reflect.TypeFor[k8sPoolRemoveStartupTaintRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { request := argsI.(*k8sPoolRemoveStartupTaintRequest) diff --git a/internal/namespaces/lb/v1/custom_backend.go b/internal/namespaces/lb/v1/custom_backend.go index 51e6a67cd0..c9e263b986 100644 --- a/internal/namespaces/lb/v1/custom_backend.go +++ b/internal/namespaces/lb/v1/custom_backend.go @@ -99,7 +99,7 @@ func backendCreateBuilder(c *core.Command) *core.Command { BaremetalServerTag []string } - c.ArgsType = reflect.TypeOf(lbBackendCreateRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbBackendCreateRequestCustom]() c.ArgSpecs.AddBefore("server-ip.{index}", &core.ArgSpec{ Name: "instance-server-id.{index}", @@ -317,7 +317,7 @@ func backendAddServersBuilder(c *core.Command) *core.Command { BaremetalServerTag []string } - c.ArgsType = reflect.TypeOf(lbBackendAddBackendServersRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbBackendAddBackendServersRequestCustom]() c.ArgSpecs.AddBefore("server-ip.{index}", &core.ArgSpec{ Name: "instance-server-id.{index}", @@ -508,7 +508,7 @@ func backendRemoveServersBuilder(c *core.Command) *core.Command { BaremetalServerTag []string } - c.ArgsType = reflect.TypeOf(lbBackendRemoveBackendServersRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbBackendRemoveBackendServersRequestCustom]() c.ArgSpecs.AddBefore("server-ip.{index}", &core.ArgSpec{ Name: "instance-server-id.{index}", @@ -699,7 +699,7 @@ func backendSetServersBuilder(c *core.Command) *core.Command { BaremetalServerTag []string } - c.ArgsType = reflect.TypeOf(lbBackendSetBackendServersRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbBackendSetBackendServersRequestCustom]() c.ArgSpecs.AddBefore("server-ip.{index}", &core.ArgSpec{ Name: "instance-server-id.{index}", diff --git a/internal/namespaces/lb/v1/custom_certificate.go b/internal/namespaces/lb/v1/custom_certificate.go index ed43195340..dd043af1c9 100644 --- a/internal/namespaces/lb/v1/custom_certificate.go +++ b/internal/namespaces/lb/v1/custom_certificate.go @@ -64,7 +64,7 @@ func certificateCreateBuilder(c *core.Command) *core.Command { LetsencryptAlternativeName []string } - c.ArgsType = reflect.TypeOf(lbCreateCertificateRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbCreateCertificateRequestCustom]() c.Interceptor = func(ctx context.Context, argsI any, runner core.CommandRunner) (any, error) { args := argsI.(*lbCreateCertificateRequestCustom) diff --git a/internal/namespaces/lb/v1/custom_lb.go b/internal/namespaces/lb/v1/custom_lb.go index 4c79e54b3d..47ef2ba384 100644 --- a/internal/namespaces/lb/v1/custom_lb.go +++ b/internal/namespaces/lb/v1/custom_lb.go @@ -71,7 +71,7 @@ func lbWaitCommand() *core.Command { Resource: "lb", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(lb.ZonedAPIWaitForLBRequest{}), + ArgsType: reflect.TypeFor[lb.ZonedAPIWaitForLBRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := lb.NewZonedAPI(core.ExtractClient(ctx)) args := argsI.(*lb.ZonedAPIWaitForLBRequest) @@ -153,7 +153,7 @@ func lbUpdateBuilder(c *core.Command) *core.Command { IPID string `json:"ip_id"` } - c.ArgsType = reflect.TypeOf(lbUpdateRequestCustom{}) + c.ArgsType = reflect.TypeFor[lbUpdateRequestCustom]() c.ArgSpecs.AddBefore("tags.{index}", &core.ArgSpec{ Name: "assign-flexible-ipv6", diff --git a/internal/namespaces/login/login.go b/internal/namespaces/login/login.go index e491ebb50c..af2f5f23b8 100644 --- a/internal/namespaces/login/login.go +++ b/internal/namespaces/login/login.go @@ -43,7 +43,7 @@ Once you connected to Scaleway, the profile should be configured. `, Namespace: "login", AllowAnonymousClient: true, - ArgsType: reflect.TypeOf(loginArgs{}), + ArgsType: reflect.TypeFor[loginArgs](), ArgSpecs: core.ArgSpecs{ { Name: "port", diff --git a/internal/namespaces/marketplace/v2/updated_commands.go b/internal/namespaces/marketplace/v2/updated_commands.go index a37734b423..34e8b45b0f 100644 --- a/internal/namespaces/marketplace/v2/updated_commands.go +++ b/internal/namespaces/marketplace/v2/updated_commands.go @@ -22,7 +22,7 @@ func updateMarketplaceGetImage(c *core.Command) { Label string } - c.ArgsType = reflect.TypeOf(getImagesArgs{}) + c.ArgsType = reflect.TypeFor[getImagesArgs]() c.ArgSpecs = core.ArgSpecs{ { Name: "label", diff --git a/internal/namespaces/mcp/server/commands.go b/internal/namespaces/mcp/server/commands.go index 138d7cb094..3f8c26e4a2 100644 --- a/internal/namespaces/mcp/server/commands.go +++ b/internal/namespaces/mcp/server/commands.go @@ -29,7 +29,7 @@ func McpServerServe() *core.Command { Long: "Runs the MCP server, exposing all CLI commands as MCP tools for AI assistants. Supports stdio (default) and streamable HTTP transports.", AllowAnonymousClient: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(serveArgs{}), + ArgsType: reflect.TypeFor[serveArgs](), Examples: []*core.Example{ { Short: "Start the MCP server with stdio transport (default)", @@ -187,7 +187,7 @@ func McpServerListResources() *core.Command { Long: "Lists all CLI commands that would be exposed as MCP resources by the server. Resources are read-only endpoints for list commands that can be accessed via URI. Use filters to see which resources are available for specific namespaces or resources.", AllowAnonymousClient: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(listResourcesArgs{}), + ArgsType: reflect.TypeFor[listResourcesArgs](), Examples: []*core.Example{ { Short: "List all available MCP resources", diff --git a/internal/namespaces/mcp/server/list_tools.go b/internal/namespaces/mcp/server/list_tools.go index 8a25184877..4c3c2cf80b 100644 --- a/internal/namespaces/mcp/server/list_tools.go +++ b/internal/namespaces/mcp/server/list_tools.go @@ -64,7 +64,7 @@ func McpServerListTools() *core.Command { Long: "Lists all CLI commands that would be exposed as MCP tools by the server. Use filters to see which commands are available for specific namespaces, resources, or verbs.", AllowAnonymousClient: true, DisableTelemetry: true, - ArgsType: reflect.TypeOf(listArgs{}), + ArgsType: reflect.TypeFor[listArgs](), Examples: []*core.Example{ { Short: "List all available MCP tools", diff --git a/internal/namespaces/mcp/server/mcp_tools_test.go b/internal/namespaces/mcp/server/mcp_tools_test.go index 3dc2b2cbd3..c74bc98725 100644 --- a/internal/namespaces/mcp/server/mcp_tools_test.go +++ b/internal/namespaces/mcp/server/mcp_tools_test.go @@ -161,7 +161,7 @@ func TestCommandToolExecuteAppliesDefaultValues(t *testing.T) { Namespace: "instance", Resource: "server-type", Verb: "list", - ArgsType: reflect.TypeOf(testArgs{}), + ArgsType: reflect.TypeFor[testArgs](), ArgSpecs: core.ArgSpecs{ { Name: "zone", @@ -203,7 +203,7 @@ func TestCommandToolExecute(t *testing.T) { Namespace: "test", Resource: "resource", Verb: "get", - ArgsType: reflect.TypeOf(testArgs{}), + ArgsType: reflect.TypeFor[testArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", @@ -261,7 +261,7 @@ func TestCommandToolExecuteWithKebabCase(t *testing.T) { Namespace: "test", Resource: "resource", Verb: "list", - ArgsType: reflect.TypeOf(testArgs{}), + ArgsType: reflect.TypeFor[testArgs](), ArgSpecs: core.ArgSpecs{ { Name: "project-id", diff --git a/internal/namespaces/mnq/v1beta1/custom_nats.go b/internal/namespaces/mnq/v1beta1/custom_nats.go index 1499d468f6..b75f17845e 100644 --- a/internal/namespaces/mnq/v1beta1/custom_nats.go +++ b/internal/namespaces/mnq/v1beta1/custom_nats.go @@ -57,7 +57,7 @@ Credentials and context file are saved in your nats context folder with 0600 per }, core.RegionArgSpec((*mnq.NatsAPI)(nil).Regions()...), }, - ArgsType: reflect.TypeOf(CreateContextRequest{}), + ArgsType: reflect.TypeFor[CreateContextRequest](), Run: func(ctx context.Context, argsI any) (any, error) { args := argsI.(*CreateContextRequest) api := mnq.NewNatsAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/mongodb/v1alpha1/custom_instance.go b/internal/namespaces/mongodb/v1alpha1/custom_instance.go index e14d665624..097936601a 100644 --- a/internal/namespaces/mongodb/v1alpha1/custom_instance.go +++ b/internal/namespaces/mongodb/v1alpha1/custom_instance.go @@ -138,7 +138,7 @@ func instanceWaitCommand() *core.Command { Resource: "instance", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(serverWaitRequest{}), + ArgsType: reflect.TypeFor[serverWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := mongodb.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/object/v1/custom_bucket.go b/internal/namespaces/object/v1/custom_bucket.go index 6af40a0bff..9b3a5fe3db 100644 --- a/internal/namespaces/object/v1/custom_bucket.go +++ b/internal/namespaces/object/v1/custom_bucket.go @@ -32,7 +32,7 @@ func bucketCreateCommand() *core.Command { Verb: "create", Short: "Create an S3 bucket", Long: "Create an Object Storage Bucket with the S3 protocol. The namespace is shared between all S3 users, so its name must be unique.", - ArgsType: reflect.TypeOf(bucketConfigArgs{}), + ArgsType: reflect.TypeFor[bucketConfigArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", @@ -130,7 +130,7 @@ func bucketDeleteCommand() *core.Command { Verb: "delete", Short: "Delete an S3 bucket", Long: "Delete an S3 bucket with all its content.", - ArgsType: reflect.TypeOf(bucketDeleteArgs{}), + ArgsType: reflect.TypeFor[bucketDeleteArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", @@ -173,7 +173,7 @@ func bucketGetCommand() *core.Command { Verb: "get", Short: "Get information about an S3 bucket", Long: "Get the properties of an S3 bucket like tags, endpoint, access control, versioning, size, etc.", - ArgsType: reflect.TypeOf(bucketGetArgs{}), + ArgsType: reflect.TypeFor[bucketGetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", @@ -244,7 +244,7 @@ func bucketListCommand() *core.Command { Verb: "list", Short: "List S3 buckets", Long: "List all existing S3 buckets in the specified region", - ArgsType: reflect.TypeOf(bucketListArgs{}), + ArgsType: reflect.TypeFor[bucketListArgs](), ArgSpecs: core.ArgSpecs{ { Name: "project-id", @@ -275,7 +275,7 @@ func bucketUpdateCommand() *core.Command { Verb: "update", Short: "Update an S3 bucket", Long: "Update an S3 bucket's properties like tags, access control and versioning.", - ArgsType: reflect.TypeOf(bucketConfigArgs{}), + ArgsType: reflect.TypeFor[bucketConfigArgs](), ArgSpecs: core.ArgSpecs{ { Name: "name", diff --git a/internal/namespaces/object/v1/custom_bucket_cors.go b/internal/namespaces/object/v1/custom_bucket_cors.go index cf83220c6e..92b9528267 100644 --- a/internal/namespaces/object/v1/custom_bucket_cors.go +++ b/internal/namespaces/object/v1/custom_bucket_cors.go @@ -30,7 +30,7 @@ func bucketCorsCreateCommand() *core.Command { Verb: "create", Short: "Add CORS rules to a bucket", Long: "Add CORS rules to an Object Storage bucket with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketCorsCreateArgs{}), + ArgsType: reflect.TypeFor[bucketCorsCreateArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -117,7 +117,7 @@ func bucketCorsDeleteCommand() *core.Command { Verb: "delete", Short: "Remove CORS rules from a bucket", Long: "Remove CORS rules from an Object Storage bucket with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketCorsDeleteArgs{}), + ArgsType: reflect.TypeFor[bucketCorsDeleteArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -166,7 +166,7 @@ func bucketCorsGetCommand() *core.Command { Verb: "get", Short: "Get the CORS configuration of a bucket", Long: "Get the CORS configuration of an Object Storage bucket with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketCorsGetArgs{}), + ArgsType: reflect.TypeFor[bucketCorsGetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", diff --git a/internal/namespaces/object/v1/custom_bucket_lifecycle.go b/internal/namespaces/object/v1/custom_bucket_lifecycle.go index 086467900c..9588e44016 100644 --- a/internal/namespaces/object/v1/custom_bucket_lifecycle.go +++ b/internal/namespaces/object/v1/custom_bucket_lifecycle.go @@ -30,7 +30,7 @@ func lifecycleCreateCommand() *core.Command { Verb: "create", Short: "Create a lifecycle configuration for an S3 bucket's objects.", Long: "Create a lifecycle configuration and apply to an Object Bucket's objects with the S3 protocol.", - ArgsType: reflect.TypeOf(lifecycleCreateArgs{}), + ArgsType: reflect.TypeFor[lifecycleCreateArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -116,7 +116,7 @@ func lifecycleDeleteCommand() *core.Command { Verb: "delete", Short: "Delete an S3 bucket's lifecycle configuration if it exists.", Long: "Delete an Object Bucket's lifecycle configuration with the S3 protocol.", - ArgsType: reflect.TypeOf(lifecycleDeleteArgs{}), + ArgsType: reflect.TypeFor[lifecycleDeleteArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -165,7 +165,7 @@ func lifecycleGetCommand() *core.Command { Verb: "get", Short: "Get the lifecycle configuration of an S3 bucket.", Long: "Retrieve an Object Bucket's list of lifecycle rules with the S3 protocol.", - ArgsType: reflect.TypeOf(lifecycleGetArgs{}), + ArgsType: reflect.TypeFor[lifecycleGetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", diff --git a/internal/namespaces/object/v1/custom_bucket_policy.go b/internal/namespaces/object/v1/custom_bucket_policy.go index e6c9b83b39..673daad94b 100644 --- a/internal/namespaces/object/v1/custom_bucket_policy.go +++ b/internal/namespaces/object/v1/custom_bucket_policy.go @@ -30,7 +30,7 @@ func bucketPolicyCreateCommand() *core.Command { Verb: "create", Short: "Create a policy for an S3 bucket", Long: "Create a policy and apply to an Object Bucket with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketPolicyCreateArgs{}), + ArgsType: reflect.TypeFor[bucketPolicyCreateArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -107,7 +107,7 @@ func bucketPolicyDeleteCommand() *core.Command { Verb: "delete", Short: "Delete an S3 bucket's policy if it exists.", Long: "Delete an Object Bucket's policy with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketPolicyDeleteArgs{}), + ArgsType: reflect.TypeFor[bucketPolicyDeleteArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", @@ -156,7 +156,7 @@ func bucketPolicyGetCommand() *core.Command { Verb: "get", Short: "Retrieve an S3 bucket's policy.", Long: "Retrieve an Object Bucket's policy with the S3 protocol.", - ArgsType: reflect.TypeOf(bucketPolicyGetArgs{}), + ArgsType: reflect.TypeFor[bucketPolicyGetArgs](), ArgSpecs: core.ArgSpecs{ { Name: "bucket", diff --git a/internal/namespaces/object/v1/custom_config_get.go b/internal/namespaces/object/v1/custom_config_get.go index 9a99bd189f..50c97e0f0d 100644 --- a/internal/namespaces/object/v1/custom_config_get.go +++ b/internal/namespaces/object/v1/custom_config_get.go @@ -24,7 +24,7 @@ func configGetCommand() *core.Command { Verb: "get", Short: "Generate a S3 tool configuration file", Long: "Generate a S3 tool configuration file.", - ArgsType: reflect.TypeOf(getArgs{}), + ArgsType: reflect.TypeFor[getArgs](), ArgSpecs: []*core.ArgSpec{ { Name: "type", diff --git a/internal/namespaces/object/v1/custom_config_install.go b/internal/namespaces/object/v1/custom_config_install.go index 769166595e..c93fa50506 100644 --- a/internal/namespaces/object/v1/custom_config_install.go +++ b/internal/namespaces/object/v1/custom_config_install.go @@ -28,7 +28,7 @@ func configInstallCommand() *core.Command { Verb: "install", Short: "Install a S3 tool configuration file to its default location", Long: "Install a S3 tool configuration file to its default location.", - ArgsType: reflect.TypeOf(installArgs{}), + ArgsType: reflect.TypeFor[installArgs](), ArgSpecs: []*core.ArgSpec{ { Name: "type", diff --git a/internal/namespaces/rdb/v1/custom_acl.go b/internal/namespaces/rdb/v1/custom_acl.go index 64e8a97387..39c1020743 100644 --- a/internal/namespaces/rdb/v1/custom_acl.go +++ b/internal/namespaces/rdb/v1/custom_acl.go @@ -52,7 +52,7 @@ func rdbACLCustomResultMarshalerFunc(i any, opt *human.MarshalOpt) (string, erro } func aclAddBuilder(c *core.Command) *core.Command { - c.ArgsType = reflect.TypeOf(rdbACLAddCustomArgs{}) + c.ArgsType = reflect.TypeFor[rdbACLAddCustomArgs]() c.ArgSpecs = core.ArgSpecs{ { Name: "acl-rule-ips", @@ -158,7 +158,7 @@ func aclAddBuilder(c *core.Command) *core.Command { } func aclDeleteBuilder(c *core.Command) *core.Command { - c.ArgsType = reflect.TypeOf(rdbACLCustomArgs{}) + c.ArgsType = reflect.TypeFor[rdbACLCustomArgs]() c.ArgSpecs = core.ArgSpecs{ { Name: "acl-rule-ips", @@ -293,7 +293,7 @@ type rdbACLSetCustomArgs struct { } func aclSetBuilder(c *core.Command) *core.Command { - c.ArgsType = reflect.TypeOf(rdbACLSetCustomArgs{}) + c.ArgsType = reflect.TypeFor[rdbACLSetCustomArgs]() c.ArgSpecs = core.ArgSpecs{ { Name: "acl-rule-ips", @@ -389,7 +389,7 @@ func aclEditCommand() *core.Command { Namespace: "rdb", Resource: "acl", Verb: "edit", - ArgsType: reflect.TypeOf(rdbACLEditArgs{}), + ArgsType: reflect.TypeFor[rdbACLEditArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/rdb/v1/custom_backup.go b/internal/namespaces/rdb/v1/custom_backup.go index 354e8ceda5..723c8ae211 100644 --- a/internal/namespaces/rdb/v1/custom_backup.go +++ b/internal/namespaces/rdb/v1/custom_backup.go @@ -69,7 +69,7 @@ func backupWaitCommand() *core.Command { Resource: "backup", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(backupWaitRequest{}), + ArgsType: reflect.TypeFor[backupWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := rdb.NewAPI(core.ExtractClient(ctx)) @@ -159,7 +159,7 @@ func backupListBuilder(c *core.Command) *core.Command { CreatedBefore *time.Time } - c.ArgsType = reflect.TypeOf(backupListArgs{}) + c.ArgsType = reflect.TypeFor[backupListArgs]() // Insert created-after / created-before date filters before region, keeping // existing arguments (name, order-by, instance-id, project-id, organization-id) @@ -395,7 +395,7 @@ func backupDownloadCommand() *core.Command { Namespace: "rdb", Resource: "backup", Verb: "download", - ArgsType: reflect.TypeOf(backupDownloadArgs{}), + ArgsType: reflect.TypeFor[backupDownloadArgs](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*backupDownloadArgs) api := rdb.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/rdb/v1/custom_endpoint.go b/internal/namespaces/rdb/v1/custom_endpoint.go index 63d9703528..b7a7eb6958 100644 --- a/internal/namespaces/rdb/v1/custom_endpoint.go +++ b/internal/namespaces/rdb/v1/custom_endpoint.go @@ -52,7 +52,7 @@ func endpointCreateBuilder(c *core.Command) *core.Command { PrivateNetwork *rdbEndpointSpecPrivateNetworkCustom `json:"private-network"` } - c.ArgsType = reflect.TypeOf(rdbCreateEndpointRequestCustom{}) + c.ArgsType = reflect.TypeFor[rdbCreateEndpointRequestCustom]() c.ArgSpecs = core.ArgSpecs{ { @@ -160,7 +160,7 @@ func endpointDeleteBuilder(c *core.Command) *core.Command { InstanceID string `json:"instance-id"` } - c.ArgsType = reflect.TypeOf(rdbDeleteEndpointRequestCustom{}) + c.ArgsType = reflect.TypeFor[rdbDeleteEndpointRequestCustom]() c.ArgSpecs.GetByName("endpoint-id").Positional = true c.ArgSpecs.AddBefore("endpoint-id", &core.ArgSpec{ @@ -227,7 +227,7 @@ func endpointListCommand() *core.Command { Verb: "list", Short: "Lists a Database Instance's endpoints", Long: "Lists all public and private endpoints of a Database Instance", - ArgsType: reflect.TypeOf(rdbEndpointListCustomArgs{}), + ArgsType: reflect.TypeFor[rdbEndpointListCustomArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/rdb/v1/custom_engine_settings.go b/internal/namespaces/rdb/v1/custom_engine_settings.go index e43df63790..f72f6d4183 100644 --- a/internal/namespaces/rdb/v1/custom_engine_settings.go +++ b/internal/namespaces/rdb/v1/custom_engine_settings.go @@ -22,7 +22,7 @@ func engineSettingsCommand() *core.Command { Namespace: "rdb", Resource: "engine", Verb: "settings", - ArgsType: reflect.TypeOf(engineSettingsArgs{}), + ArgsType: reflect.TypeFor[engineSettingsArgs](), Run: func(ctx context.Context, argsI any) (i any, err error) { args := argsI.(*engineSettingsArgs) api := rdb.NewAPI(core.ExtractClient(ctx)) diff --git a/internal/namespaces/rdb/v1/custom_instance.go b/internal/namespaces/rdb/v1/custom_instance.go index ddba7b9b28..4eaf3981e2 100644 --- a/internal/namespaces/rdb/v1/custom_instance.go +++ b/internal/namespaces/rdb/v1/custom_instance.go @@ -311,7 +311,7 @@ func instanceCreateBuilder(c *core.Command) *core.Command { c.ArgSpecs.GetByName("node-type").AutoCompleteFunc = autoCompleteNodeType c.ArgSpecs.GetByName("engine").AutoCompleteFunc = autoCompleteDatabaseEngines - c.ArgsType = reflect.TypeOf(rdbCreateInstanceRequestCustom{}) + c.ArgsType = reflect.TypeFor[rdbCreateInstanceRequestCustom]() c.WaitFunc = func(ctx context.Context, _, respI any) (any, error) { api := rdbSDK.NewAPI(core.ExtractClient(ctx)) @@ -530,7 +530,7 @@ func instanceUpdateBuilder(_ *core.Command) *core.Command { Namespace: "rdb", Resource: "instance", Verb: "update", - ArgsType: reflect.TypeOf(rdbUpdateInstanceRequestCustom{}), + ArgsType: reflect.TypeFor[rdbUpdateInstanceRequestCustom](), ArgSpecs: core.ArgSpecs{ { Name: "backup-schedule-frequency", @@ -726,7 +726,7 @@ func instanceWaitCommand() *core.Command { Resource: "instance", Verb: "wait", Groups: []string{"workflow"}, - ArgsType: reflect.TypeOf(serverWaitRequest{}), + ArgsType: reflect.TypeFor[serverWaitRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := rdbSDK.NewAPI(core.ExtractClient(ctx)) @@ -907,7 +907,7 @@ func instanceConnectCommand() *core.Command { Verb: "connect", Short: "Connect to an instance using locally installed CLI", Long: "Connect to an instance using locally installed CLI such as psql or mysql.", - ArgsType: reflect.TypeOf(instanceConnectArgs{}), + ArgsType: reflect.TypeFor[instanceConnectArgs](), ArgSpecs: core.ArgSpecs{ { Name: "private-network", @@ -1016,7 +1016,7 @@ func instanceEditSettingsCommand() *core.Command { Short: "Edit Database Instance settings in your default editor", Long: `This command opens the current settings of your RDB instance in your $EDITOR. You can modify the values and save the file to apply the new configuration.`, - ArgsType: reflect.TypeOf(editSettingsArgs{}), + ArgsType: reflect.TypeFor[editSettingsArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/rdb/v1/custom_log.go b/internal/namespaces/rdb/v1/custom_log.go index 396892b21a..c4cbfcbc2f 100644 --- a/internal/namespaces/rdb/v1/custom_log.go +++ b/internal/namespaces/rdb/v1/custom_log.go @@ -100,7 +100,7 @@ func logDownloadCommand() *core.Command { Namespace: "rdb", Resource: "log", Verb: "download", - ArgsType: reflect.TypeOf(logDownloadArgs{}), + ArgsType: reflect.TypeFor[logDownloadArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/rdb/v1/custom_url.go b/internal/namespaces/rdb/v1/custom_url.go index fb6381e673..8ffee83e58 100644 --- a/internal/namespaces/rdb/v1/custom_url.go +++ b/internal/namespaces/rdb/v1/custom_url.go @@ -27,7 +27,7 @@ func databaseGetURLCommand() *core.Command { Verb: "get-url", Short: "Gets the URL to connect to the Database", Long: "Provides the URL to connect to a Database on an Instance as the given user", - ArgsType: reflect.TypeOf(rdbGetURLArgs{}), + ArgsType: reflect.TypeFor[rdbGetURLArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/rdb/v1/custom_user.go b/internal/namespaces/rdb/v1/custom_user.go index a656628a17..02982fee3e 100644 --- a/internal/namespaces/rdb/v1/custom_user.go +++ b/internal/namespaces/rdb/v1/custom_user.go @@ -109,7 +109,7 @@ func userCreateBuilder(c *core.Command) *core.Command { Positional: false, Default: core.DefaultValueSetter("true"), }) - c.ArgsType = reflect.TypeOf(rdbCreateUserRequestCustom{}) + c.ArgsType = reflect.TypeFor[rdbCreateUserRequestCustom]() c.Run = func(ctx context.Context, argsI any) (any, error) { api := rdb.NewAPI(core.ExtractClient(ctx)) @@ -174,7 +174,7 @@ func userUpdateBuilder(c *core.Command) *core.Command { Positional: false, Default: core.DefaultValueSetter("true"), }) - c.ArgsType = reflect.TypeOf(rdbUpdateUserRequestCustom{}) + c.ArgsType = reflect.TypeFor[rdbUpdateUserRequestCustom]() c.Run = func(ctx context.Context, argsI any) (any, error) { client := core.ExtractClient(ctx) @@ -238,7 +238,7 @@ func userGetURLCommand() *core.Command { Verb: "get-url", Short: "Gets the URL to connect to the Database", Long: "Provides the URL to connect to a Database on an Instance as the given user", - ArgsType: reflect.TypeOf(rdbGetURLArgs{}), + ArgsType: reflect.TypeFor[rdbGetURLArgs](), ArgSpecs: core.ArgSpecs{ { Name: "instance-id", diff --git a/internal/namespaces/redis/v1/custom_acl.go b/internal/namespaces/redis/v1/custom_acl.go index d5a6a7cba8..63c2fa2bf4 100644 --- a/internal/namespaces/redis/v1/custom_acl.go +++ b/internal/namespaces/redis/v1/custom_acl.go @@ -18,7 +18,7 @@ func redisACLUpdateCommand() *core.Command { Namespace: "redis", Resource: "acl", Verb: "update", - ArgsType: reflect.TypeOf(redisUpdateACLRuleRequest{}), + ArgsType: reflect.TypeFor[redisUpdateACLRuleRequest](), ArgSpecs: core.ArgSpecs{ { Name: "cluster-id", diff --git a/internal/namespaces/redis/v1/custom_cluster.go b/internal/namespaces/redis/v1/custom_cluster.go index 195b191c7b..8b15130908 100644 --- a/internal/namespaces/redis/v1/custom_cluster.go +++ b/internal/namespaces/redis/v1/custom_cluster.go @@ -51,7 +51,7 @@ func clusterCreateBuilder(c *core.Command) *core.Command { Default: core.DefaultValueSetter("false"), }) - c.ArgsType = reflect.TypeOf(redisCreateClusterRequestCustom{}) + c.ArgsType = reflect.TypeFor[redisCreateClusterRequestCustom]() c.WaitFunc = func(ctx context.Context, _, respI any) (any, error) { api := redis.NewAPI(core.ExtractClient(ctx)) @@ -150,7 +150,7 @@ func clusterWaitCommand() *core.Command { Namespace: "redis", Resource: "cluster", Verb: "wait", - ArgsType: reflect.TypeOf(redis.WaitForClusterRequest{}), + ArgsType: reflect.TypeFor[redis.WaitForClusterRequest](), Run: func(ctx context.Context, argsI any) (i any, err error) { api := redis.NewAPI(core.ExtractClient(ctx)) @@ -386,7 +386,7 @@ func clusterConnectCommand() *core.Command { Verb: "connect", Short: "Connect to a Redis cluster using locally installed redis-cli", Long: "Connect to a Redis cluster using locally installed redis-cli. The command will check if redis-cli is installed, download the certificate if TLS is enabled, and prompt for the password.", - ArgsType: reflect.TypeOf(clusterConnectArgs{}), + ArgsType: reflect.TypeFor[clusterConnectArgs](), ArgSpecs: core.ArgSpecs{ { Name: "private-network", diff --git a/internal/namespaces/redis/v1/custom_version_settings.go b/internal/namespaces/redis/v1/custom_version_settings.go index 9058523d4e..6bb4b0e6ef 100644 --- a/internal/namespaces/redis/v1/custom_version_settings.go +++ b/internal/namespaces/redis/v1/custom_version_settings.go @@ -21,7 +21,7 @@ func redisVersionSettingsCommand() *core.Command { Namespace: "redis", Resource: "version", Verb: "list-settings", - ArgsType: reflect.TypeOf(versionSettingsArgs{}), + ArgsType: reflect.TypeFor[versionSettingsArgs](), ArgSpecs: core.ArgSpecs{ { Name: "version", diff --git a/internal/namespaces/registry/v1/custom_docker_helper.go b/internal/namespaces/registry/v1/custom_docker_helper.go index 288e075b1d..d6e8215751 100644 --- a/internal/namespaces/registry/v1/custom_docker_helper.go +++ b/internal/namespaces/registry/v1/custom_docker_helper.go @@ -39,7 +39,7 @@ It avoid running docker login commands. `, Namespace: "registry", Resource: "install-docker-helper", - ArgsType: reflect.TypeOf(registrySetupDockerHelperArgs{}), + ArgsType: reflect.TypeFor[registrySetupDockerHelperArgs](), ArgSpecs: []*core.ArgSpec{ { Name: "path", @@ -176,7 +176,7 @@ func registryDockerHelperGetCommand() *core.Command { Namespace: "registry", Resource: "docker-helper", Verb: "get", - ArgsType: reflect.TypeOf(emptyRequest{}), + ArgsType: reflect.TypeFor[emptyRequest](), Run: registryDockerHelperGetRun, } } @@ -227,7 +227,7 @@ func registryDockerHelperStoreCommand() *core.Command { Namespace: "registry", Resource: "docker-helper", Verb: "store", - ArgsType: reflect.TypeOf(emptyRequest{}), + ArgsType: reflect.TypeFor[emptyRequest](), Run: func(_ context.Context, _ any) (i any, e error) { return nil, nil }, @@ -240,7 +240,7 @@ func registryDockerHelperEraseCommand() *core.Command { Namespace: "registry", Resource: "docker-helper", Verb: "erase", - ArgsType: reflect.TypeOf(emptyRequest{}), + ArgsType: reflect.TypeFor[emptyRequest](), ArgSpecs: []*core.ArgSpec{ {}, }, @@ -256,7 +256,7 @@ func registryDockerHelperListCommand() *core.Command { Namespace: "registry", Resource: "docker-helper", Verb: "list", - ArgsType: reflect.TypeOf(emptyRequest{}), + ArgsType: reflect.TypeFor[emptyRequest](), Run: func(_ context.Context, _ any) (i any, e error) { registryEndpoints := make(map[string]string) for _, region := range scw.AllRegions { diff --git a/internal/namespaces/registry/v1/custom_login.go b/internal/namespaces/registry/v1/custom_login.go index 3c40518e5b..f7144be8aa 100644 --- a/internal/namespaces/registry/v1/custom_login.go +++ b/internal/namespaces/registry/v1/custom_login.go @@ -23,7 +23,7 @@ func registryLoginCommand() *core.Command { You will need to have the chosen binary installed on your system and in your PATH.`, Namespace: "registry", Resource: "login", - ArgsType: reflect.TypeOf(registryLoginArgs{}), + ArgsType: reflect.TypeFor[registryLoginArgs](), ArgSpecs: []*core.ArgSpec{ { Name: "program", diff --git a/internal/namespaces/registry/v1/custom_logout.go b/internal/namespaces/registry/v1/custom_logout.go index 89fa4264a8..f6384cf2e5 100644 --- a/internal/namespaces/registry/v1/custom_logout.go +++ b/internal/namespaces/registry/v1/custom_logout.go @@ -21,7 +21,7 @@ func registryLogoutCommand() *core.Command { You will need to have the chosen binary installed on your system and in your PATH.`, Namespace: "registry", Resource: "logout", - ArgsType: reflect.TypeOf(registryLogoutArgs{}), + ArgsType: reflect.TypeFor[registryLogoutArgs](), ArgSpecs: []*core.ArgSpec{ { Name: "program", diff --git a/internal/namespaces/registry/v1/custom_tag.go b/internal/namespaces/registry/v1/custom_tag.go index afe30738d3..927bc88868 100644 --- a/internal/namespaces/registry/v1/custom_tag.go +++ b/internal/namespaces/registry/v1/custom_tag.go @@ -144,7 +144,7 @@ type customTagDeleteArgs struct { } func tagDeleteBuilder(c *core.Command) *core.Command { - c.ArgsType = reflect.TypeOf(customTagDeleteArgs{}) + c.ArgsType = reflect.TypeFor[customTagDeleteArgs]() c.ArgSpecs.AddBefore("force", &core.ArgSpec{ Name: "timeout", Short: "Maximum time to handle the request", diff --git a/internal/namespaces/secret/v1beta1/custom_secret_version.go b/internal/namespaces/secret/v1beta1/custom_secret_version.go index 81b519481a..797fc5820a 100644 --- a/internal/namespaces/secret/v1beta1/custom_secret_version.go +++ b/internal/namespaces/secret/v1beta1/custom_secret_version.go @@ -27,7 +27,7 @@ func secretVersionCreateBuilder(c *core.Command) *core.Command { } func secretVersionAccessBuilder(c *core.Command) *core.Command { - c.ArgsType = reflect.TypeOf(customAccessSecretVersionRequest{}) + c.ArgsType = reflect.TypeFor[customAccessSecretVersionRequest]() c.ArgSpecs.AddBefore("region", &core.ArgSpec{ Name: "field", diff --git a/internal/namespaces/shell/shell.go b/internal/namespaces/shell/shell.go index 47a2d0b3bd..11b70111ac 100644 --- a/internal/namespaces/shell/shell.go +++ b/internal/namespaces/shell/shell.go @@ -20,7 +20,7 @@ func shellCommand() *core.Command { Short: "Start shell mode", Namespace: "shell", AllowAnonymousClient: false, - ArgsType: reflect.TypeOf(args.RawArgs{}), + ArgsType: reflect.TypeFor[args.RawArgs](), Run: func(_ context.Context, _ any) (any, error) { return nil, nil }, diff --git a/internal/namespaces/test/custom/custom_cli.go b/internal/namespaces/test/custom/custom_cli.go index 8ce48b1d8a..cdb34364d5 100644 --- a/internal/namespaces/test/custom/custom_cli.go +++ b/internal/namespaces/test/custom/custom_cli.go @@ -38,7 +38,7 @@ func CustomTestAnonymousFields() *core.Command { Long: `Test Anonymous Fields.`, Namespace: "test", Resource: "anonymous-fields", - ArgsType: reflect.TypeOf(testAnonymousFieldsCustom{}), + ArgsType: reflect.TypeFor[testAnonymousFieldsCustom](), ArgSpecs: core.ArgSpecs{ { Name: "field-b", diff --git a/internal/namespaces/test/v1/test_cli.go b/internal/namespaces/test/v1/test_cli.go index 9d10619854..6ce4c4d6b6 100644 --- a/internal/namespaces/test/v1/test_cli.go +++ b/internal/namespaces/test/v1/test_cli.go @@ -75,7 +75,7 @@ Hint: you can use other test commands by setting the SCW_SECRET_KEY env variable Resource: "user", Verb: "register", // Deprecated: false, - ArgsType: reflect.TypeOf(test.RegisterRequest{}), + ArgsType: reflect.TypeFor[test.RegisterRequest](), ArgSpecs: core.ArgSpecs{ { Name: "username", @@ -103,7 +103,7 @@ func testHumanList() *core.Command { Resource: "human", Verb: "list", // Deprecated: false, - ArgsType: reflect.TypeOf(test.ListHumansRequest{}), + ArgsType: reflect.TypeFor[test.ListHumansRequest](), ArgSpecs: core.ArgSpecs{ { Name: "order-by", @@ -156,7 +156,7 @@ func testHumanGet() *core.Command { Resource: "human", Verb: "get", // Deprecated: false, - ArgsType: reflect.TypeOf(test.GetHumanRequest{}), + ArgsType: reflect.TypeFor[test.GetHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "human-id", @@ -185,7 +185,7 @@ func testHumanCreate() *core.Command { Resource: "human", Verb: "create", // Deprecated: false, - ArgsType: reflect.TypeOf(test.CreateHumanRequest{}), + ArgsType: reflect.TypeFor[test.CreateHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "height", @@ -280,7 +280,7 @@ func testHumanUpdate() *core.Command { Resource: "human", Verb: "update", // Deprecated: false, - ArgsType: reflect.TypeOf(test.UpdateHumanRequest{}), + ArgsType: reflect.TypeFor[test.UpdateHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "human-id", @@ -374,7 +374,7 @@ func testHumanDelete() *core.Command { Resource: "human", Verb: "delete", // Deprecated: false, - ArgsType: reflect.TypeOf(test.DeleteHumanRequest{}), + ArgsType: reflect.TypeFor[test.DeleteHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "human-id", @@ -403,7 +403,7 @@ func testHumanRun() *core.Command { Resource: "human", Verb: "run", // Deprecated: false, - ArgsType: reflect.TypeOf(test.RunHumanRequest{}), + ArgsType: reflect.TypeFor[test.RunHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "human-id", @@ -439,7 +439,7 @@ func testHumanSmoke() *core.Command { Resource: "human", Verb: "smoke", // Deprecated: true, - ArgsType: reflect.TypeOf(test.SmokeHumanRequest{}), + ArgsType: reflect.TypeFor[test.SmokeHumanRequest](), ArgSpecs: core.ArgSpecs{ { Name: "human-id", diff --git a/internal/namespaces/vpc/v2/custom_acl.go b/internal/namespaces/vpc/v2/custom_acl.go index ef1db3526e..1976de3907 100644 --- a/internal/namespaces/vpc/v2/custom_acl.go +++ b/internal/namespaces/vpc/v2/custom_acl.go @@ -50,7 +50,7 @@ func vpcACLEditCommand() *core.Command { Namespace: "vpc", Resource: "rule", Verb: "edit", - ArgsType: reflect.TypeOf(vpcACLEditArgs{}), + ArgsType: reflect.TypeFor[vpcACLEditArgs](), ArgSpecs: core.ArgSpecs{ { Name: "vpc-id", diff --git a/internal/namespaces/vpcgw/v2/custom_pat_rule.go b/internal/namespaces/vpcgw/v2/custom_pat_rule.go index 7cd23de07e..70bb328079 100644 --- a/internal/namespaces/vpcgw/v2/custom_pat_rule.go +++ b/internal/namespaces/vpcgw/v2/custom_pat_rule.go @@ -31,7 +31,7 @@ func vpcgwPATRulesEditCommand() *core.Command { Namespace: "vpc-gw", Resource: "pat-rule", Verb: "edit", - ArgsType: reflect.TypeOf(vpcgwPATRulesEditArgs{}), + ArgsType: reflect.TypeFor[vpcgwPATRulesEditArgs](), ArgSpecs: core.ArgSpecs{ { Name: "gateway-id", diff --git a/internal/qa/argspec.go b/internal/qa/argspec.go index 2c4b66164d..54e9245c23 100644 --- a/internal/qa/argspec.go +++ b/internal/qa/argspec.go @@ -61,7 +61,7 @@ func testArgSpecMissingError(commands *core.Commands) []error { // Check all commands for _, command := range commands.GetAll() { - if command.ArgsType == nil || command.ArgsType == reflect.TypeOf(args.RawArgs{}) { + if command.ArgsType == nil || command.ArgsType == reflect.TypeFor[args.RawArgs]() { continue } diff --git a/internal/qa/ignore.go b/internal/qa/ignore.go index 2b097bc1d0..9aaaa4f267 100644 --- a/internal/qa/ignore.go +++ b/internal/qa/ignore.go @@ -53,15 +53,15 @@ func areCommandsEquals(c1 *core.Command, c2 *core.Command) bool { var ignoredErrors = []ignoredError{ { - Type: reflect.TypeOf(&DifferentLocalizationForNamespaceError{}), + Type: reflect.TypeFor[*DifferentLocalizationForNamespaceError](), Command: commands.GetCommands().MustFind("k8s", "kubeconfig", "uninstall"), }, { - Type: reflect.TypeOf(&DifferentLocalizationForNamespaceError{}), + Type: reflect.TypeFor[*DifferentLocalizationForNamespaceError](), Command: commands.GetCommands().MustFind("registry", "logout"), }, { - Type: reflect.TypeOf(&DifferentLocalizationForNamespaceError{}), + Type: reflect.TypeFor[*DifferentLocalizationForNamespaceError](), Command: commands.GetCommands().MustFind("registry", "login"), }, }