Skip to content

Commit b91c8a0

Browse files
Matthew FisherApsOps
authored andcommitted
feat(gitreceive): add app envvars to DOCKER_BUILD_ARGS
This environment variable will be handled by dockerbuilder to inject into the Docker image as build time args.
1 parent 7fd02cb commit b91c8a0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

pkg/gitreceive/k8s_util.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gitreceive
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"time"
67

@@ -58,6 +59,16 @@ func dockerBuilderPod(
5859

5960
pod := buildPod(debug, name, namespace, pullPolicy, env)
6061

62+
// inject application envvars as a special envvar which will be handled by dockerbuilder to
63+
// inject them as build-time variables.
64+
// NOTE(bacongobbler): docker-py takes buildargs as a json string in the form of
65+
//
66+
// {"KEY": "value"}
67+
//
68+
// So we need to translate the map into json.
69+
dockerBuildArgs, _ := json.Marshal(env)
70+
addEnvToPod(pod, "DOCKER_BUILD_ARGS", dockerBuildArgs)
71+
6172
pod.Spec.Containers[0].Name = dockerBuilderName
6273
pod.Spec.Containers[0].Image = image
6374

0 commit comments

Comments
 (0)