Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Skip checking for changes in reference field #3169

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions pkg/controller/dynamic/dynamic_controller_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"path/filepath"
"reflect"
"regexp"
"slices"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -831,14 +832,28 @@ func getChangedFields(initialObject, updatedObject map[string]interface{}, field
if !reflect.DeepEqual(initial, updated) {
for k, v := range updated {
if !reflect.DeepEqual(initial[k], v) {
if _, ok := v.(map[string]interface{}); ok {
switch v.(type) {
case map[string]interface{}:
// Skip checking for changes in resource reference fields, because there
// is no way to export the name and namespace fields (only external).
if !strings.HasSuffix(k, "Ref") {
changedFields[k] = getChangedFields(initial, updated, k)
}
} else {
changedFields[k] = updated[k]
default:
// Skip checking for changes in fields contains a list of resource references,
// because there is no way to export the name and namespace fields (only external).

// Fields containing a list of resource references do not have the "Ref" suffix in the field name.
// For example, targetResources field in ComputeFirewallPolicyRule.
// Manually add those fields to the skipped fields list.
// todo: Determine if we want to have "Refs" in those field names, like "targetResourceRefs"
// That would introduce breaking changes to DCL/TF resource
if updatedObject["kind"] == "ComputeFirewallPolicyRule" {
computeFirewallPolicyRuleSkippedFields := []string{"targetResources", "targetServiceAccounts"}
if !slices.Contains(computeFirewallPolicyRuleSkippedFields, k) {
changedFields[k] = updated[k]
}
}
}
}
}
Expand Down
Loading