-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolve tilda paths and validate datadir config (#4485)
Running the command `bacalhau --repo=~/some/path <command>` results in a config with a `DataDir` value of `~/some/path` rather than an expanded path, e.g.` /home/$USER/some/path`. We must handle tilda paths gracefully by expanding them to an absolute path before accepting them as configuration. Further, we must either dis-allow relative paths, or expand them to absolute paths, before accepting them as configuration. In this PR we have chosen the latter. This is because the `DataDir` field is used as the root path for our [hard-coded config paths](https://github.com/bacalhau-project/bacalhau/blob/main/pkg/config/types/paths.go#L1), and said path must be absolute when provided to docker as a volume mount point, else we get errors like: #4506 This PR adds path expansion when `DataDir` is a tilda path, and validation to enforces `DataDir` be an absolute path before accepting it as configuration. Below are some examples of valid, and invalid paths - enforced via unit tests: ### Valid ``` DataDir: "/absolute/path", DataDir: "~/absolute/path", DataDir: "~", DataDir: "~/", DataDir: "~/.", DataDir: "/path/with/special/char$", DataDir: "/path/with space", DataDir: "/absolute/path/", DataDir: "~/~/path", DataDir: "~/path/with space", DataDir: "/very/long/path/" + strings.Repeat("a", 255), DataDir: "/path/~to/file", DataDir: "~/path/~to/file", DataDir: "/path/with?invalid", ``` ### Invalid ``` DataDir: "", DataDir: "not/absolute/path", DataDir: "./not/absolute/path", DataDir: "~not/absolute/path", ``` - closes #4484 --------- Co-authored-by: frrist <[email protected]> Co-authored-by: Walid Baruni <[email protected]>
- Loading branch information
1 parent
5be6fe1
commit 329319b
Showing
7 changed files
with
326 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.