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

Function GetCommand

plugins/pass/commands/get.go:26–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24)
25
26func GetCommand() *cobra.Command {
27 cmd := &cobra.Command{
28 Use: "get NAME",
29 Args: cobra.ExactArgs(1),
30 Short: "Get a secret from a keystore.",
31 Long: "Retrieves a named secret from the local OS keychain. The secret value is masked in output.",
32 RunE: func(cmd *cobra.Command, args []string) error {
33 id, err := store.ParseID(args[0])
34 if err != nil {
35 return err
36 }
37 kc, err := StoreFrom(cmd.Context())
38 if err != nil {
39 return err
40 }
41 s, err := kc.Get(cmd.Context(), id)
42 if err != nil {
43 return err
44 }
45 _, ok := s.(*pass.PassValue)
46 if !ok {
47 return errors.New("unknown secret type")
48 }
49 cmd.Printf("ID: %s\nValue: %s\n", id.String(), "**********")
50 return nil
51 },
52 }
53 return cmd
54}

Callers 1

Test_GetCommandFunction · 0.85

Calls 4

StoreFromFunction · 0.85
GetMethod · 0.65
PrintfMethod · 0.65
StringMethod · 0.65

Tested by 1

Test_GetCommandFunction · 0.68