Skip to content

Commit

Permalink
Merge pull request #42 from jsturtevant/env-fix
Browse files Browse the repository at this point in the history
Env fix for docker envsubst
  • Loading branch information
jsturtevant authored Jun 4, 2021
2 parents ad12236 + cf59263 commit 85e30b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ jobs:
env:
T: integration
WITHOUT_ENVSUBST: 1
without-envsubst-tolerations:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- id: test-runner
uses: ./.github/actions/tests
env:
T: integration
NUM_NODES: 0
WITHOUT_ENVSUBST: 1
EXTRA_GMSA_DEPLOY_ARGS: --tolerate-master
10 changes: 6 additions & 4 deletions admission-webhook/deploy/deploy-gmsa-webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ write_manifests_file() {
envsubst < "$TEMPLATE_PATH" > "$MANIFESTS_FILE"
elif [ -x "$(command -v docker)" ]; then
echo "using envsubst in docker"
TMP_FILE=$(mktemp)
trap "rm -f $TMP_FILE" EXIT
env > "$TMP_FILE"
# due to a bug in --env-file convert varaibles we care about to -e parameters
# The sed commands get only the env names before =, clean any white space, add -e to them, then make it all one line
# https://github.com/moby/moby/issues/12997#issuecomment-307665540
ENVS=`env | grep -E 'NAME|NAMESPACE|TLS|RBAC|TOLERATIONS|IMAGE|CA' | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '`

# envsubst is installed in the nginx images which we already maintain
docker run --rm -v "$TEMPLATE_PATH:$TEMPLATE_PATH" --env-file $TMP_FILE k8s.gcr.io/e2e-test-images/nginx:1.15-1 sh -c "cat $TEMPLATE_PATH | envsubst" > $MANIFESTS_FILE
docker run --rm -v "$TEMPLATE_PATH:$TEMPLATE_PATH" $ENVS k8s.gcr.io/e2e-test-images/nginx:1.15-1 sh -c "cat $TEMPLATE_PATH | envsubst" > $MANIFESTS_FILE
else
fatal_error "Unable to run envsubst"
fi
Expand Down

0 comments on commit 85e30b7

Please sign in to comment.