From b595f640f7effb3f5df2722e6af4bb0e97d7739f Mon Sep 17 00:00:00 2001 From: Junjie Gao Date: Mon, 30 Dec 2024 07:26:02 +0000 Subject: [PATCH] fix: resolve comments Signed-off-by: Junjie Gao --- cmd/notation/blob/cmd.go | 2 +- cmd/notation/blob/policy/import.go | 6 +++--- cmd/notation/blob/policy/show.go | 6 +++--- cmd/notation/policy/import.go | 4 ++-- cmd/notation/policy/show.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/notation/blob/cmd.go b/cmd/notation/blob/cmd.go index 4a83becfc..c491b81fb 100644 --- a/cmd/notation/blob/cmd.go +++ b/cmd/notation/blob/cmd.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package blob provides the command for blob trust policy configuration. +// Package blob provides blob sign, verify, inspect, and policy commands. package blob import ( diff --git a/cmd/notation/blob/policy/import.go b/cmd/notation/blob/policy/import.go index 0406768ea..6391b975c 100644 --- a/cmd/notation/blob/policy/import.go +++ b/cmd/notation/blob/policy/import.go @@ -51,7 +51,7 @@ Example - Import trust policy configuration from a file: return runImport(opts) }, } - command.Flags().BoolVar(&opts.force, "force", false, "override the existing trust policy configuration, never prompt") + command.Flags().BoolVar(&opts.force, "force", false, "override the existing blob trust policy configuration, never prompt") return command } @@ -82,7 +82,7 @@ func runImport(opts importOpts) error { } } } else { - fmt.Fprintln(os.Stderr, "Warning: existing blob trust policy configuration file will be overwritten") + fmt.Fprintln(os.Stderr, "Warning: existing blob trust policy file will be overwritten") } // write @@ -94,6 +94,6 @@ func runImport(opts importOpts) error { return fmt.Errorf("failed to write blob trust policy file: %w", err) } - _, err = fmt.Fprintln(os.Stdout, "Blob trust policy configuration imported successfully.") + _, err = fmt.Fprintln(os.Stdout, "Successfully imported blob trust policy file.") return err } diff --git a/cmd/notation/blob/policy/show.go b/cmd/notation/blob/policy/show.go index f8d9872ea..38b7f5380 100644 --- a/cmd/notation/blob/policy/show.go +++ b/cmd/notation/blob/policy/show.go @@ -59,9 +59,9 @@ func runShow() error { err = doc.Validate() } if err != nil { - fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "Existing blob trust policy configuration is invalid, you may update or create a new one via `notation blob policy import `\n") - // not returning to show the invalid policy configuration + fmt.Fprintf(os.Stderr, "Existing blob trust policy file is invalid, you may update or create a new one via `notation blob policy import `\n") + os.Stdout.Write(policyJSON) + return err } // show policy content diff --git a/cmd/notation/policy/import.go b/cmd/notation/policy/import.go index 1e1f3191b..b6a5110df 100644 --- a/cmd/notation/policy/import.go +++ b/cmd/notation/policy/import.go @@ -85,7 +85,7 @@ func runImport(opts importOpts) error { } } } else { - fmt.Fprintln(os.Stderr, "Warning: existing trust policy configuration file will be overwritten") + fmt.Fprintln(os.Stderr, "Warning: existing trust policy file will be overwritten") } // write @@ -106,6 +106,6 @@ func runImport(opts importOpts) error { fmt.Fprintf(os.Stderr, "Warning: failed to clear old trust policy %q: %v\n", oldPolicyPath, err) } - _, err = fmt.Fprintln(os.Stdout, "Trust policy configuration imported successfully.") + _, err = fmt.Fprintln(os.Stdout, "Successfully imported trust policy file.") return err } diff --git a/cmd/notation/policy/show.go b/cmd/notation/policy/show.go index 5bce6a5b2..7e5461b31 100644 --- a/cmd/notation/policy/show.go +++ b/cmd/notation/policy/show.go @@ -62,7 +62,7 @@ func runShow() error { } if err != nil { fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error()) - fmt.Fprintf(os.Stderr, "Existing trust policy configuration is invalid, you may update or create a new one via `notation policy import `\n") + fmt.Fprintf(os.Stderr, "Existing trust policy file is invalid, you may update or create a new one via `notation policy import `\n") // not returning to show the invalid policy configuration }