Skip to content

Commit

Permalink
Extend the Buildpack environment variables script to other Buildpack …
Browse files Browse the repository at this point in the history
…files
  • Loading branch information
Shahul authored and Shahul committed Oct 20, 2021
1 parent 98406b2 commit afb462c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
securityContext:
runAsUser: 0
capabilities:
add:
add:
- CHOWN
command:
- chown
Expand Down Expand Up @@ -39,6 +39,19 @@ spec:
mkdir /tmp/cache /tmp/layers
echo "> Processing environment variables..."
ENV_DIR="/platform/env"
envs=($(env))
for env in "${envs[@]}"; do
IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" ]]; then
path="${ENV_DIR}/${key}"
echo -n "$value" > "$path"
fi
done
/cnb/lifecycle/creator \
'-app=$(params.shp-source-context)' \
-cache-dir=/tmp/cache \
Expand All @@ -48,6 +61,9 @@ spec:
# Store the image digest
grep digest /tmp/report.toml | tr -d ' \"\n' | sed s/digest=// > "$(results.shp-image-digest.path)"
volumeMounts:
- mountPath: /platform/env
name: platform-env
resources:
limits:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
securityContext:
runAsUser: 0
capabilities:
add:
add:
- CHOWN
command:
- chown
Expand Down Expand Up @@ -39,6 +39,19 @@ spec:
mkdir /tmp/cache /tmp/layers
echo "> Processing environment variables..."
ENV_DIR="/platform/env"
envs=($(env))
for env in "${envs[@]}"; do
IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" ]]; then
path="${ENV_DIR}/${key}"
echo -n "$value" > "$path"
fi
done
/cnb/lifecycle/creator \
'-app=$(params.shp-source-context)' \
-cache-dir=/tmp/cache \
Expand All @@ -48,6 +61,9 @@ spec:
# Store the image digest
grep digest /tmp/report.toml | tr -d ' \"\n' | sed s/digest=// > "$(results.shp-image-digest.path)"
volumeMounts:
- mountPath: /platform/env
name: platform-env
resources:
limits:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ spec:
for env in "${envs[@]}"; do
IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" && "$value" != "" ]]; then
if [[ "$key" != "" ]]; then
path="${ENV_DIR}/${key}"
echo "--> Writing ${path}..."
echo -n "$value" > "$path"
fi
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ spec:
mkdir /tmp/cache /tmp/layers
echo "> Processing environment variables..."
ENV_DIR="/platform/env"
envs=($(env))
for env in "${envs[@]}"; do
IFS='=' read -r key value string <<< "$env"
if [[ "$key" != "" ]]; then
path="${ENV_DIR}/${key}"
echo -n "$value" > "$path"
fi
done
/cnb/lifecycle/creator \
'-app=$(params.shp-source-context)' \
-cache-dir=/tmp/cache \
Expand All @@ -50,6 +63,9 @@ spec:
# Store the image digest
grep digest /tmp/report.toml | tr -d ' \"\n' | sed s/digest=// > "$(results.shp-image-digest.path)"
volumeMounts:
- mountPath: /platform/env
name: platform-env
resources:
limits:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ metadata:
spec:
source:
url: https://github.com/shipwright-io/sample-go
contextDir: source-build
contextDir: source-build-with-package
env:
- name: BP_GO_TARGETS
value: "target-build"
value: "main-package"
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,14 @@ var _ = Describe("For a Kubernetes cluster with Tekton and build installed", fun
})

Context("when a Buildpacks v3 build is defined for a golang runtime with `BP_GO_TARGETS` env", func() {

BeforeEach(func() {
testID = generateTestID("buildpacks-v3-golang")

// create the build definition
build = createBuild(
testBuild,
testID,
"test/data/build_buildpacks-v3_golang_cr+env.yaml",
"test/data/build_buildpacks-v3_golang_cr_env.yaml",
)
})

Expand Down

0 comments on commit afb462c

Please sign in to comment.