Skip to content

Commit 67af3e1

Browse files
committed
Allow mounting multiple secrets
1 parent 93992eb commit 67af3e1

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

.buildkite/pipeline.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ steps:
55
- uname -a
66
- echo 'Hello, World!'
77
- ls -lR /foo
8-
- cat /foo/bar/foo
9-
- cat /foo/bar/bar
108
plugins:
119
- EmbarkStudios/k8s:
1210
image: alpine
13-
mount-secret: dlntest:/foo/bar
11+
mount-secret:
12+
- dlntest:/foo/bar
13+
- dlntest2:/foo/baz

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ The name of the secret containing the git credentials used for checking out sour
125125

126126
The key of the secret value containing the SSH key used when checking out source code with SSH as transport.
127127

128-
### `mount-secret` (optional, string)
128+
### `mount-secret` (optional, string or array)
129129

130130
Mount a secret as a directory inside the container. Must be in the form of `secretName:/some/mount/path`.
131+
Multiple secrets may be mounted by specifying a list of secret/mount pairs.
131132

132-
Example: `my-secret:/my/secrets`
133+
Example: `my-secret:/my/secret`
133134

134135
### `build-path-host-path` (optional, string)
135136

lib/job.jsonnet

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,20 @@ function(jobName, agentEnv={}, stepEnvFile='') {
165165
},
166166

167167
local secretMount = {
168-
local mv = std.splitLimit(env.BUILDKITE_PLUGIN_K8S_MOUNT_SECRET, ':', 1),
169-
mount:
170-
if std.length(mv) < 2 then []
171-
else [{ mountPath: mv[1], name: mv[0] }],
172-
volume:
173-
if std.length(mv) < 2 then []
174-
else [{
175-
name: mv[0],
176-
secret: {
177-
defaultMode: 256,
178-
secretName: mv[0],
179-
},
180-
}],
168+
local cfg = [
169+
std.splitLimit(env[f], ':', 1)
170+
for f in std.objectFields(env)
171+
if std.startsWith(f, 'BUILDKITE_PLUGIN_K8S_MOUNT_SECRET')
172+
&& env[f] != ''
173+
],
174+
mount: [
175+
{ name: c[0], mountPath: c[1] }
176+
for c in cfg
177+
],
178+
volume: [
179+
{ name: c[0], secret: { secretName: c[0], defaultMode: 256 } }
180+
for c in cfg
181+
],
181182
},
182183

183184
local commandArgs =

plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ configuration:
2222
init-image:
2323
type: string
2424
mount-secret:
25-
type: [string]
25+
type: [string, array]
2626
privileged:
2727
type: boolean
2828
secret-name:

0 commit comments

Comments
 (0)