Skip to content

Commit

Permalink
feat: use */* for all group kinds
Browse files Browse the repository at this point in the history
Signed-off-by: darshanime <deathbullet@gmail.com>
  • Loading branch information
darshanime committed Jun 27, 2020
1 parent 3d2f142 commit 367a751
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion util/argo/normalizers/diff_normalizer.go
Expand Up @@ -76,7 +76,7 @@ func NewIgnoreNormalizer(ignore []v1alpha1.ResourceIgnoreDifferences, overrides
func (n *ignoreNormalizer) Normalize(un *unstructured.Unstructured) error {
matched := make([]normalizerPatch, 0)
for _, patch := range n.patches {
if patch.groupKind.Group == "" && patch.groupKind.Kind == "" {
if patch.groupKind.Group == "*" && patch.groupKind.Kind == "*" {
matched = append(matched, patch)
continue
}
Expand Down
29 changes: 12 additions & 17 deletions util/settings/settings.go
Expand Up @@ -474,41 +474,36 @@ func (mgr *SettingsManager) GetResourceOverrides() (map[string]v1alpha1.Resource
}
}

ignoreStatus := v1alpha1.ResourceOverride{IgnoreDifferences: "jsonPointers:\n- /status"}
crdGK := "apiextensions.k8s.io/CustomResourceDefinition"

switch diffOptions.IgnoreResourceStatusField {
case "", "crd":
if val, ok := resourceOverrides[crdGK]; ok {
resourceOverrides[crdGK] = v1alpha1.ResourceOverride{IgnoreDifferences: val.IgnoreDifferences + "\n- /status"}
} else {
resourceOverrides[crdGK] = ignoreStatus
}
addStatusOverrideToGK(resourceOverrides, crdGK)
log.Info("Ignore status for CustomResourceDefinitions")

case "all":
if val, ok := resourceOverrides[crdGK]; ok {
resourceOverrides["/"] = v1alpha1.ResourceOverride{IgnoreDifferences: val.IgnoreDifferences + "\n- /status"}
} else {
resourceOverrides["/"] = ignoreStatus
}
addStatusOverrideToGK(resourceOverrides, "*/*")
log.Info("Ignore status for all objects")

case "off", "false":
log.Info("Not ignore status for any object")
log.Info("Not ignoring status for any object")

default:
if val, ok := resourceOverrides[crdGK]; ok {
resourceOverrides[crdGK] = v1alpha1.ResourceOverride{IgnoreDifferences: val.IgnoreDifferences + "\n- /status"}
} else {
resourceOverrides[crdGK] = ignoreStatus
}
addStatusOverrideToGK(resourceOverrides, crdGK)
log.Warnf("Unrecognized value for ignoreResourceStatusField - %s, ignore status for CustomResourceDefinitions", diffOptions.IgnoreResourceStatusField)
}

return resourceOverrides, nil
}

func addStatusOverrideToGK(resourceOverrides map[string]v1alpha1.ResourceOverride, groupKind string) {
if val, ok := resourceOverrides[groupKind]; ok {
resourceOverrides[groupKind] = v1alpha1.ResourceOverride{IgnoreDifferences: val.IgnoreDifferences + "\n- /status"}
} else {
resourceOverrides[groupKind] = v1alpha1.ResourceOverride{IgnoreDifferences: "jsonPointers:\n- /status"}
}
}

// GetResourceCompareOptions loads the resource compare options settings from the ConfigMap
func (mgr *SettingsManager) GetResourceCompareOptions() (diff.DiffOptions, error) {
// We have a sane set of default diff options
Expand Down
2 changes: 1 addition & 1 deletion util/settings/settings_test.go
Expand Up @@ -174,7 +174,7 @@ func TestGetResourceOverrides(t *testing.T) {
overrides, err = settingsManager.GetResourceOverrides()
assert.NoError(t, err)

globalOverrides := overrides["/"]
globalOverrides := overrides["*/*"]
assert.NotNil(t, globalOverrides)
assert.Equal(t, ignoreStatus, globalOverrides)

Expand Down

0 comments on commit 367a751

Please sign in to comment.