File tree 5 files changed +62
-0
lines changed 5 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ RUN apt update && apt install -y --no-install-recommends \
45
45
docker-ce \
46
46
docker-buildx-plugin \
47
47
jq \
48
+ openssh-client \
48
49
ca-certificates \
49
50
xz-utils \
50
51
iproute2 \
Original file line number Diff line number Diff line change @@ -277,6 +277,27 @@ version is the image's digest.
277
277
* `pull_tag`: *Optional.* **DEPRECATED. Use `get` and `load` instead.** Default
278
278
` latest` . The tag of the repository to pull down via `pull_repository`.
279
279
280
+ * `ssh_identity`: *Optional.* Set to an openssh private SSH key (it can be a file
281
+ or an inline key). This identity will be passed to `docker build` via the
282
+ ` --ssh default` argument through a temporary `ssh-agent` instance.
283
+
284
+ Examples :
285
+
286
+ ` ` ` yaml
287
+ ssh_identity: |
288
+ -----BEGIN OPENSSH PRIVATE KEY-----
289
+ 0000000000000000000000000000000000000000000000000000000000000000000000
290
+ 0000000000000000000000000000000000000000000000000000000000000000000000
291
+ 0000000000000000000000000000000000000000000000000000000000000000000000
292
+ 0000000000000000000000000000000000000000000000000000000000000000000000
293
+ 000000000000000000000000000000000000000000000000000000==
294
+ -----END OPENSSH PRIVATE KEY-----
295
+ ` ` `
296
+
297
+ ` ` ` yaml
298
+ ssh_identity: /path/to/key
299
+ ` ` `
300
+
280
301
* `tag`: **DEPRECATED - Use `tag_file` instead**
281
302
* `tag_file`: *Optional.* The value should be a path to a file containing the name
282
303
of the tag. When not set, the Docker build will be pushed with tag value set by
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ import_file=$(jq -r '.params.import_file // ""' < $payload)
126
126
127
127
pull_repository=$( jq -r ' .params.pull_repository // ""' < $payload )
128
128
pull_tag=$( jq -r ' .params.pull_tag // "latest"' < $payload )
129
+ ssh_identity=$( jq -r ' .params.ssh_identity // ""' < $payload )
129
130
target_name=$( jq -r ' .params.target_name // ""' < $payload )
130
131
131
132
if [ -n " $load " ]; then
@@ -237,6 +238,20 @@ elif [ -n "$build" ]; then
237
238
fi
238
239
fi
239
240
241
+ ssh_args=()
242
+ if [ -n " $ssh_identity " ]; then
243
+ export DOCKER_BUILDKIT=1
244
+ eval " $( ssh-agent) "
245
+ trap " ssh-agent -k; $( trap -p EXIT | cut -f2 -d \' ) " EXIT
246
+ if [ -f " $ssh_identity " ]; then
247
+ ssh-add " $ssh_identity "
248
+ else
249
+ ssh-add <( echo " $ssh_identity " )
250
+ fi
251
+ ssh_args+=(" --ssh" )
252
+ ssh_args+=(" default" )
253
+ fi
254
+
240
255
target=()
241
256
if [ -n " ${target_name} " ]; then
242
257
target+=(" --target" )
Original file line number Diff line number Diff line change
1
+ -----BEGIN OPENSSH PRIVATE KEY-----
2
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
3
+ QyNTUxOQAAACCTcY7/Q4JTr+zc5uuLSndCM8uiMBdf2H3JHTaCw1POrQAAAJiSPsoAkj7K
4
+ AAAAAAtzc2gtZWQyNTUxOQAAACCTcY7/Q4JTr+zc5uuLSndCM8uiMBdf2H3JHTaCw1POrQ
5
+ AAAEBhwFGOegUZ/wTf18i/9SNbDgZ0P/BJtPUoGHdvi2bNtJNxjv9DglOv7Nzm64tKd0Iz
6
+ y6IwF1/YfckdNoLDU86tAAAAE3NvbWVvbmVAZXhhbXBsZS5jb20BAg==
7
+ -----END OPENSSH PRIVATE KEY-----
Original file line number Diff line number Diff line change @@ -484,6 +484,24 @@ var _ = Describe("Out", func() {
484
484
})
485
485
})
486
486
487
+ Context ("When specifying ssh_identity" , func () {
488
+ It ("should set ssh args" , func () {
489
+ session := put (map [string ]interface {}{
490
+ "source" : map [string ]interface {}{
491
+ "repository" : "test" ,
492
+ },
493
+ "params" : map [string ]interface {}{
494
+ "build" : "/docker-image-resource/tests/fixtures/build" ,
495
+ "additional_tags" : "/docker-image-resource/tests/fixtures/tags" ,
496
+ "ssh_identity" : "/docker-image-resource/tests/fixtures/ssh_identity" ,
497
+ },
498
+ },
499
+ )
500
+ Expect (session .Err ).To (gbytes .Say (dockerarg (`--ssh` )))
501
+ Expect (session .Err ).To (gbytes .Say (dockerarg (`default` )))
502
+ })
503
+ })
504
+
487
505
Context ("When passing additional_tags " , func () {
488
506
It ("should push add the additional_tags" , func () {
489
507
session := put (map [string ]interface {}{
You can’t perform that action at this time.
0 commit comments