Skip to content

Commit

Permalink
Rename interface{} with any
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymonSAP committed Nov 14, 2024
1 parent 7dec144 commit 90166fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions cmd/metalctl/app/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ func getMetalCrs(ctx context.Context, cl client.Client, crds []*apiextensionsv1.
return crs, nil
}

func clearFields(obj client.Object) map[string]interface{} {
func clearFields(obj client.Object) map[string]any {
so, _ := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)

for _, field := range []string{"creationTimestamp", "resourceVersion", "uid", "generation", "managedFields"} {
delete(so["metadata"].(map[string]interface{}), field)
delete(so["metadata"].(map[string]any), field)
}

if so["status"] != nil && so["status"].(map[string]interface{})["conditions"] != nil {
for _, field := range so["status"].(map[string]interface{})["conditions"].([]interface{}) {
delete(field.(map[string]interface{}), "lastTransitionTime")
if so["status"] != nil && so["status"].(map[string]any)["conditions"] != nil {
for _, field := range so["status"].(map[string]any)["conditions"].([]interface{}) {
delete(field.(map[string]any), "lastTransitionTime")
}
}

Expand Down Expand Up @@ -237,13 +237,13 @@ func moveCrds(ctx context.Context, cl client.Client, sourceCrds []*apiextensions
return
}

func moveCrs(ctx context.Context, cl client.Client, crsTrees []*Node, uid ...types.UID) (movedCrs []*unstructured.Unstructured, err error) {
func moveCrs(ctx context.Context, cl client.Client, crsTrees []*Node, ownerUid ...types.UID) (movedCrs []*unstructured.Unstructured, err error) {
movedCrs = make([]*unstructured.Unstructured, 0)

for _, crsTree := range crsTrees {
ownerReferences := crsTree.Cr.GetOwnerReferences()
if len(ownerReferences) == 1 && len(uid) == 1 {
ownerReferences[0].UID = uid[0]
if len(ownerReferences) == 1 && len(ownerUid) == 1 {
ownerReferences[0].UID = ownerUid[0]
crsTree.Cr.SetOwnerReferences(ownerReferences)
}

Expand Down
4 changes: 3 additions & 1 deletion cmd/metalctl/app/move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log/slog"

metalv1alpha1 "github.com/ironcore-dev/metal-operator/api/v1alpha1"
v1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -42,7 +43,8 @@ var _ = Describe("metalctl move", func() {
return clients.source.Get(ctx, client.ObjectKeyFromObject(sourceEndpoint), sourceEndpoint)
}).Should(Succeed())

sourceBmc := &metalv1alpha1.BMC{ObjectMeta: metav1.ObjectMeta{GenerateName: "test-"}}
sourceBmc := &metalv1alpha1.BMC{ObjectMeta: metav1.ObjectMeta{GenerateName: "test-"},
Spec: metalv1alpha1.BMCSpec{EndpointRef: &v1.LocalObjectReference{}}}
controllerutil.SetOwnerReference(sourceCommonEndpoint, sourceBmc, k8sSchema.Scheme)

Check failure on line 48 in cmd/metalctl/app/move_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `controllerutil.SetOwnerReference` is not checked (errcheck)
Expect(clients.source.Create(ctx, sourceBmc)).To(Succeed())
Eventually(func(g Gomega) error {
Expand Down

0 comments on commit 90166fe

Please sign in to comment.