Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/generate-manifests-demos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Generate manifests for demo
on: [push]

env:
USE_RELEASE: true
USE_RELEASE: false
RELEASE_TAG: v0.1.1

jobs:
Expand Down
26 changes: 26 additions & 0 deletions demo/.zz.auto-generated/test-app-group-1/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
4 changes: 4 additions & 0 deletions demo/charts/app-of-apps/templates/service.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions demo/overrides/app-of-apps/test-app-group-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ children:
chart: service
baz:
chart: service
skipped:
chart: service
skipManiDiffy: true
23 changes: 22 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,27 @@ import (

const InfiniteDepth = -1

const skipAnnotation = "mani-diffy.chime.com/skip"

// 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
}

// 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 false
}

// Renderer is a function that can render an Argo application.
type Renderer func(*v1alpha1.Application, string) error

Expand Down Expand Up @@ -114,7 +135,7 @@ func (w *Walker) walk(inputPath, outputPath string, depth, maxDepth int, visited
continue
}

if strings.HasSuffix(crd.ObjectMeta.Name, w.ignoreSuffix) {
if shouldSkipRender(crd, w.ignoreSuffix) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading