You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clicommand/secret_get.go
+22-24Lines changed: 22 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -38,11 +38,12 @@ Gets a list of secrets from Buildkite and prints them to stdout. Key names are c
38
38
insensitive in this command, and secret values are automatically redacted in the build logs
39
39
unless the ′skip-redaction′ flag is used.
40
40
41
-
If any request for a secret fails, the command will return a non-zero exit code and print details of all failed secrets.
41
+
If any request for a secret fails, the command will return a non-zero exit code and print
42
+
details of all failed secrets.
42
43
43
-
If only a single key is provided, the secret value will be printed without any formatting.
44
-
45
-
If multiple keys are provided, the output format will be as defined by the ′format′ flag, which defaults to JSON.
44
+
By default, when fetching a single key, the secret value will be printed without any
45
+
formatting. When fetching multiple keys, the output will be in JSON format. Output
46
+
format can be controlled explicitly with the ′format′ flag.
46
47
47
48
Examples:
48
49
@@ -52,11 +53,13 @@ Examples:
52
53
$ buildkite-agent secret get DEPLOY_KEY
53
54
"..."
54
55
55
-
# Format is ignored when only a single key is provided
56
56
$ buildkite-agent secret get --format env deploy_key
57
-
"..."
57
+
DEPLOY_KEY="..."
58
58
59
-
# JSON is the default format when multiple keys are provided
59
+
$ buildkite-agent secret get --format json deploy_key
60
+
{"deploy_key": "..."}
61
+
62
+
# JSON is the default format when multiple keys are provided...
60
63
$ buildkite-agent secret get deploy_key github_api_token
61
64
{"deploy_key": "...", "github_api_token": "..."}
62
65
@@ -72,8 +75,8 @@ Examples:
72
75
},
73
76
cli.StringFlag{
74
77
Name: "format",
75
-
Usage: "The output format, either 'json' (default) or 'env'. Ignored when only a single key is provided",
76
-
Value: "json",
78
+
Usage: "The output format, either 'default', 'json', or 'env'. When 'default', a single secret will print just the value, while multiple secrets will print JSON. When 'json' or 'env', secrets will be printed as key-value pairs in the requested format",
79
+
Value: "default",
77
80
EnvVar: "BUILDKITE_AGENT_SECRET_GET_FORMAT",
78
81
},
79
82
cli.BoolFlag{
@@ -91,8 +94,8 @@ Examples:
91
94
returnerrors.New("at least one secret key must be provided")
92
95
}
93
96
94
-
ifcfg.Format!="json"&&cfg.Format!="env" {
95
-
returnfmt.Errorf("invalid format %q: must be either 'json' or 'env'", cfg.Format)
0 commit comments