better messaging for `pull artifact` command

- When there's an error stat'ing the output directory flux now prints
  the error:

  Before:
  ```
  ✗ invalid output path ./ro-dir/foo
  ```

  After:
  ```
  ✗ invalid output path "./ro-dir/foo": stat ./ro-dir/foo: permission denied
  ```
- When no output directory is provided flux now explicitly says so in
  the error:

  Before:
  ```
  ✗ invalid output path
  ```

  After:
  ```
  ✗ output path cannot be empty
  ```

Signed-off-by: Max Jonas Werner <mail@makk.es>
pull/3797/head
Max Jonas Werner 2 years ago
parent 3d1173a2cd
commit 6700aac4a4
No known key found for this signature in database
GPG Key ID: EB525E0F02B52140

@ -67,11 +67,11 @@ func pullArtifactCmdRun(cmd *cobra.Command, args []string) error {
ociURL := args[0]
if pullArtifactArgs.output == "" {
return fmt.Errorf("invalid output path %s", pullArtifactArgs.output)
return fmt.Errorf("output path cannot be empty")
}
if fs, err := os.Stat(pullArtifactArgs.output); err != nil || !fs.IsDir() {
return fmt.Errorf("invalid output path %s", pullArtifactArgs.output)
return fmt.Errorf("invalid output path %q: %w", pullArtifactArgs.output, err)
}
url, err := oci.ParseArtifactURL(ociURL)

Loading…
Cancel
Save