Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fail when the paths sent are parent to another #1023

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/pathconverters/pathconverters.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ func MakePlanPathsAbsolute(obj interface{}, sourcePath, assetsPath string) (err

// ChangePaths changes paths which are based out of one root to another root
func ChangePaths(obj interface{}, mapping map[string]string) error {
for parent := range mapping {
for child := range mapping {
if parent != child {
if common.IsParent(child, parent) {
err := fmt.Errorf("the provided source paths %s is child of %s.", child, parent)
logrus.Errorf("%s", err)
return err
}
}
}
}
function := func(path string) (string, error) {
if path == "" {
return path, nil
Expand Down