Skip to content

Commit

Permalink
feat: allow helm non-root install (#180)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
rarkins and viceice authored Dec 7, 2021
1 parent e484a6b commit 91ac764
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
35 changes: 23 additions & 12 deletions src/usr/local/buildpack/tools/helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -e

require_root
check_semver ${TOOL_VERSION}


Expand All @@ -11,18 +10,30 @@ if [[ ! "${MAJOR}" || ! "${MINOR}" || ! "${PATCH}" ]]; then
exit 1
fi

if [[ -d "/usr/local/${TOOL_NAME}/${TOOL_VERSION}" ]]; then
echo "Skipping, already installed"
exit 0
fi
tool_path=$(find_tool_path)

mkdir -p /usr/local/${TOOL_NAME}/${TOOL_VERSION}
curl -sSL https://get.helm.sh/helm-v${TOOL_VERSION}-linux-amd64.tar.gz --output helm.tgz
tar --strip 1 -C /usr/local/${TOOL_NAME}/${TOOL_VERSION} -xzf helm.tgz
rm helm.tgz
function update_env () {
PATH="${1}:${PATH}"
link_wrapper ${TOOL_NAME}
}

export_path "/usr/local/${TOOL_NAME}/${TOOL_VERSION}"
if [[ -z "${tool_path}" ]]; then
INSTALL_DIR=$(get_install_dir)
base_path=${INSTALL_DIR}/${TOOL_NAME}
tool_path=${base_path}/${TOOL_VERSION}

helm version
mkdir -p ${tool_path}

file=/tmp/${TOOL_NAME}.tgz

curl -sSfLo ${file} https://get.helm.sh/helm-v${TOOL_VERSION}-linux-amd64.tar.gz
tar --strip 1 -C ${tool_path} -xf ${file}
rm ${file}

shell_wrapper helm
update_env ${tool_path}
else
echo "Already installed, resetting env"
update_env ${tool_path}
fi

helm version
6 changes: 3 additions & 3 deletions test/helm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
ARG IMAGE=containerbase/buildpack
FROM ${IMAGE} as build

USER 1000

# renovate: datasource=github-releases lookupName=helm/helm
RUN install-tool helm v3.7.1

USER 1000

RUN set -ex; helm version

RUN set -ex; \
helm repo add stable https://charts.helm.sh/stable; \
helm repo update


SHELL [ "/bin/sh", "-c" ]

RUN helm version

0 comments on commit 91ac764

Please sign in to comment.