mrsimonemms/gitpod-self-hosted

Helm template syntax

buggtb opened this issue · 6 comments

Bug description

This probably isn't a bug but you know this stuff better than me:

In the rendered template down on line 1294 and a few other places it renders
{{ extensionsGalleryItemUrl }}

I assume that is correct and I've not missed something in my hacked up install script?

When I chuck it at the kubernetes cluster and flux and stuff I get

Helm install failed: parse error at (gitpod/templates/gitpod.yaml:1294): function "extensionsGalleryItemUrl" not defined

but as soon as i remove the brackets it works fine, so I'm assuming I need to find a way to parse that into the template that its happy with so that some process can read the configmap then look up that string in a config file and replace it, if i'm not mistaken?

Steps to reproduce

lol

Expected behavior

No response

Example repository

No response

Anything else?

keep fighting the good fight!

Can you share with me (preferably here, but simon@gitpod-self-hosted.dev) what the config you're passing into the Installer is? I've not seen that error before.

This script does have to escape some Go template variables when it generated the Helm script, so I'm wondering if that's the problem

i had a prod around, i think its taking this:

docker run --rm -v=/home/barber/.kube/config:/home/barber/.kube/config -v=/home/barber/.kube/config:/root/.kube/config -v=/home/barber/Projects/gitpod-app:/home/barber/Projects/gitpod-app -w=/home/barber/Projects/gitpod-app --pull=always --entrypoint=/app/installer ghcr.io/mrsimonemms/gitpod-self-hosted/installer:latest validate config -c tmp/gitpod.config.yaml

and the config I just lifted from your repo.

resulting file attached. If you take a look at one of your own i'm just curious to know if the extensionsGalleryItemUrl is the same, if it is I'll go figure out how flux helm and helm helm are different
gitpod.txt

Yes, I was right.

If you look at:

{{`                "search": "{{extensionsGalleryItemUrl}}",`}}

that's got {{ at the start, which is from this line in the install.sh file.

This file will only work if run via helm install or helm upgrade, not kubectl apply. That's because Helm parses all template files as Golang templates, but the extensionsGalleryItemUrl is already a Golang template which we actually want to put into the config map as-is.

So, the question now becomes "why the diddly-chuff is it working for me and not for you"? This line is directly lifted out of the old KOTS installer, so it's been used fairly extensively.

My guess is that Flux Helm applies this slightly differently. What you can do is put an envvar if statement around the escaping, eg:

# Put at top of install.sh
ESCAPE_HELM_CHARTS="${ESCAPE_HELM_CHARTS:-true}"

if [ "${ESCAPE_HELM_CHARTS}" = "true" ]; then
  echo "Escaping Golang variables in Helm charts"
  sed -i -r 's/(.*\{\{.*)/{{`\1`}}/' "${chart_dir}/templates/gitpod.yaml"
fi

Thanks! I'll give it a bash in a bit

if you don't do something with them they are just pruned, so i'm going to have to figure out how these are handled on the flux side

We can always do a pair session together on this if you want a bash on it