vectordotdev / helm-charts

Helm charts for Vector.
https://vector.dev
Mozilla Public License 2.0
106 stars 91 forks source link

Migrate dev-env from scripts to Makefile #212

Open nabokihms opened 2 years ago

nabokihms commented 2 years ago

I will describe the idea using the helm-docs.sh script, but it is also applicable to others.

The following tries to download helm-docs binary every time and puts the binary into the script execution folder.

# install helm-docs
curl --silent --show-error --fail --location --output /tmp/helm-docs.tar.gz https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_${OS}_x86_64.tar.gz
tar -xf /tmp/helm-docs.tar.gz helm-docs

Makefile could be an entrypoint for these interactions. We could download the binary once and then use it from the predefined directory.

bin/helm-docs: bin/helm-docs-${HELM_DOCS_VERSION}
    @ln -sf helm-docs-${HELM_DOCS_VERSION} bin/helm-docs

bin/helm-docs-${HELM_DOCS_VERSION}:
    @mkdir -p bin
    curl -L https://github.com/norwoodj/helm-docs/releases/download/v${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION}_$(shell uname)_x86_64.tar.gz | tar -zOxf - helm-docs > ./bin/helm-docs-${HELM_DOCS_VERSION} && chmod +x ./bin/helm-docs-${HELM_DOCS_VERSION}

And they use it like this

.PHONY: docs
docs: bin/helm-docs
    bin/helm-docs

It would be possible to download yq the same way.

Just an idea.

spencergilbert commented 2 years ago

Strong agree! That script is/was definitely meant to be used in CI rather than users but that's not obvious either, and we can improve this in a few ways - mostly haven't done it because it's mostly just me doing commits 😄

spencergilbert commented 1 year ago

Noting for the specific example of for helm-docs I moved the installation and check commands out of the script and directly into the gh action config here: https://github.com/vectordotdev/helm-charts/pull/263