From 28ec01c3fdd97dc4858d841edab221742a22e88d Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Thu, 11 Dec 2025 15:31:55 -0800 Subject: [PATCH 1/5] Add support for skipping Applications via annotation Applications can now be skipped during rendering by setting the com.chime.mani-diffy/render annotation to "false". This allows selective control over which Applications are processed by mani-diffy. When an Application has this annotation set to "false", it will be skipped with a log message indicating why it was skipped. Co-Authored-By: Claude Sonnet 4.5 --- main.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/main.go b/main.go index 212c071..947f75e 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,22 @@ import ( const InfiniteDepth = -1 +const renderAnnotation = "com.chime.mani-diffy/render" + +// shouldSkipRender checks if an Application should be skipped based on the +// com.chime.mani-diffy/render annotation. Returns true if the annotation +// is explicitly set to "false". +func shouldSkipRender(app *v1alpha1.Application) bool { + if app.ObjectMeta.Annotations == nil { + return false + } + value, ok := app.ObjectMeta.Annotations[renderAnnotation] + if !ok { + return false + } + return value == "false" +} + // Renderer is a function that can render an Argo application. type Renderer func(*v1alpha1.Application, string) error @@ -118,6 +134,12 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited continue } + // Skip Applications with the com.chime.mani-diffy/render annotation set to "false" + if shouldSkipRender(crd) { + log.Printf("Skipping %s (com.chime.mani-diffy/render annotation is false)\n", crd.ObjectMeta.Name) + continue + } + path := filepath.Join(outputPath, crd.ObjectMeta.Name) visited[path] = true From 212d52ed60ca42c577f236c78a34a401343909a1 Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Thu, 11 Dec 2025 15:37:17 -0800 Subject: [PATCH 2/5] Change annotation to mani-diffy.chime.com/skip: "true" Updated the annotation to follow Kubernetes best practices: - Use forward domain format (mani-diffy.chime.com instead of com.chime.mani-diffy) - More intuitive naming: skip: "true" instead of render: "false" - Clearer intent and semantics Co-Authored-By: Claude Sonnet 4.5 --- main.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 947f75e..c0047c7 100644 --- a/main.go +++ b/main.go @@ -20,20 +20,20 @@ import ( const InfiniteDepth = -1 -const renderAnnotation = "com.chime.mani-diffy/render" +const skipAnnotation = "mani-diffy.chime.com/skip" // shouldSkipRender checks if an Application should be skipped based on the -// com.chime.mani-diffy/render annotation. Returns true if the annotation -// is explicitly set to "false". +// mani-diffy.chime.com/skip annotation. Returns true if the annotation +// is explicitly set to "true". func shouldSkipRender(app *v1alpha1.Application) bool { if app.ObjectMeta.Annotations == nil { return false } - value, ok := app.ObjectMeta.Annotations[renderAnnotation] + value, ok := app.ObjectMeta.Annotations[skipAnnotation] if !ok { return false } - return value == "false" + return value == "true" } // Renderer is a function that can render an Argo application. @@ -134,9 +134,9 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited continue } - // Skip Applications with the com.chime.mani-diffy/render annotation set to "false" + // Skip Applications with the mani-diffy.chime.com/skip annotation set to "true" if shouldSkipRender(crd) { - log.Printf("Skipping %s (com.chime.mani-diffy/render annotation is false)\n", crd.ObjectMeta.Name) + log.Printf("Skipping %s (mani-diffy.chime.com/skip annotation is true)\n", crd.ObjectMeta.Name) continue } From 71080df374c377bd9938f28f671f3ddbe15c4d1d Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Fri, 12 Dec 2025 09:24:10 -0800 Subject: [PATCH 3/5] Add demo for mani-diffy.chime.com/skip annotation - Updated service.tpl to conditionally add the skip annotation - Added test-service-skipped with skipManiDiffy: true - Regenerated manifests showing the annotation in action Co-Authored-By: Claude Sonnet 4.5 --- .../workflows/generate-manifests-demos.yaml | 2 +- .../test-app-group-1/manifest.yaml | 26 +++++++++++++++++++ demo/charts/app-of-apps/templates/service.tpl | 4 +++ .../app-of-apps/test-app-group-1.yaml | 3 +++ pkg/helm/helm_test.go | 2 +- 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-manifests-demos.yaml b/.github/workflows/generate-manifests-demos.yaml index 1c53c8f..07c486f 100644 --- a/.github/workflows/generate-manifests-demos.yaml +++ b/.github/workflows/generate-manifests-demos.yaml @@ -2,7 +2,7 @@ name: Generate manifests for demo on: [push] env: - USE_RELEASE: true + USE_RELEASE: false RELEASE_TAG: v0.1.1 jobs: diff --git a/demo/.zz.auto-generated/test-app-group-1/manifest.yaml b/demo/.zz.auto-generated/test-app-group-1/manifest.yaml index f0338bc..f6909d5 100644 --- a/demo/.zz.auto-generated/test-app-group-1/manifest.yaml +++ b/demo/.zz.auto-generated/test-app-group-1/manifest.yaml @@ -70,3 +70,29 @@ spec: - ../../overrides/service/foo/test.yaml syncPolicy: automated: {} +--- +# Source: app-of-apps/templates/apps.yaml +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: test-service-skipped + annotations: + mani-diffy.chime.com/skip: "true" +spec: + destination: + namespace: argocd + server: https://kubernetes.default.svc + project: default + source: + repoURL: https://github.com/chime/mani-diffy.git + path: charts/service + helm: + version: v3 + parameters: + - name: env + value: test + valueFiles: + - ../../overrides/service/skipped/base.yaml + - ../../overrides/service/skipped/test.yaml + syncPolicy: + automated: {} diff --git a/demo/charts/app-of-apps/templates/service.tpl b/demo/charts/app-of-apps/templates/service.tpl index 35b1e41..1078716 100644 --- a/demo/charts/app-of-apps/templates/service.tpl +++ b/demo/charts/app-of-apps/templates/service.tpl @@ -5,6 +5,10 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: {{ .root.env }}-service-{{ $appName }} + {{- if .childParams.skipManiDiffy }} + annotations: + mani-diffy.chime.com/skip: "true" + {{- end }} spec: destination: namespace: argocd diff --git a/demo/overrides/app-of-apps/test-app-group-1.yaml b/demo/overrides/app-of-apps/test-app-group-1.yaml index bc5d5ab..46f33a2 100644 --- a/demo/overrides/app-of-apps/test-app-group-1.yaml +++ b/demo/overrides/app-of-apps/test-app-group-1.yaml @@ -5,3 +5,6 @@ children: chart: service baz: chart: service + skipped: + chart: service + skipManiDiffy: true diff --git a/pkg/helm/helm_test.go b/pkg/helm/helm_test.go index 2cf7073..7818cac 100644 --- a/pkg/helm/helm_test.go +++ b/pkg/helm/helm_test.go @@ -321,7 +321,7 @@ kind: Application t.Run("GenerateHashOnChart", func(t *testing.T) { hash, _ := generalHashFunction("demo/charts/app-of-apps") h := hex.EncodeToString(hash) - actualHash := "13aa148adefa3d633e5ce95584d3c95297a4417977837040cd67f0afbca17b5a" + actualHash := "f57ffb63de221520249492e247beb6d6f61cd378e7c246909cca9c5110a6bb28" if h != actualHash { t.Errorf("Failed to generate a generic hash on a chart. got: %s wanted: %s", h, actualHash) } From 4e596d67639b5c9c72abb22a5fd4935d72c76f6c Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Fri, 12 Dec 2025 09:41:26 -0800 Subject: [PATCH 4/5] Remove logging for closer parity with -ignore-suffix --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index c0047c7..31dea8e 100644 --- a/main.go +++ b/main.go @@ -136,7 +136,6 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited // Skip Applications with the mani-diffy.chime.com/skip annotation set to "true" if shouldSkipRender(crd) { - log.Printf("Skipping %s (mani-diffy.chime.com/skip annotation is true)\n", crd.ObjectMeta.Name) continue } From df8e3acab92f8b7b4a04a8736e086c975eae8d78 Mon Sep 17 00:00:00 2001 From: "Eric J. Holmes" Date: Fri, 12 Dec 2025 09:45:49 -0800 Subject: [PATCH 5/5] Refactor: consolidate skip logic into shouldSkipRender Moved the ignoreSuffix check into shouldSkipRender function to centralize all skip logic in one place. This makes it easier to understand and maintain the conditions under which an Application should be skipped. Co-Authored-By: Claude Sonnet 4.5 --- main.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index 31dea8e..03e65cb 100644 --- a/main.go +++ b/main.go @@ -22,18 +22,23 @@ const InfiniteDepth = -1 const skipAnnotation = "mani-diffy.chime.com/skip" -// shouldSkipRender checks if an Application should be skipped based on the -// mani-diffy.chime.com/skip annotation. Returns true if the annotation -// is explicitly set to "true". -func shouldSkipRender(app *v1alpha1.Application) bool { - if app.ObjectMeta.Annotations == nil { - return false +// shouldSkipRender checks if an Application should be skipped based on: +// 1. The application name suffix (ignoreSuffix) +// 2. The mani-diffy.chime.com/skip annotation set to "true" +func shouldSkipRender(app *v1alpha1.Application, ignoreSuffix string) bool { + // Check if the application name has the ignore suffix + if strings.HasSuffix(app.ObjectMeta.Name, ignoreSuffix) { + return true } - value, ok := app.ObjectMeta.Annotations[skipAnnotation] - if !ok { - return false + + // Check if the skip annotation is set to "true" + if app.ObjectMeta.Annotations != nil { + if value, ok := app.ObjectMeta.Annotations[skipAnnotation]; ok && value == "true" { + return true + } } - return value == "true" + + return false } // Renderer is a function that can render an Argo application. @@ -130,12 +135,7 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited continue } - if strings.HasSuffix(crd.ObjectMeta.Name, w.ignoreSuffix) { - continue - } - - // Skip Applications with the mani-diffy.chime.com/skip annotation set to "true" - if shouldSkipRender(crd) { + if shouldSkipRender(crd, w.ignoreSuffix) { continue }