Skip to content

Commit 82c7740

Browse files
authored
Merge pull request #533 from docker/feat/pass-docs
refactor(pass): extract multi-line Long descriptions to embedded mark down
2 parents 4fd121d + b37935f commit 82c7740

6 files changed

Lines changed: 43 additions & 31 deletions

File tree

plugins/pass/command.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,15 @@ Examples:
5353
//go:embed examples.md
5454
var rootExample string
5555

56+
//go:embed long.md
57+
var rootLong string
58+
5659
// Root returns the root command for the docker-pass CLI plugin
5760
func Root(ctx context.Context, s store.Store, info commands.VersionInfo) *cobra.Command {
5861
cmd := &cobra.Command{
59-
Use: "pass set|get|ls|rm|run",
60-
Short: "Manage your local OS keychain secrets.",
61-
Long: "Docker Pass is a helper for securely storing secrets in your local OS keychain and injecting them into containers when needed.\n" +
62-
"It uses platform-specific credential storage:\n" +
63-
"\n" +
64-
" - Windows: Windows Credential Manager API\n" +
65-
" - macOS: Keychain services API\n" +
66-
" - Linux: `org.freedesktop.secrets` API (requires DBus + `gnome-keyring` or `kdewallet`)\n" +
67-
"\n" +
68-
"Secrets can be injected into running containers at runtime using the `se://` URI scheme.",
62+
Use: "pass set|get|ls|rm|run",
63+
Short: "Manage your local OS keychain secrets.",
64+
Long: strings.TrimSpace(rootLong),
6965
Example: strings.TrimSpace(rootExample),
7066
SilenceUsage: true,
7167
TraverseChildren: true,

plugins/pass/commands/run.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,19 @@ func (e *ExitCodeError) Error() string {
5252
//go:embed run_example.md
5353
var runExample string
5454

55+
//go:embed run_long.md
56+
var runLong string
57+
5558
type runOpts struct {
5659
envFiles []string
5760
}
5861

5962
func RunCommand() *cobra.Command {
6063
opts := runOpts{}
6164
cmd := &cobra.Command{
62-
Use: "run -- CMD [ARGS...]",
63-
Short: "Run a command with `se://` environment references resolved.",
64-
Long: "Scans the current environment (plus any `--env-file` inputs) for variables\n" +
65-
"whose value is exactly `se://<ID|pattern>`. Each reference is resolved through the\n" +
66-
"secrets-engine daemon and the resolved value is passed to the child process.\n" +
67-
"The child inherits stdin, stdout, and stderr.\n" +
68-
"\n" +
69-
"Requires the secrets-engine daemon (Docker Desktop) to be running.\n" +
70-
"\n" +
71-
"If any reference cannot be resolved, the command fails before the child is\n" +
72-
"started and exits non-zero.",
65+
Use: "run -- CMD [ARGS...]",
66+
Short: "Run a command with `se://` environment references resolved.",
67+
Long: strings.Trim(runLong, "\n"),
7368
Example: strings.Trim(runExample, "\n"),
7469
Args: cobra.MinimumNArgs(1),
7570
RunE: func(cmd *cobra.Command, args []string) error {

plugins/pass/commands/run_long.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Scans the current environment (plus any `--env-file` inputs) for variables
2+
whose value is exactly `se://<ID|pattern>`. Each reference is resolved through the
3+
secrets-engine daemon and the resolved value is passed to the child process.
4+
The child inherits stdin, stdout, and stderr.
5+
6+
Requires the secrets-engine daemon (Docker Desktop) to be running.
7+
8+
If any reference cannot be resolved, the command fails before the child is
9+
started and exits non-zero.

plugins/pass/commands/set.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import (
3333
//go:embed set_example.md
3434
var setExample string
3535

36+
//go:embed set_long.md
37+
var setLong string
38+
3639
type setOpts struct {
3740
metadata []string // raw "key=value" strings from --metadata flag
3841
force bool // if true, overwrite existing secret instead of erroring
@@ -49,16 +52,7 @@ func SetCommand(kc store.Store) *cobra.Command {
4952
Use: "set id[=value]",
5053
Aliases: []string{"store", "save"},
5154
Short: "Set a secret",
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.",
55+
Long: strings.Trim(setLong, "\n"),
6256
Example: strings.Trim(setExample, "\n"),
6357
Args: cobra.ExactArgs(1),
6458
RunE: func(cmd *cobra.Command, args []string) error {

plugins/pass/commands/set_long.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Stores a secret in the local OS keychain. The secret value can be provided inline (`NAME=VALUE`) or piped via STDIN.
2+
3+
Behavior when a secret with the same id already exists is platform-dependent:
4+
- macOS (Keychain): the command fails with a duplicate-item error.
5+
- Linux (Secret Service) and Windows (Credential Manager): the existing
6+
value is silently overwritten.
7+
8+
Pass `--force` to overwrite an existing secret. On Linux and Windows the
9+
replacement is performed atomically. On macOS the Keychain API requires
10+
a delete-then-add sequence.

plugins/pass/long.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Docker Pass is a helper for securely storing secrets in your local OS keychain and injecting them into containers when needed.
2+
It uses platform-specific credential storage:
3+
4+
- Windows: Windows Credential Manager API
5+
- macOS: Keychain services API
6+
- Linux: `org.freedesktop.secrets` API (requires DBus + `gnome-keyring` or `kdewallet`)
7+
8+
Secrets can be injected into running containers at runtime using the `se://` URI scheme.

0 commit comments

Comments
 (0)