Skip to content

Commit

Permalink
ensure only yaml files are processed (#288)
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu McCloskey <[email protected]>
  • Loading branch information
nabuskey authored Jun 11, 2024
1 parent ce840e7 commit 5e4aca7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/localbuild/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (r *LocalbuildReconciler) reconcileCustomPkgDir(ctx context.Context, resour

for i := range files {
file := files[i]
if !file.Type().IsRegular() {
if !file.Type().IsRegular() || !util.IsYamlFile(file.Name()) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/git_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func GetWorktreeYamlFiles(parent string, wt billy.Filesystem, recurse bool) ([]s
}
paths = append(paths, rPaths...)
}
if ent.Mode().IsRegular() && (strings.HasSuffix(ent.Name(), "yaml") || strings.HasSuffix(ent.Name(), "yml")) {
if ent.Mode().IsRegular() && IsYamlFile(ent.Name()) {
paths = append(paths, fmt.Sprintf("%s/%s", parent, ent.Name()))
}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math"
"math/big"
mathrand "math/rand"
"path/filepath"
"strings"

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

return string(input[position.Int64()]), nil
}

func IsYamlFile(input string) bool {
extension := filepath.Ext(input)
return extension == ".yaml" || extension == ".yml"
}

0 comments on commit 5e4aca7

Please sign in to comment.