Skip to content

Commit

Permalink
Skip existing Kitfiles when generating a new Kitfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
amisevsk committed Dec 18, 2024
1 parent adf3372 commit 0359443
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/lib/constants/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ func DefaultKitfileNames() []string {
return []string{"Kitfile", "kitfile", ".kitfile"}
}

func IsDefaultKitfileName(filename string) bool {
for _, name := range DefaultKitfileNames() {
if name == filename {
return true
}
}
return false
}

// DefaultConfigPath returns the default configuration and cache directory for the CLI.
// This is platform-dependent, using
// - $XDG_DATA_HOME/kitops on Linux, with fall back to $HOME/.local/share/kitops
Expand Down
6 changes: 6 additions & 0 deletions pkg/lib/kitfile/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"io/fs"
"kitops/pkg/artifact"
"kitops/pkg/lib/constants"
"kitops/pkg/output"
"os"
"path/filepath"
Expand Down Expand Up @@ -91,6 +92,11 @@ func GenerateKitfile(baseDir string, packageOpt *artifact.Package) (*artifact.Ki
var detectedLicenseType string
for _, d := range ds {
filename := d.Name()
if constants.IsDefaultKitfileName(filename) {
// Skip Kitfile files (if present in the directory...). These won't be packed
// either way.
continue
}
if d.IsDir() {
dirModelFiles, err := addDirToKitfile(kitfile, filename, d)
if err != nil {
Expand Down

0 comments on commit 0359443

Please sign in to comment.