Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit d4af08f

Browse files
authored
♻️ interface{} -> any (#1261)
1 parent fb8f303 commit d4af08f

File tree

15 files changed

+34
-34
lines changed

15 files changed

+34
-34
lines changed

cmd/rig-ops/cmd/base/register.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
var options []fx.Option
2727

28-
func Register(f interface{}) func(cmd *cobra.Command, args []string) error {
28+
func Register(f any) func(cmd *cobra.Command, args []string) error {
2929
options = append(options,
3030
fx.Provide(f),
3131
)

cmd/rig/cmd/capsule/jobs/add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (c *Cmd) cronJobFromPath(path string) (*capsule.CronJob, error) {
8282
return nil, err
8383
}
8484

85-
var raw interface{}
85+
var raw any
8686
if err := yaml.Unmarshal(bytes, &raw); err != nil {
8787
return nil, err
8888
}

cmd/rig/cmd/capsule/root/status_utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ type getInfoStep interface {
226226
GetInfo() *rollout.StepInfo
227227
}
228228

229-
func GetStepInfo(s interface{}) *rollout.StepInfo {
229+
func GetStepInfo(s any) *rollout.StepInfo {
230230
msg, ok := s.(protoreflect.ProtoMessage)
231231
if !ok {
232232
return nil

cmd/rig/cmd/capsule/scale/horizontal.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (c *Cmd) autoscale(ctx context.Context, cmd *cobra.Command, _ []string) err
9292
return err
9393
}
9494

95-
var raw interface{}
95+
var raw any
9696
if err := yaml.Unmarshal(bytes, &raw); err != nil {
9797
return err
9898
}

pkg/cli/module.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var Module = fx.Module(
8787
fx.Provide(func() common.Prompter { return common.StandardPrompter{} }),
8888
)
8989

90-
type ContextDependency interface{}
90+
type ContextDependency any
9191

9292
type contextParams struct {
9393
fx.In

pkg/controller/plugin/external_plugin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ type loggerSink struct {
9090
logger logr.Logger
9191
}
9292

93-
func (l *loggerSink) Accept(name string, level hclog.Level, msg string, args ...interface{}) {
93+
func (l *loggerSink) Accept(name string, level hclog.Level, msg string, args ...any) {
9494
logger := l.logger.WithName(name).WithValues(args...)
9595
if level < hclog.Info {
9696
return

pkg/controller/plugin/heap.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ func (s *sliceHeap[E]) Less(i, j int) bool {
105105
return s.less(s.s[i], s.s[j])
106106
}
107107

108-
func (s *sliceHeap[E]) Push(x interface{}) {
108+
func (s *sliceHeap[E]) Push(x any) {
109109
s.s = append(s.s, x.(E))
110110
if s.setIndex != nil {
111111
s.setIndex(s.s[len(s.s)-1], len(s.s)-1)
112112
}
113113
}
114114

115-
func (s *sliceHeap[E]) Pop() interface{} {
115+
func (s *sliceHeap[E]) Pop() any {
116116
e := s.s[len(s.s)-1]
117117
if s.setIndex != nil {
118118
s.setIndex(e, -1)

pkg/controller/plugin/helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func ParseTemplatedConfig[T any](data []byte, req pipeline.CapsuleRequest, steps
3636
}
3737

3838
for k, v := range m {
39-
result := map[string]interface{}{}
39+
result := map[string]any{}
4040
d, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{TagName: "json", Result: &result})
4141
if err != nil {
4242
return empty, err

pkg/controller/plugin/watcher.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func (ow *objectWatcher) Watch(options metav1.ListOptions) (watch.Interface, err
535535
return wi, err
536536
}
537537

538-
func (ow *objectWatcher) OnAdd(obj interface{}, _ bool) {
538+
func (ow *objectWatcher) OnAdd(obj any, _ bool) {
539539
if e, ok := obj.(*corev1.Event); ok {
540540
key := cache.NewObjectName(e.InvolvedObject.Namespace, e.InvolvedObject.Name)
541541
item, exists, err := ow.store.GetByKey(key.String())
@@ -596,11 +596,11 @@ func (ow *objectWatcher) OnAdd(obj interface{}, _ bool) {
596596
}
597597
}
598598

599-
func (ow *objectWatcher) OnUpdate(_, newObj interface{}) {
599+
func (ow *objectWatcher) OnUpdate(_, newObj any) {
600600
ow.OnAdd(newObj, false)
601601
}
602602

603-
func (ow *objectWatcher) OnDelete(obj interface{}) {
603+
func (ow *objectWatcher) OnDelete(obj any) {
604604
if e, ok := obj.(*corev1.Event); ok {
605605
key := cache.NewObjectName(e.InvolvedObject.Namespace, e.InvolvedObject.Name)
606606
item, exists, err := ow.store.GetByKey(key.String())

pkg/errors/errors.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func IsUnauthenticated(err error) bool {
258258
//
259259
// The gRPC framework will generate this error code when cancellation
260260
// is requested.
261-
func CanceledErrorf(format string, a ...interface{}) error {
261+
func CanceledErrorf(format string, a ...any) error {
262262
return NewError(connect.CodeCanceled, fmt.Errorf(format, a...))
263263
}
264264

@@ -270,7 +270,7 @@ func CanceledErrorf(format string, a ...interface{}) error {
270270
//
271271
// The gRPC framework will generate this error code in the above two
272272
// mentioned cases.
273-
func UnknownErrorf(format string, a ...interface{}) error {
273+
func UnknownErrorf(format string, a ...any) error {
274274
return NewError(connect.CodeUnknown, fmt.Errorf(format, a...))
275275
}
276276

@@ -280,7 +280,7 @@ func UnknownErrorf(format string, a ...interface{}) error {
280280
// (e.g., a malformed file name).
281281
//
282282
// This error code will not be generated by the gRPC framework.
283-
func InvalidArgumentErrorf(format string, a ...interface{}) error {
283+
func InvalidArgumentErrorf(format string, a ...any) error {
284284
return NewError(connect.CodeInvalidArgument, fmt.Errorf(format, a...))
285285
}
286286

@@ -292,23 +292,23 @@ func InvalidArgumentErrorf(format string, a ...interface{}) error {
292292
//
293293
// The gRPC framework will generate this error code when the deadline is
294294
// exceeded.
295-
func DeadlineExceededErrorf(format string, a ...interface{}) error {
295+
func DeadlineExceededErrorf(format string, a ...any) error {
296296
return NewError(connect.CodeDeadlineExceeded, fmt.Errorf(format, a...))
297297
}
298298

299299
// NotFoundErrorf creates a new error that means some requested entity (e.g., file or directory) was
300300
// not found.
301301
//
302302
// This error code will not be generated by the gRPC framework.
303-
func NotFoundErrorf(format string, a ...interface{}) error {
303+
func NotFoundErrorf(format string, a ...any) error {
304304
return NewError(connect.CodeNotFound, fmt.Errorf(format, a...))
305305
}
306306

307307
// AlreadyExistsErrorf creates a new error that means an attempt to create an entity failed because one
308308
// already exists.
309309
//
310310
// This error code will not be generated by the gRPC framework.
311-
func AlreadyExistsErrorf(format string, a ...interface{}) error {
311+
func AlreadyExistsErrorf(format string, a ...any) error {
312312
return NewError(connect.CodeAlreadyExists, fmt.Errorf(format, a...))
313313
}
314314

@@ -321,7 +321,7 @@ func AlreadyExistsErrorf(format string, a ...interface{}) error {
321321
//
322322
// This error code will not be generated by the gRPC core framework,
323323
// but expect authentication middleware to use it.
324-
func PermissionDeniedErrorf(format string, a ...interface{}) error {
324+
func PermissionDeniedErrorf(format string, a ...any) error {
325325
return NewError(connect.CodePermissionDenied, fmt.Errorf(format, a...))
326326
}
327327

@@ -331,7 +331,7 @@ func PermissionDeniedErrorf(format string, a ...interface{}) error {
331331
// This error code will be generated by the gRPC framework in
332332
// out-of-memory and server overload situations, or when a message is
333333
// larger than the configured maximum size.
334-
func ResourceExhaustedErrorf(format string, a ...interface{}) error {
334+
func ResourceExhaustedErrorf(format string, a ...any) error {
335335
return NewError(connect.CodeResourceExhausted, fmt.Errorf(format, a...))
336336
}
337337

@@ -357,7 +357,7 @@ func ResourceExhaustedErrorf(format string, a ...interface{}) error {
357357
// read-modify-write on the same resource.
358358
//
359359
// This error code will not be generated by the gRPC framework.
360-
func FailedPreconditionErrorf(format string, a ...interface{}) error {
360+
func FailedPreconditionErrorf(format string, a ...any) error {
361361
return NewError(connect.CodeFailedPrecondition, fmt.Errorf(format, a...))
362362
}
363363

@@ -369,7 +369,7 @@ func FailedPreconditionErrorf(format string, a ...interface{}) error {
369369
// Aborted, and Unavailable.
370370
//
371371
// This error code will not be generated by the gRPC framework.
372-
func AbortedErrorf(format string, a ...interface{}) error {
372+
func AbortedErrorf(format string, a ...any) error {
373373
return NewError(connect.CodeAborted, fmt.Errorf(format, a...))
374374
}
375375

@@ -390,7 +390,7 @@ func AbortedErrorf(format string, a ...interface{}) error {
390390
// they are done.
391391
//
392392
// This error code will not be generated by the gRPC framework.
393-
func OutOfRangeErrorf(format string, a ...interface{}) error {
393+
func OutOfRangeErrorf(format string, a ...any) error {
394394
return NewError(connect.CodeOutOfRange, fmt.Errorf(format, a...))
395395
}
396396

@@ -402,7 +402,7 @@ func OutOfRangeErrorf(format string, a ...interface{}) error {
402402
// is missing on the server. It can also be generated for unknown
403403
// compression algorithms or a disagreement as to whether an RPC should
404404
// be streaming.
405-
func UnimplementedErrorf(format string, a ...interface{}) error {
405+
func UnimplementedErrorf(format string, a ...any) error {
406406
return NewError(connect.CodeUnimplemented, fmt.Errorf(format, a...))
407407
}
408408

@@ -412,7 +412,7 @@ func UnimplementedErrorf(format string, a ...interface{}) error {
412412
//
413413
// This error code will be generated by the gRPC framework in several
414414
// internal error conditions.
415-
func InternalErrorf(format string, a ...interface{}) error {
415+
func InternalErrorf(format string, a ...any) error {
416416
return NewError(connect.CodeInternal, fmt.Errorf(format, a...))
417417
}
418418

@@ -426,14 +426,14 @@ func InternalErrorf(format string, a ...interface{}) error {
426426
//
427427
// This error code will be generated by the gRPC framework during
428428
// abrupt shutdown of a server process or network connection.
429-
func UnavailableErrorf(format string, a ...interface{}) error {
429+
func UnavailableErrorf(format string, a ...any) error {
430430
return NewError(connect.CodeUnavailable, fmt.Errorf(format, a...))
431431
}
432432

433433
// DataLossErrorf creates a new error that indicates unrecoverable data loss or corruption.
434434
//
435435
// This error code will not be generated by the gRPC framework.
436-
func DataLossErrorf(format string, a ...interface{}) error {
436+
func DataLossErrorf(format string, a ...any) error {
437437
return NewError(connect.CodeDataLoss, fmt.Errorf(format, a...))
438438
}
439439

@@ -443,7 +443,7 @@ func DataLossErrorf(format string, a ...interface{}) error {
443443
// The gRPC framework will generate this error code when the
444444
// authentication metadata is invalid or a Credentials callback fails,
445445
// but also expect authentication middleware to generate it.
446-
func UnauthenticatedErrorf(format string, a ...interface{}) error {
446+
func UnauthenticatedErrorf(format string, a ...any) error {
447447
return NewError(connect.CodeUnauthenticated, fmt.Errorf(format, a...))
448448
}
449449

pkg/pipeline/pipeline.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (ok ObjectKey) String() string {
4444
return fmt.Sprintf("%s/%s", ok.GroupVersionKind.String(), ok.ObjectKey.String())
4545
}
4646

47-
func (ok ObjectKey) MarshalLog() interface{} {
47+
func (ok ObjectKey) MarshalLog() any {
4848
return struct {
4949
Group string `json:"group,omitempty"`
5050
Version string `json:"version,omitempty"`

pkg/roclient/layered_reader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (r *LayeredReader) List(ctx context.Context, list client.ObjectList, opts .
7575
}
7676
}
7777

78-
bs, err := gojson.Marshal(map[string]interface{}{
78+
bs, err := gojson.Marshal(map[string]any{
7979
"items": objs,
8080
})
8181
if err != nil {

pkg/roclient/reader.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (r *reader) List(_ context.Context, list client.ObjectList, opts ...client.
125125
}
126126
}
127127

128-
bs, err := gojson.Marshal(map[string]interface{}{
128+
bs, err := gojson.Marshal(map[string]any{
129129
"items": objs,
130130
})
131131
if err != nil {

pkg/uuid/uuid.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (u *UUID) UnmarshalJSON(bs []byte) error {
7171
return nil
7272
}
7373

74-
func (u UUID) MarshalYAML() (interface{}, error) {
74+
func (u UUID) MarshalYAML() (any, error) {
7575
if u == Nil {
7676
return "", nil
7777
}
@@ -105,7 +105,7 @@ func (u *UUID) Unmarshal(v *yaml.Node) error {
105105
}
106106

107107
func MapstructureDecodeFunc() mapstructure.DecodeHookFuncType {
108-
return func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
108+
return func(f reflect.Type, t reflect.Type, data any) (any, error) {
109109
if f == reflect.TypeOf("") && t == reflect.TypeOf(Nil) {
110110
s := data.(string)
111111

plugins/builtin/object_create/plugin_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ object: |
124124
}
125125
require.NoError(t, plugin.Run(context.Background(), req, hclog.Default()))
126126
vpa := &unstructured.Unstructured{
127-
Object: map[string]interface{}{
127+
Object: map[string]any{
128128
"apiVersion": "vpcresources.k8s.aws/v1beta1",
129129
"kind": "SecurityGroupPolicy",
130130
"metadata": map[string]any{

0 commit comments

Comments
 (0)