Skip to content

Commit b862204

Browse files
authored
fix: status condition update (#88)
1 parent c584cca commit b862204

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

controller/lifecycle/lifecycle.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,15 @@ func updateStatus(ctx context.Context, cl client.Client, original runtime.Object
250250
return err
251251
}
252252

253-
currentStatus, hasField, err := unstructured.NestedFieldCopy(currentUn, "status")
253+
currentStatus, _, err := unstructured.NestedFieldCopy(currentUn, "status")
254254
if err != nil {
255255
return err
256256
}
257-
if !hasField {
258-
return fmt.Errorf("status field not found in current object")
259-
}
260257

261-
originalStatus, hasField, err := unstructured.NestedFieldCopy(originalUn, "status")
258+
originalStatus, _, err := unstructured.NestedFieldCopy(originalUn, "status")
262259
if err != nil {
263260
return err
264261
}
265-
if !hasField {
266-
return fmt.Errorf("status field not found in current object")
267-
}
268262

269263
if equality.Semantic.DeepEqual(currentStatus, originalStatus) {
270264
log.Info().Msg("skipping status update, since they are equal")

controller/lifecycle/lifecycle_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ func TestUpdateStatus(t *testing.T) {
894894

895895
// Then
896896
assert.Error(t, err)
897-
assert.Equal(t, "status field not found in current object", err.Error())
897+
assert.Equal(t, "internal error", err.Error())
898898
})
899899
t.Run("Test UpdateStatus with no status object (current)", func(t *testing.T) {
900900
original := &pmtesting.ImplementConditions{}
@@ -904,7 +904,7 @@ func TestUpdateStatus(t *testing.T) {
904904

905905
// Then
906906
assert.Error(t, err)
907-
assert.Equal(t, "status field not found in current object", err.Error())
907+
assert.Equal(t, "internal error", err.Error())
908908
})
909909
}
910910

0 commit comments

Comments
 (0)