Skip to content

Commit

Permalink
operator v1: treat "null" as null for drift detection
Browse files Browse the repository at this point in the history
this stops operator from detecting non-existing drifts over and over
again, if "null" is used to set `null`. Since
spec.additionalConfiguration is map[string]string, string "null" is the
only way to set `null.`
  • Loading branch information
birdayz committed Nov 20, 2024
1 parent c102390 commit 09ecb1c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions operator/pkg/resources/configuration/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ func PropertiesEqual(
l logr.Logger, v1, v2 interface{}, metadata rpadmin.ConfigPropertyMetadata,
) bool {
log := l.WithName("PropertiesEqual")

// "null" (string) is the only way to define null as the desired value.
// Therefore, treat `"null"` as equal to `null` (only if `null`
if metadata.Nullable {
if v1 == "null" && v2 == nil {
return true
}
}
switch metadata.Type {
case "number":
if f1, f2, ok := bothFloat64(v1, v2); ok {
Expand Down

0 comments on commit 09ecb1c

Please sign in to comment.