Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Build: include both major Helm version binaries in image #118

Merged
merged 3 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ SHELLCHECK_VERSION := 0.7.0
SHFMT_VERSION := 2.6.4

include docker/kubectl.version
include docker/helm.version
include docker/helm2.version
include docker/helm3.version

# NB default target architecture is amd64. If you would like to try the
# other one -- pass an ARCH variable, e.g.,
Expand All @@ -36,15 +37,15 @@ all: $(GOBIN)/bin/helm-operator build/.helm-operator.done
clean:
go clean ./cmd/helm-operator
rm -rf ./build
rm -f test/bin/kubectl test/bin/helm test/bin/kind
rm -f test/bin/kubectl test/bin/helm2 test/bin/helm3 test/bin/kind

realclean: clean
rm -rf ./cache

test: test/bin/helm
test: test/bin/helm2 test/bin/helm3
PATH="${PWD}/bin:${PWD}/test/bin:${PATH}" go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/weaveworks/flux/vendor" | sort -u)

e2e: test/bin/helm test/bin/kubectl test/e2e/bats build/.helm-operator.done
e2e: test/bin/helm2 test/bin/helm3 test/bin/kubectl test/e2e/bats build/.helm-operator.done
PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.bash

E2E_BATS_FILES := test/e2e/*.bats
Expand All @@ -68,19 +69,21 @@ build/.%.done: docker/Dockerfile.%
-f build/docker/$*/Dockerfile.$* ./build/docker/$*
touch $@

build/.helm-operator.done: build/helm-operator build/kubectl build/helm docker/ssh_config docker/known_hosts.sh docker/helm-repositories.yaml
build/.helm-operator.done: build/helm-operator build/kubectl build/helm2 build/helm3 docker/ssh_config docker/known_hosts.sh docker/helm-repositories.yaml

build/helm-operator: $(HELM_OPERATOR_DEPS)
build/helm-operator: cmd/helm-operator/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator

build/kubectl: cache/linux-$(ARCH)/kubectl-$(KUBECTL_VERSION)
test/bin/kubectl: cache/$(CURRENT_OS_ARCH)/kubectl-$(KUBECTL_VERSION)
build/helm: cache/linux-$(ARCH)/helm-$(HELM_VERSION)
test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION)
build/helm2: cache/linux-$(ARCH)/helm-$(HELM2_VERSION)
build/helm3: cache/linux-$(ARCH)/helm-$(HELM3_VERSION)
test/bin/helm2: cache/$(CURRENT_OS_ARCH)/helm-$(HELM2_VERSION)
test/bin/helm3: cache/$(CURRENT_OS_ARCH)/helm-$(HELM3_VERSION)
test/bin/shellcheck: cache/$(CURRENT_OS_ARCH)/shellcheck-$(SHELLCHECK_VERSION)
test/bin/shfmt: cache/$(CURRENT_OS_ARCH)/shfmt-$(SHFMT_VERSION)
build/kubectl test/bin/kubectl build/helm test/bin/helm test/bin/shellcheck test/bin/shfmt:
build/kubectl test/bin/kubectl build/helm2 build/helm3 test/bin/helm2 test/bin/helm3 test/bin/shellcheck test/bin/shfmt:
mkdir -p build
cp $< $@
if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-$(ARCH)" ]; then strip $@; fi
Expand All @@ -93,11 +96,18 @@ cache/%/kubectl-$(KUBECTL_VERSION): docker/kubectl.version
tar -m --strip-components 3 -C ./cache/$* -xzf cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz kubernetes/client/bin/kubectl
mv ./cache/$*/kubectl $@

cache/%/helm-$(HELM_VERSION): docker/helm.version
cache/%/helm-$(HELM2_VERSION): docker/helm2.version
mkdir -p cache/$*
curl --fail -L -o cache/$*/helm-$(HELM_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM_VERSION)-$*.tar.gz"
[ $* != "linux-$(ARCH)" ] || echo "$(HELM_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm
curl --fail -L -o cache/$*/helm-$(HELM2_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM2_VERSION)-$*.tar.gz"
[ $* != "linux-$(ARCH)" ] || echo "$(HELM2_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM2_VERSION).tar.gz" | shasum -a 256 -c
tar -m -C ./cache -xzf cache/$*/helm-$(HELM2_VERSION).tar.gz $*/helm
mv cache/$*/helm $@

cache/%/helm-$(HELM3_VERSION): docker/helm3.version
mkdir -p cache/$*
curl --fail -L -o cache/$*/helm-$(HELM3_VERSION).tar.gz "https://get.helm.sh/helm-v$(HELM3_VERSION)-$*.tar.gz"
[ $* != "linux-$(ARCH)" ] || echo "$(HELM3_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM3_VERSION).tar.gz" | shasum -a 256 -c
tar -m -C ./cache -xzf cache/$*/helm-$(HELM3_VERSION).tar.gz $*/helm
mv cache/$*/helm $@

$(GOBIN)/bin/helm-operator: $(HELM_OPERATOR_DEPS)
Expand Down
5 changes: 3 additions & 2 deletions docker/Dockerfile.helm-operator
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ RUN sh /home/flux/known_hosts.sh /etc/ssh/ssh_known_hosts && \
COPY ./ssh_config /etc/ssh/ssh_config

COPY ./kubectl /usr/local/bin/
# The Helm client is included as a convenience for troubleshooting
COPY ./helm /usr/local/bin/
# The Helm clients are included as a convenience for troubleshooting
COPY ./helm2 /usr/local/bin/
COPY ./helm3 /usr/local/bin/

# These are pretty static
LABEL maintainer="Flux CD <https://github.com/fluxcd/helm-operator/issues>" \
Expand Down
4 changes: 0 additions & 4 deletions docker/helm.version

This file was deleted.

4 changes: 4 additions & 0 deletions docker/helm2.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
HELM2_VERSION=2.16.1
HELM2_CHECKSUM_amd64=7eebaaa2da4734242bbcdced62cc32ba8c7164a18792c8acdf16c77abffce202
HELM2_CHECKSUM_arm=dc4c322191827420bedb024ae4764189b3e5a19ea62a1662b048f6ef76e0e08b
HELM2_CHECKSUM_arm64=9badab17f79a0dfc99144bc77c451c998f61f1e2c97b515743238ae316148b1d
4 changes: 4 additions & 0 deletions docker/helm3.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
HELM3_VERSION=3.0.0
HELM3_CHECKSUM_amd64=10e1fdcca263062b1d7b2cb93a924be1ef3dd6c381263d8151dd1a20a3d8c0dc
HELM3_CHECKSUM_arm=ac43445ff6942c75f338a62ed851a6ee5e01927ae09dbf2a09d0ef1a091d0647
HELM3_CHECKSUM_arm64=24c0ba00178d43435c786904fefaa9eca0dbabc605b73b15a01e4c90800d5e5c
4 changes: 2 additions & 2 deletions pkg/helm/v2/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func (h *HelmV2) DependencyUpdate(chartPath string) error {
defer os.Remove(lockfilePath)
}

cmd := exec.Command("helm", "repo", "update")
cmd := exec.Command("helm2", "repo", "update")
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("could not update repo: %s", string(out))
}

cmd = exec.Command("helm", "dep", "build", ".")
cmd = exec.Command("helm2", "dep", "build", ".")
cmd.Dir = chartPath

out, err = cmd.CombinedOutput()
Expand Down
1 change: 1 addition & 0 deletions test/e2e/lib/env.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ KNOWN_HOSTS=$(cat "${FIXTURES_DIR}/known_hosts")
export KNOWN_HOSTS
GITCONFIG=$(cat "${FIXTURES_DIR}/gitconfig")
export GITCONFIG
export HELM_VERSION=${HELM_VERSION}
13 changes: 8 additions & 5 deletions test/e2e/lib/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ source "${E2E_DIR}/lib/defer.bash"
source "${E2E_DIR}/lib/template.bash"

function install_tiller() {
if ! helm version > /dev/null 2>&1; then # only if helm isn't already installed
if ! helm2 version > /dev/null 2>&1; then # only if helm isn't already installed
kubectl --namespace kube-system create sa tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller --upgrade --wait
helm2 init --service-account tiller --upgrade --wait
fi
}

function uninstall_tiller() {
helm reset --force
helm2 reset --force
kubectl delete clusterrolebinding tiller-cluster-rule
kubectl --namespace kube-system delete sa tiller
}
Expand All @@ -26,9 +26,10 @@ function install_helm_operator_with_helm() {
create_crds='false'
fi

helm install --name helm-operator --wait \
helm2 install --name helm-operator --wait \
--namespace "${E2E_NAMESPACE}" \
--set createCRD="${create_crds}" \
--set chartsSyncInterval=10s \
--set image.repository=docker.io/fluxcd/helm-operator \
--set image.tag=latest \
--set git.pollInterval=10s \
Expand All @@ -40,11 +41,13 @@ function install_helm_operator_with_helm() {
--set configureRepositories.enable=true \
--set configureRepositories.repositories[0].name="podinfo" \
--set configureRepositories.repositories[0].url="https://stefanprodan.github.io/podinfo" \
--set extraEnvs[0].name="HELM_VERSION" \
--set extraEnvs[0].value="${HELM_VERSION:-v2\,v3}" \
"${ROOT_DIR}/chart/helm-operator"
}

function uninstall_helm_operator_with_helm() {
helm delete --purge helm-operator > /dev/null 2>&1
helm2 delete --purge helm-operator > /dev/null 2>&1
kubectl delete crd helmreleases.helm.fluxcd.io > /dev/null 2>&1
}

Expand Down
2 changes: 2 additions & 0 deletions test/e2e/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ fi
echo '>>> Running the tests'
# Run all tests by default but let users specify which ones to run, e.g. with E2E_TESTS='11_*' make e2e
E2E_TESTS=${E2E_TESTS:-.}
HELM_VERSION=${HELM_VERSION:-}
(
cd "${E2E_DIR}"
export HELM_VERSION=${HELM_VERSION}
# shellcheck disable=SC2086
"${E2E_DIR}/bats/bin/bats" -t ${E2E_TESTS}
)