diff --git a/cmd/notation/key.go b/cmd/notation/key.go index aff21f636..9764bdbd0 100644 --- a/cmd/notation/key.go +++ b/cmd/notation/key.go @@ -4,9 +4,10 @@ import ( "context" "errors" "fmt" - "github.com/notaryproject/notation-go/config" "os" + "github.com/notaryproject/notation-go/config" + "github.com/notaryproject/notation-go/log" "github.com/notaryproject/notation/internal/cmd" "github.com/notaryproject/notation/internal/ioutil" @@ -74,7 +75,7 @@ func keyAddCommand(opts *keyAddOpts) *cobra.Command { } command := &cobra.Command{ Use: "add --plugin [flags] ", - Short: "Add key to signing key list", + Short: "Add key to Notation signing key list", Args: func(cmd *cobra.Command, args []string) error { if len(args) != 1 { return errors.New("either missing key name or unnecessary parameters passed") @@ -105,7 +106,7 @@ func keyUpdateCommand(opts *keyUpdateOpts) *cobra.Command { command := &cobra.Command{ Use: "update [flags] ", Aliases: []string{"set"}, - Short: "Update key in signing key list", + Short: "Update key in Notation signing key list", Args: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return errors.New("missing key name") @@ -142,7 +143,7 @@ func keyDeleteCommand(opts *keyDeleteOpts) *cobra.Command { command := &cobra.Command{ Use: "delete [flags] ...", - Short: "Delete key from signing key list", + Short: "Remove key from Notation signing key list", Args: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return errors.New("missing key names") @@ -243,11 +244,21 @@ func deleteKeys(ctx context.Context, opts *keyDeleteOpts) error { } // write out - for _, name := range deletedNames { - if prevDefault == name { - fmt.Printf("%s: unmarked as default\n", name) + if len(deletedNames) == 1 { + name := deletedNames[0] + if name == prevDefault { + fmt.Printf("Removed default key %s from Notation signing key list. The source key still exists.\n", name) } else { - fmt.Println(name) + fmt.Printf("Removed %s from Notation signing key list. The source key still exists.\n", name) + } + } else if len(deletedNames) > 1 { + fmt.Println("Removed the following keys from Notation signing key list. The source keys still exist.") + for _, name := range deletedNames { + if name == prevDefault { + fmt.Println(name, "(default)") + } else { + fmt.Println(name) + } } } return nil diff --git a/specs/commandline/key.md b/specs/commandline/key.md index bc5b64a64..dbd9fd72a 100644 --- a/specs/commandline/key.md +++ b/specs/commandline/key.md @@ -132,6 +132,12 @@ Removed from Notation signing key list. The source key still exists. Removed from Notation signing key list. The source key still exists. ``` +- Upon successful removal of the default key, the output message is printed out as follows: + +```text +Removed default key from Notation signing key list. The source key still exists. +``` + ### Remove two keys from Notation signing key list ```shell @@ -143,5 +149,5 @@ Upon successful execution, the output message is printed out as follows. Please ```text Removed the following keys from Notation signing key list. The source keys still exist. - + (default) ``` \ No newline at end of file