helm-subenv icon indicating copy to clipboard operation
helm-subenv copied to clipboard

Fields are empty after execution

Open khauser opened this issue 2 years ago • 3 comments

values.yaml

icm:
  icm-as:
    image:
      repository: "${ICM_TEST_IMAGE}"

environment.sh

#!/usr/bin/env bash
ICM_TEST_IMAGE="whatever"

After executing source ./environment.sh and helm subenv -f values.yaml the env variable is replaced with an empty string.

My base image for execution is ubuntu-20.4-DS1_v2-adopt-adoptium-jdk with the following RUN cmd to install helm:

RUN apk add --no-cache ca-certificates bash git openssh curl \
    && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl \
    && chmod +x /usr/local/bin/kubectl \
    && wget -q https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \
    && chmod +x /usr/local/bin/helm

khauser avatar Feb 09 '23 15:02 khauser

Hello, @khauser I will try replicating this issue and get back to you.

hydeenoble avatar Mar 10 '23 11:03 hydeenoble

Thanks in advance For now I use envsubst directly without any helm plugin:

set -o allexport
source environment.sh
set +o allexport

# puts envs into a comma separated list with dollar signs
env_list=$(env | cut -d '=' -f 1 | sed 's/^/\$/;s/$/,/' | tr -d '\n' | sed 's/,$//')

# now only env variables are replaced in values template
envsubst "${env_list}" < ./values.tmpl | tee values.yaml

khauser avatar Mar 10 '23 12:03 khauser

So far, I have been able to detect that the helm-subenv plugin doesn't see environment variables created using only the source command. For environment variables to be accessible/visible to the plugin, export has to be used.

something like:

export ICM_TEST_IMAGE=somevalue

this would work.

hydeenoble avatar Mar 14 '23 09:03 hydeenoble