Skip to content
Permalink
Browse files
fix(stapel): changes in directories of import.include/excludePaths no…
…t triggered import

Changes in files were not taken into account if paths were not specified explicitly:
```
import:
- ...
  includePaths:
  - dir/file
```

or using asterisks:
```
import:
- ...
  includePaths:
  - dir/*
```

Thus, imports that contained `includePaths` or `excludePaths` with directories did not work correctly and related changes did not trigger importing of actual files.
  • Loading branch information
alexey-igrychev committed Sep 21, 2021
1 parent 1ac3d40 commit f9043c3316d41119e4f51ace7319a2ef2b92c5c3
Showing with 16 additions and 2 deletions.
  1. +16 −2 pkg/build/stage/imports.go
@@ -186,7 +186,12 @@ func generateChecksumCommand(from string, includePaths, excludePaths []string, r

var nameIncludeArgs []string
for _, includePath := range includePaths {
nameIncludeArgs = append(nameIncludeArgs, fmt.Sprintf("-wholename \"%s\"", path.Join(from, includePath)))
formattedPath := formatIncludeAndExcludePath(includePath)
nameIncludeArgs = append(
nameIncludeArgs,
fmt.Sprintf("-wholename \"%s\"", path.Join(from, formattedPath)),
fmt.Sprintf("-wholename \"%s\"", path.Join(from, formattedPath, "**")),
)
}

if len(nameIncludeArgs) != 0 {
@@ -195,7 +200,12 @@ func generateChecksumCommand(from string, includePaths, excludePaths []string, r

var nameExcludeArgs []string
for _, excludePath := range excludePaths {
nameExcludeArgs = append(nameExcludeArgs, fmt.Sprintf("! -wholename \"%s\"", path.Join(from, excludePath)))
formattedPath := formatIncludeAndExcludePath(excludePath)
nameExcludeArgs = append(
nameExcludeArgs,
fmt.Sprintf("! -wholename \"%s\"", path.Join(from, formattedPath)),
fmt.Sprintf("! -wholename \"%s\"", path.Join(from, formattedPath, "**")),
)
}

if len(nameExcludeArgs) != 0 {
@@ -225,6 +235,10 @@ func generateChecksumCommand(from string, includePaths, excludePaths []string, r
return command
}

func formatIncludeAndExcludePath(path string) string {
return strings.TrimRight(path, "*/")
}

func getImportID(importElm *config.Import) string {
return util.Sha256Hash(
"ImageName", importElm.ImageName,

0 comments on commit f9043c3

Please sign in to comment.