Skip to content

Commit 5e4aca7

Browse files
authored
ensure only yaml files are processed (#288)
Signed-off-by: Manabu McCloskey <[email protected]>
1 parent ce840e7 commit 5e4aca7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

pkg/controllers/localbuild/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ func (r *LocalbuildReconciler) reconcileCustomPkgDir(ctx context.Context, resour
454454

455455
for i := range files {
456456
file := files[i]
457-
if !file.Type().IsRegular() {
457+
if !file.Type().IsRegular() || !util.IsYamlFile(file.Name()) {
458458
continue
459459
}
460460

pkg/util/git_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func GetWorktreeYamlFiles(parent string, wt billy.Filesystem, recurse bool) ([]s
8585
}
8686
paths = append(paths, rPaths...)
8787
}
88-
if ent.Mode().IsRegular() && (strings.HasSuffix(ent.Name(), "yaml") || strings.HasSuffix(ent.Name(), "yml")) {
88+
if ent.Mode().IsRegular() && IsYamlFile(ent.Name()) {
8989
paths = append(paths, fmt.Sprintf("%s/%s", parent, ent.Name()))
9090
}
9191
}

pkg/util/util.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"math"
88
"math/big"
99
mathrand "math/rand"
10+
"path/filepath"
1011
"strings"
1112

1213
"github.com/cnoe-io/idpbuilder/api/v1alpha1"
@@ -123,3 +124,8 @@ func getRandElement(input string) (string, error) {
123124

124125
return string(input[position.Int64()]), nil
125126
}
127+
128+
func IsYamlFile(input string) bool {
129+
extension := filepath.Ext(input)
130+
return extension == ".yaml" || extension == ".yml"
131+
}

0 commit comments

Comments
 (0)