Skip to content

Commit

Permalink
Allow the use of absolute paths in RuntimeObjectsFromPath (#205)
Browse files Browse the repository at this point in the history
Fixes #204

Co-authored-by: Ken Sipe <[email protected]>
Signed-off-by: Joe Julian <[email protected]>
  • Loading branch information
joejulian and kensipe authored Aug 24, 2020
1 parent cbc4eba commit ec93024
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/test/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,22 @@ func RuntimeObjectsFromPath(path, dir string) ([]runtime.Object, error) {
}

// it's a directory or file
paths, err := kfile.FromPath(filepath.Join(dir, path), "*.yaml")
cPath := cleanPath(path, dir)
paths, err := kfile.FromPath(cPath, "*.yaml")
if err != nil {
return nil, fmt.Errorf("failed to find YAML files in %s: %w", filepath.Join(dir, path), err)
return nil, fmt.Errorf("failed to find YAML files in %s: %w", cPath, err)
}
apply, err := kfile.ToRuntimeObjects(paths)
if err != nil {
return nil, err
}
return apply, nil
}

// cleanPath returns either the abs path or the joined path
func cleanPath(path, dir string) string {
if filepath.IsAbs(path) {
return path
}
return filepath.Join(dir, path)
}

0 comments on commit ec93024

Please sign in to comment.