Skip to content

Commit 339df9a

Browse files
troy0820k8s-infra-cherrypick-robot
authored and
k8s-infra-cherrypick-robot
committed
delete copyNonStatusFrom function, change test case description
Signed-off-by: Troy Connor <[email protected]>
1 parent b3c83a2 commit 339df9a

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

pkg/client/fake/client.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -950,46 +950,6 @@ func dryPatch(action testing.PatchActionImpl, tracker testing.ObjectTracker) (ru
950950
return obj, nil
951951
}
952952

953-
//lint:ignore U1000 function is causing errors with status updates
954-
func copyNonStatusFrom(old, new runtime.Object) error {
955-
newClientObject, ok := new.(client.Object)
956-
if !ok {
957-
return fmt.Errorf("%T is not a client.Object", new)
958-
}
959-
// The only thing other than status we have to retain
960-
rv := newClientObject.GetResourceVersion()
961-
962-
oldMapStringAny, err := toMapStringAny(old)
963-
if err != nil {
964-
return fmt.Errorf("failed to convert old to *unstructured.Unstructured: %w", err)
965-
}
966-
newMapStringAny, err := toMapStringAny(new)
967-
if err != nil {
968-
return fmt.Errorf("failed to convert new to *unststructured.Unstructured: %w", err)
969-
}
970-
971-
// delete everything other than status in case it has fields that were not present in
972-
// the old object
973-
for k := range newMapStringAny {
974-
if k != "status" {
975-
delete(newMapStringAny, k)
976-
}
977-
}
978-
// copy everything other than status from the old object
979-
for k := range oldMapStringAny {
980-
if k != "status" {
981-
newMapStringAny[k] = oldMapStringAny[k]
982-
}
983-
}
984-
985-
if err := fromMapStringAny(newMapStringAny, new); err != nil {
986-
return fmt.Errorf("failed to convert back from map[string]any: %w", err)
987-
}
988-
newClientObject.SetResourceVersion(rv)
989-
990-
return nil
991-
}
992-
993953
// copyStatusFrom copies the status from old into new
994954
func copyStatusFrom(old, new runtime.Object) error {
995955
oldMapStringAny, err := toMapStringAny(old)

pkg/client/fake/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ var _ = Describe("Fake client", func() {
14791479
objOriginal.Status.NodeInfo.MachineID = "machine-id-from-status-update"
14801480
Expect(cmp.Diff(objOriginal, actual)).To(BeEmpty())
14811481
})
1482-
It("should not overwrite status fields of typed objects that have a status subresource on status update", func() {
1482+
It("Should only override status fields of typed objects that have a status subresource on status update", func() {
14831483
obj := &corev1.Node{
14841484
ObjectMeta: metav1.ObjectMeta{
14851485
Name: "node",

0 commit comments

Comments
 (0)