From 6700aac4a4b2265f7da5559b38ebd6c1b9498f7a Mon Sep 17 00:00:00 2001 From: Max Jonas Werner Date: Thu, 13 Apr 2023 12:40:10 +0200 Subject: [PATCH] better messaging for `pull artifact` command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- cmd/flux/pull_artifact.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/flux/pull_artifact.go b/cmd/flux/pull_artifact.go index 29313f5e..105ed580 100644 --- a/cmd/flux/pull_artifact.go +++ b/cmd/flux/pull_artifact.go @@ -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)