added condition to handle the condition when hasannotation is false

Signed-off-by: Aditya Raj <adityaraj10600@gmail.com>
This commit is contained in:
Aditya Raj 2026-03-19 19:10:51 +00:00
parent cbbb19ddef
commit ad813ad86b
2 changed files with 12 additions and 3 deletions

View file

@ -101,7 +101,8 @@ func CheckOutOfBoundsSymlinks(basePath string) error {
// The source parameter influences the returned refresh paths:
// - if source hydrator configured AND source is syncSource: use sync source path (ignores annotation)
// - if source hydrator configured AND source is drySource WITH annotation: use annotation paths with drySource base
// - if source hydrator not configured: use annotation paths with source base, or empty if no annotation
// - if source hydrator not configured AND annotation present then use annotation paths with source base
// - if source hydrator not configured AND no annotation AND source.Path set: use source.Path as default
func GetSourceRefreshPaths(app *v1alpha1.Application, source v1alpha1.ApplicationSource) []string {
annotationPaths, hasAnnotation := app.Annotations[v1alpha1.AnnotationKeyManifestGeneratePaths]
@ -135,8 +136,10 @@ func GetSourceRefreshPaths(app *v1alpha1.Application, source v1alpha1.Applicatio
// add the path relative to the source path
paths = append(paths, filepath.Clean(filepath.Join(source.Path, item)))
}
} else if !hasAnnotation && source.Path != "" && app.Spec.SourceHydrator == nil {
// No annotation set then use source.Path as the default refresh path.
paths = append(paths, source.Path)
}
return paths
}

View file

@ -144,9 +144,15 @@ func Test_GetAppRefreshPaths(t *testing.T) {
expectedPaths []string
}{
{
name: "single source without annotation",
name: "single source without annotation defaults to source path",
app: getApp(nil, new("source/path")),
source: v1alpha1.ApplicationSource{Path: "source/path"},
expectedPaths: []string{"source/path"},
},
{
name: "single source without annotation and without source path",
app: getApp(nil, nil),
source: v1alpha1.ApplicationSource{},
expectedPaths: []string{},
},
{