Skip to content

Commit df8e3ac

Browse files
ejholmesclaude
andcommitted
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 <[email protected]>
1 parent 4e596d6 commit df8e3ac

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

main.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@ const InfiniteDepth = -1
2222

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

25-
// shouldSkipRender checks if an Application should be skipped based on the
26-
// mani-diffy.chime.com/skip annotation. Returns true if the annotation
27-
// is explicitly set to "true".
28-
func shouldSkipRender(app *v1alpha1.Application) bool {
29-
if app.ObjectMeta.Annotations == nil {
30-
return false
25+
// shouldSkipRender checks if an Application should be skipped based on:
26+
// 1. The application name suffix (ignoreSuffix)
27+
// 2. The mani-diffy.chime.com/skip annotation set to "true"
28+
func shouldSkipRender(app *v1alpha1.Application, ignoreSuffix string) bool {
29+
// Check if the application name has the ignore suffix
30+
if strings.HasSuffix(app.ObjectMeta.Name, ignoreSuffix) {
31+
return true
3132
}
32-
value, ok := app.ObjectMeta.Annotations[skipAnnotation]
33-
if !ok {
34-
return false
33+
34+
// Check if the skip annotation is set to "true"
35+
if app.ObjectMeta.Annotations != nil {
36+
if value, ok := app.ObjectMeta.Annotations[skipAnnotation]; ok && value == "true" {
37+
return true
38+
}
3539
}
36-
return value == "true"
40+
41+
return false
3742
}
3843

3944
// 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
130135
continue
131136
}
132137

133-
if strings.HasSuffix(crd.ObjectMeta.Name, w.ignoreSuffix) {
134-
continue
135-
}
136-
137-
// Skip Applications with the mani-diffy.chime.com/skip annotation set to "true"
138-
if shouldSkipRender(crd) {
138+
if shouldSkipRender(crd, w.ignoreSuffix) {
139139
continue
140140
}
141141

0 commit comments

Comments
 (0)