File tree Expand file tree Collapse file tree 5 files changed +41
-0
lines changed Expand file tree Collapse file tree 5 files changed +41
-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,10 @@ 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 file
281
+ this identity will be passed to `docker build` via the `--ssh default` argument
282
+ through a temporary `ssh-agent` instance.
283
+
280
284
* `tag`: **DEPRECATED - Use `tag_file` instead**
281
285
* `tag_file`: *Optional.* The value should be a path to a file containing the name
282
286
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,16 @@ 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
+ ssh-add " $ssh_identity "
247
+ ssh_args+=(" --ssh" )
248
+ ssh_args+=(" default" )
249
+ fi
250
+
240
251
target=()
241
252
if [ -n " ${target_name} " ]; then
242
253
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