Skip to content

Commit 99a6944

Browse files
committed
feat(builder): add app config to env
1 parent 3846c08 commit 99a6944

3 files changed

Lines changed: 13 additions & 29 deletions

File tree

pkg/gitreceive/build.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,6 @@ func build(
101101
return err
102102
}
103103

104-
log.Debug("got the following config back for app %s: %+v", appName, appConf)
105-
var buildPackURL string
106-
if buildPackURLInterface, ok := appConf.Values["BUILDPACK_URL"]; ok {
107-
if bpStr, ok := buildPackURLInterface.(string); ok {
108-
log.Debug("found custom buildpack URL %s", bpStr)
109-
buildPackURL = bpStr
110-
}
111-
}
112-
113104
_, disableCaching := appConf.Values["DRYCC_DISABLE_CACHE"]
114105
slugBuilderInfo := NewSlugBuilderInfo(appName, gitSha.Short(), disableCaching)
115106

@@ -214,12 +205,12 @@ func build(
214205
conf.Debug,
215206
buildPodName,
216207
conf.PodNamespace,
208+
appConf.Values,
217209
envSecretName,
218210
slugBuilderInfo.TarKey(),
219211
slugBuilderInfo.PushKey(),
220212
cacheKey,
221213
gitSha.Short(),
222-
buildPackURL,
223214
conf.StorageType,
224215
stack["image"],
225216
slugBuilderImagePullPolicy,

pkg/gitreceive/k8s_util.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ func slugbuilderPod(
103103
debug bool,
104104
name,
105105
namespace string,
106+
env map[string]interface{},
106107
envSecretName string,
107108
tarKey,
108109
putKey,
109110
cacheKey,
110111
gitShortHash string,
111-
buildpackURL,
112112
storageType,
113113
image string,
114114
pullPolicy api.PullPolicy,
@@ -145,10 +145,6 @@ func slugbuilderPod(
145145
addEnvToPod(pod, sourceVersion, gitShortHash)
146146
addEnvToPod(pod, builderStorage, storageType)
147147

148-
if buildpackURL != "" {
149-
addEnvToPod(pod, "BUILDPACK_URL", buildpackURL)
150-
}
151-
152148
return &pod
153149
}
154150

pkg/gitreceive/k8s_util_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ type slugBuildCase struct {
4646
debug bool
4747
name string
4848
namespace string
49+
env map[string]interface{}
4950
envSecretName string
5051
tarKey string
5152
putKey string
5253
cacheKey string
5354
gitShortHash string
54-
buildPack string
5555
slugBuilderImage string
5656
slugBuilderImagePullPolicy api.PullPolicy
5757
storageType string
@@ -77,6 +77,7 @@ func TestBuildPod(t *testing.T) {
7777

7878
env := make(map[string]interface{})
7979
env["KEY"] = "VALUE"
80+
env["BUILDPACK_URL"] = "buildpack"
8081
buildArgsEnv := make(map[string]interface{})
8182
buildArgsEnv["DRYCC_DOCKER_BUILD_ARGS_ENABLED"] = "1"
8283
buildArgsEnv["KEY"] = "VALUE"
@@ -93,27 +94,27 @@ func TestBuildPod(t *testing.T) {
9394
nodeSelector2["network"] = "fast"
9495

9596
slugBuilds := []slugBuildCase{
96-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", "", api.PullAlways, "", emptyNodeSelector},
97-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", "", api.PullAlways, "", emptyNodeSelector},
98-
{true, "test", "default", envSecretName, "tar", "put-url", "", "deadbeef", "", "", api.PullAlways, "", emptyNodeSelector},
99-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "buildpack", "", api.PullAlways, "", emptyNodeSelector},
100-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "buildpack", "", api.PullAlways, "", emptyNodeSelector},
101-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "buildpack", "customimage", api.PullAlways, "", nil},
102-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "buildpack", "customimage", api.PullIfNotPresent, "", nodeSelector1},
103-
{true, "test", "default", envSecretName, "tar", "put-url", "cache-url", "deadbeef", "buildpack", "customimage", api.PullNever, "", nodeSelector2},
97+
{true, "test", "default", emptyEnv, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", api.PullAlways, "", emptyNodeSelector},
98+
{true, "test", "default", emptyEnv, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", api.PullAlways, "", emptyNodeSelector},
99+
{true, "test", "default", emptyEnv, envSecretName, "tar", "put-url", "", "deadbeef", "", api.PullAlways, "", emptyNodeSelector},
100+
{true, "test", "default", env, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", api.PullAlways, "", emptyNodeSelector},
101+
{true, "test", "default", env, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "", api.PullAlways, "", emptyNodeSelector},
102+
{true, "test", "default", env, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "customimage", api.PullAlways, "", nil},
103+
{true, "test", "default", env, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "customimage", api.PullIfNotPresent, "", nodeSelector1},
104+
{true, "test", "default", env, envSecretName, "tar", "put-url", "cache-url", "deadbeef", "customimage", api.PullNever, "", nodeSelector2},
104105
}
105106

106107
for _, build := range slugBuilds {
107108
pod = slugbuilderPod(
108109
build.debug,
109110
build.name,
110111
build.namespace,
112+
build.env,
111113
build.envSecretName,
112114
build.tarKey,
113115
build.putKey,
114116
build.cacheKey,
115117
build.gitShortHash,
116-
build.buildPack,
117118
build.storageType,
118119
build.slugBuilderImage,
119120
build.slugBuilderImagePullPolicy,
@@ -140,10 +141,6 @@ func TestBuildPod(t *testing.T) {
140141
checkForEnv(t, pod, "CACHE_PATH", build.cacheKey)
141142
}
142143

143-
if build.buildPack != "" {
144-
checkForEnv(t, pod, "BUILDPACK_URL", build.buildPack)
145-
}
146-
147144
if build.slugBuilderImage != "" {
148145
if pod.Spec.Containers[0].Image != build.slugBuilderImage {
149146
t.Errorf("expected %v but returned %v ", build.slugBuilderImage, pod.Spec.Containers[0].Image)

0 commit comments

Comments
 (0)