in pkg/controller/direct/gkebackup/restoreplan_controller.go [266:385]
func restoreConfigsEqual(a, b *pb.RestoreConfig) bool {
if a == nil && b == nil {
return true
}
if a == nil || b == nil {
return false
}
// Compare VolumeDataRestorePolicy
if a.GetVolumeDataRestorePolicy() != b.GetVolumeDataRestorePolicy() {
return false
}
// Compare ClusterResourceConflictPolicy
if a.GetClusterResourceConflictPolicy() != b.GetClusterResourceConflictPolicy() {
return false
}
// Compare NamespacedResourceRestoreMode
if a.GetNamespacedResourceRestoreMode() != b.GetNamespacedResourceRestoreMode() {
return false
}
// Compare ClusterResourceRestoreScope
aScope, bScope := a.GetClusterResourceRestoreScope(), b.GetClusterResourceRestoreScope()
if (aScope == nil) != (bScope == nil) {
return false
}
if aScope != nil {
if aScope.GetAllGroupKinds() != bScope.GetAllGroupKinds() {
return false
}
if aScope.GetNoGroupKinds() != bScope.GetNoGroupKinds() {
return false
}
// Compare SelectedGroupKinds
aSelected, bSelected := aScope.GetSelectedGroupKinds(), bScope.GetSelectedGroupKinds()
if len(aSelected) != len(bSelected) {
return false
}
for i := range aSelected {
if !proto.Equal(aSelected[i], bSelected[i]) {
return false
}
}
// Compare ExcludedGroupKinds
aExcluded, bExcluded := aScope.GetExcludedGroupKinds(), bScope.GetExcludedGroupKinds()
if len(aExcluded) != len(bExcluded) {
return false
}
for i := range aExcluded {
if !proto.Equal(aExcluded[i], bExcluded[i]) {
return false
}
}
}
// Compare NamespacedResourceRestoreScope (oneof field)
// We need to check which field is set in the oneof
switch {
case a.GetAllNamespaces():
if !b.GetAllNamespaces() {
return false
}
case a.GetSelectedNamespaces() != nil:
bSelected := b.GetSelectedNamespaces()
if bSelected == nil || !proto.Equal(a.GetSelectedNamespaces(), bSelected) {
return false
}
case a.GetSelectedApplications() != nil:
bSelected := b.GetSelectedApplications()
if bSelected == nil || !proto.Equal(a.GetSelectedApplications(), bSelected) {
return false
}
case a.GetNoNamespaces():
if !b.GetNoNamespaces() {
return false
}
case a.GetExcludedNamespaces() != nil:
bExcluded := b.GetExcludedNamespaces()
if bExcluded == nil || !proto.Equal(a.GetExcludedNamespaces(), bExcluded) {
return false
}
default:
// If we get here, the oneof field might not be set in a
// Check if it's set in b
if b.GetAllNamespaces() || b.GetSelectedNamespaces() != nil ||
b.GetSelectedApplications() != nil || b.GetNoNamespaces() ||
b.GetExcludedNamespaces() != nil {
return false
}
}
// Compare SubstitutionRules
if !proto.Equal(&pb.RestoreConfig{SubstitutionRules: a.GetSubstitutionRules()},
&pb.RestoreConfig{SubstitutionRules: b.GetSubstitutionRules()}) {
return false
}
// Compare TransformationRules
if !proto.Equal(&pb.RestoreConfig{TransformationRules: a.GetTransformationRules()},
&pb.RestoreConfig{TransformationRules: b.GetTransformationRules()}) {
return false
}
// Compare VolumeDataRestorePolicyBindings
if !proto.Equal(&pb.RestoreConfig{VolumeDataRestorePolicyBindings: a.GetVolumeDataRestorePolicyBindings()},
&pb.RestoreConfig{VolumeDataRestorePolicyBindings: b.GetVolumeDataRestorePolicyBindings()}) {
return false
}
// Compare RestoreOrder
if !proto.Equal(a.GetRestoreOrder(), b.GetRestoreOrder()) {
return false
}
return true
}