@@ -16,6 +16,7 @@ package commands
1616
1717import (
1818 "context"
19+ _ "embed"
1920 "encoding/json"
2021 "fmt"
2122 "io"
@@ -29,23 +30,8 @@ import (
2930 "github.com/docker/secrets-engine/x/secrets"
3031)
3132
32- const setExample = `
33- ### Set a secret:
34- docker pass set POSTGRES_PASSWORD=my-secret-password
35-
36- ### Or pass the secret via STDIN:
37- echo my-secret-password > pwd.txt
38- cat pwd.txt | docker pass set POSTGRES_PASSWORD
39-
40- ### Set a secret with metadata:
41- docker pass set POSTGRES_PASSWORD=my-secret-password --metadata owner=alice --metadata expiry=2027-03-01
42-
43- ### Or pass a JSON payload with secret and metadata via STDIN:
44- echo '{"secret":"my-secret-password","metadata":{"owner":"alice"}}' | docker pass set POSTGRES_PASSWORD
45-
46- ### Overwrite an existing secret:
47- docker pass set POSTGRES_PASSWORD=new-secret-password --force
48- `
33+ //go:embed set_example.md
34+ var setExample string
4935
5036type setOpts struct {
5137 metadata []string // raw "key=value" strings from --metadata flag
@@ -63,16 +49,16 @@ func SetCommand(kc store.Store) *cobra.Command {
6349 Use : "set id[=value]" ,
6450 Aliases : []string {"store" , "save" },
6551 Short : "Set a secret" ,
66- Long : ` Stores a secret in the local OS keychain. The secret value can be provided inline (NAME=VALUE) or piped via STDIN.
67-
68- Behavior when a secret with the same id already exists is platform-dependent:
69- - macOS (Keychain): the command fails with a duplicate-item error.
70- - Linux (Secret Service) and Windows (Credential Manager): the existing
71- value is silently overwritten.
72-
73- Pass --force to overwrite an existing secret. On Linux and Windows the
74- replacement is performed atomically. On macOS the Keychain API requires
75- a delete-then-add sequence.` ,
52+ Long : " Stores a secret in the local OS keychain. The secret value can be provided inline (` NAME=VALUE` ) or piped via STDIN.\n " +
53+ " \n " +
54+ " Behavior when a secret with the same id already exists is platform-dependent:\n " +
55+ " - macOS (Keychain): the command fails with a duplicate-item error.\n " +
56+ " - Linux (Secret Service) and Windows (Credential Manager): the existing\n " +
57+ " value is silently overwritten.\n " +
58+ " \n " +
59+ " Pass ` --force` to overwrite an existing secret. On Linux and Windows the\n " +
60+ " replacement is performed atomically. On macOS the Keychain API requires\n " +
61+ " a delete-then-add sequence." ,
7662 Example : strings .Trim (setExample , "\n " ),
7763 Args : cobra .ExactArgs (1 ),
7864 RunE : func (cmd * cobra.Command , args []string ) error {
0 commit comments