Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 f9043c3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/build/stage/imports.go
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f9043c3

Please sign in to comment.