Merge pull request #930 from roboll/helm-v3-fixes-and-integration-test
Make helmfile + helm v3 pass the integration test suite
This commit is contained in:
commit
8fc546ae86
|
|
@ -103,6 +103,51 @@ jobs:
|
||||||
export TERM=xterm
|
export TERM=xterm
|
||||||
make integration
|
make integration
|
||||||
|
|
||||||
|
integration_tests_helmv3:
|
||||||
|
machine:
|
||||||
|
image: circleci/classic:201808-01
|
||||||
|
environment:
|
||||||
|
CHANGE_MINIKUBE_NONE_USER: true
|
||||||
|
MINIKUBE_WANTUPDATENOTIFICATION: false
|
||||||
|
MINIKUBE_WANTREPORTERRORPROMPT: false
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: mkdir ~/build
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/build
|
||||||
|
- run: cp ~/build/helmfile ~/project/helmfile
|
||||||
|
- run:
|
||||||
|
name: Install helm
|
||||||
|
environment:
|
||||||
|
HELM_VERSION: v3.0.0-rc.2
|
||||||
|
command: |
|
||||||
|
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
||||||
|
curl -Lo ${HELM_FILENAME} "https://get.helm.sh/${HELM_FILENAME}"
|
||||||
|
tar zxf ${HELM_FILENAME} linux-amd64/helm
|
||||||
|
chmod +x linux-amd64/helm
|
||||||
|
sudo mv linux-amd64/helm /usr/local/bin/
|
||||||
|
- run:
|
||||||
|
name: Deploy minikube
|
||||||
|
environment:
|
||||||
|
CHANGE_MINIKUBE_NONE_USER: true
|
||||||
|
K8S_VERSION: v1.12.3
|
||||||
|
MINIKUBE_VERSION: v0.30.0
|
||||||
|
command: |
|
||||||
|
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl
|
||||||
|
chmod +x kubectl && sudo mv kubectl /usr/local/bin/
|
||||||
|
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
|
||||||
|
chmod +x minikube && sudo mv minikube /usr/local/bin/
|
||||||
|
sudo -E minikube start --vm-driver=none --kubernetes-version=${K8S_VERSION}
|
||||||
|
sudo -E minikube update-context
|
||||||
|
- run:
|
||||||
|
name: Wait for nodes to become ready
|
||||||
|
command: JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
|
||||||
|
- run:
|
||||||
|
name: Execute integration tests
|
||||||
|
command: |
|
||||||
|
export TERM=xterm
|
||||||
|
HELMFILE_HELM3=1 make integration
|
||||||
|
|
||||||
# GITHUB_TOKEN env var must be setup in circleci console
|
# GITHUB_TOKEN env var must be setup in circleci console
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
|
@ -133,11 +178,9 @@ workflows:
|
||||||
- integration_tests:
|
- integration_tests:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
filters:
|
- integration_tests_helmv3:
|
||||||
branches:
|
requires:
|
||||||
only:
|
- build
|
||||||
- master
|
|
||||||
- /pull.*/
|
|
||||||
- release:
|
- release:
|
||||||
filters:
|
filters:
|
||||||
branches:
|
branches:
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,17 @@ func (helm *execer) List(context HelmContext, filter string, flags ...string) (s
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := helm.exec(append(append(preArgs, args...), flags...), env)
|
out, err := helm.exec(append(append(preArgs, args...), flags...), env)
|
||||||
|
// In v2 we have been expecting `helm list FILTER` prints nothing.
|
||||||
|
// In v3 helm still prints the header like `NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION`,
|
||||||
|
// which confuses helmfile's existing logic that treats any non-empty output from `helm list` is considered as the indication
|
||||||
|
// of the release to exist.
|
||||||
|
//
|
||||||
|
// This fixes it by removing the header from the v3 output, so that the output is formatted the same as that of v2.
|
||||||
|
if helm.isHelm3() {
|
||||||
|
lines := strings.Split(string(out), "\n")
|
||||||
|
lines = lines[1:]
|
||||||
|
out = []byte(strings.Join(lines, "\n"))
|
||||||
|
}
|
||||||
helm.write(out)
|
helm.write(out)
|
||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1143,6 +1143,8 @@ func (st *HelmState) DeleteReleases(affectedReleases *AffectedReleases, helm hel
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st.ApplyOverrides(&release)
|
||||||
|
|
||||||
flags := []string{}
|
flags := []string{}
|
||||||
if purge && !isHelm3() {
|
if purge && !isHelm3() {
|
||||||
flags = append(flags, "--purge")
|
flags = append(flags, "--purge")
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,14 @@ function retry() {
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
info "Using namespace: ${test_ns}"
|
info "Using namespace: ${test_ns}"
|
||||||
info "Using Helm version: $(helm version --short --client | grep -o v.*$)"
|
# helm v2
|
||||||
${helm} init --wait --override spec.template.spec.automountServiceAccountToken=true
|
if helm version --client 1>/dev/null 2>/dev/null; then
|
||||||
|
info "Using Helm version: $(helm version --short --client | grep -o v.*$)"
|
||||||
|
${helm} init --wait --override spec.template.spec.automountServiceAccountToken=true
|
||||||
|
# helm v3
|
||||||
|
else
|
||||||
|
info "Using Helm version: $(helm version --short | grep -o v.*$)"
|
||||||
|
fi
|
||||||
${helm} plugin install https://github.com/databus23/helm-diff --version master
|
${helm} plugin install https://github.com/databus23/helm-diff --version master
|
||||||
${kubectl} get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?"
|
${kubectl} get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?"
|
||||||
$kubectl create namespace ${test_ns} || fail "Could not create namespace ${test_ns}"
|
$kubectl create namespace ${test_ns} || fail "Could not create namespace ${test_ns}"
|
||||||
|
|
@ -91,6 +97,7 @@ info "Applying ${dir}/happypath.yaml with locked dependencies"
|
||||||
${helmfile} -f ${dir}/happypath.yaml apply
|
${helmfile} -f ${dir}/happypath.yaml apply
|
||||||
code=$?
|
code=$?
|
||||||
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: ${code}"
|
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: ${code}"
|
||||||
|
${helm} list --namespace=${test_ns} || fail "unable to list releases"
|
||||||
|
|
||||||
info "Deleting release"
|
info "Deleting release"
|
||||||
${helmfile} -f ${dir}/happypath.yaml delete
|
${helmfile} -f ${dir}/happypath.yaml delete
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue