MCPcopy Create free account
hub / github.com/docker/secrets-engine / RmCommand

Function RmCommand

plugins/pass/commands/rm.go:38–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36}
37
38func RmCommand() *cobra.Command {
39 opts := rmOpts{}
40 cmd := &cobra.Command{
41 Use: "rm name1 name2 ...",
42 Aliases: []string{"delete", "erase", "remove"},
43 Short: "Remove secrets from local keychain.",
44 Long: "Removes one or more named secrets from the local OS keychain. Use `--all` to remove every stored secret at once.",
45 Example: strings.Trim(rmExample, "\n"),
46 RunE: func(cmd *cobra.Command, args []string) error {
47 idList, err := validateArgs(args, opts)
48 if err != nil {
49 return err
50 }
51 kc, err := StoreFrom(cmd.Context())
52 if err != nil {
53 return err
54 }
55 return runRm(cmd.Context(), cmd.OutOrStdout(), kc, idList, opts)
56 },
57 }
58 flags := cmd.Flags()
59 flags.BoolVar(&opts.All, "all", false, "Remove all secrets")
60 return cmd
61}
62
63func validateArgs(args []string, opts rmOpts) ([]store.ID, error) {
64 if (len(args) == 0 && !opts.All) || (len(args) > 0 && opts.All) {

Callers 1

Test_RmCommandFunction · 0.85

Calls 3

validateArgsFunction · 0.85
StoreFromFunction · 0.85
runRmFunction · 0.85

Tested by 1

Test_RmCommandFunction · 0.68