diff --git a/.circleci/Makefile b/.circleci/Makefile index 35b39ca5..7a16586d 100644 --- a/.circleci/Makefile +++ b/.circleci/Makefile @@ -1,4 +1,4 @@ -HELM_VERSION ?= v3.5.3 +HELM_VERSION ?= v3.7.0 KUSTOMIZE_VERSION ?= v3.8.8 K8S_VERSION ?= v1.13.12 MINIKUBE_VERSION ?= v0.30.0 diff --git a/.circleci/config.yml b/.circleci/config.yml index 0760b4f6..2607a237 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -145,7 +145,7 @@ workflows: - build matrix: parameters: - helm-version: ["v3.4.2", "v3.5.4", "v3.6.3"] + helm-version: ["v3.4.2", "v3.5.4", "v3.6.3", "v3.7.0"] - release: filters: branches: diff --git a/Dockerfile b/Dockerfile index 8b4959a3..6103fdb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,8 @@ FROM alpine:3.11 RUN apk add --no-cache ca-certificates git bash curl jq -ARG HELM_VERSION="v3.6.3" -ARG HELM_SHA256="07c100849925623dc1913209cd1a30f0a9b80a5b4d6ff2153c609d11b043e262" +ARG HELM_VERSION="v3.7.0" +ARG HELM_SHA256="096e30f54c3ccdabe30a8093f8e128dba76bb67af697b85db6ed0453a2701bf9" ARG HELM_LOCATION="https://get.helm.sh" ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz" diff --git a/Dockerfile.debian b/Dockerfile.debian index 602d0ccc..1c58cdf6 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -25,8 +25,8 @@ RUN apt-get update \ wget \ && rm -rf /var/lib/apt/lists/* -ARG HELM_VERSION="v3.6.3" -ARG HELM_SHA256="07c100849925623dc1913209cd1a30f0a9b80a5b4d6ff2153c609d11b043e262" +ARG HELM_VERSION="v3.7.0" +ARG HELM_SHA256="096e30f54c3ccdabe30a8093f8e128dba76bb67af697b85db6ed0453a2701bf9" ARG HELM_LOCATION="https://get.helm.sh" ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz" diff --git a/Dockerfile.helm3 b/Dockerfile.helm3 index 393100df..07448bd6 100644 --- a/Dockerfile.helm3 +++ b/Dockerfile.helm3 @@ -11,10 +11,10 @@ FROM alpine:3.11 RUN apk add --no-cache ca-certificates git bash curl jq -ARG HELM_VERSION="v3.5.3" +ARG HELM_VERSION="v3.7.0" ARG HELM_LOCATION="https://get.helm.sh" ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz" -ARG HELM_SHA256="2170a1a644a9e0b863f00c17b761ce33d4323da64fc74562a3a6df2abbf6cd70" +ARG HELM_SHA256="096e30f54c3ccdabe30a8093f8e128dba76bb67af697b85db6ed0453a2701bf9" RUN set -x && \ wget ${HELM_LOCATION}/${HELM_FILENAME} && \ echo Verifying ${HELM_FILENAME}... && \ diff --git a/Dockerfile.helm3.ubuntu b/Dockerfile.helm3.ubuntu index 04c96384..30491588 100644 --- a/Dockerfile.helm3.ubuntu +++ b/Dockerfile.helm3.ubuntu @@ -17,10 +17,10 @@ RUN apt update -qq && \ git bash curl jq pip wget && \ rm -rf /var/lib/apt/lists/* -ARG HELM_VERSION="v3.5.3" +ARG HELM_VERSION="v3.7.0" ARG HELM_LOCATION="https://get.helm.sh" ARG HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz" -ARG HELM_SHA256="2170a1a644a9e0b863f00c17b761ce33d4323da64fc74562a3a6df2abbf6cd70" +ARG HELM_SHA256="096e30f54c3ccdabe30a8093f8e128dba76bb67af697b85db6ed0453a2701bf9" RUN set -x && \ wget ${HELM_LOCATION}/${HELM_FILENAME} && \ echo Verifying ${HELM_FILENAME}... && \ diff --git a/pkg/helmexec/exec.go b/pkg/helmexec/exec.go index 669e03ba..aecf7949 100644 --- a/pkg/helmexec/exec.go +++ b/pkg/helmexec/exec.go @@ -432,14 +432,40 @@ func (helm *execer) Fetch(chart string, flags ...string) error { func (helm *execer) ChartPull(chart string, flags ...string) error { helm.logger.Infof("Pulling %v", chart) - out, err := helm.exec(append([]string{"chart", "pull", chart}, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) + helm.logger.Infof("Exporting %v", chart) + helmVersionConstraint, _ := semver.NewConstraint(">= 3.7.0") + var helmArgs []string + if helmVersionConstraint.Check(&helm.version) { + ociChartURLSplit := strings.Split(chart, ":") + ociChartURL := fmt.Sprintf("oci://%s", ociChartURLSplit[0]) + ociChartTag := ociChartURLSplit[1] + tempDir, err := ioutil.TempDir("", "chart*") + if err != nil { + return err + } + defer os.RemoveAll(tempDir) + helmArgs = []string{"fetch", ociChartURL, "--version", ociChartTag, "--destination", tempDir} + } else { + helmArgs = []string{"chart", "pull", chart} + } + out, err := helm.exec(append(helmArgs, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) helm.info(out) return err } func (helm *execer) ChartExport(chart string, path string, flags ...string) error { helm.logger.Infof("Exporting %v", chart) - out, err := helm.exec(append([]string{"chart", "export", chart, "--destination", path}, flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) + helmVersionConstraint, _ := semver.NewConstraint(">= 3.7.0") + var helmArgs []string + if helmVersionConstraint.Check(&helm.version) { + ociChartURLSplit := strings.Split(chart, ":") + ociChartURL := fmt.Sprintf("oci://%s", ociChartURLSplit[0]) + ociChartTag := ociChartURLSplit[1] + helmArgs = []string{"pull", ociChartURL, "--version", ociChartTag, "--untar"} + } else { + helmArgs = []string{"chart", "export", chart} + } + out, err := helm.exec(append(append(helmArgs, "--destination", path), flags...), map[string]string{"HELM_EXPERIMENTAL_OCI": "1"}) helm.info(out) return err } diff --git a/pkg/state/state.go b/pkg/state/state.go index eb5291ab..7acfcabe 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -3224,6 +3224,9 @@ func (st *HelmState) getOCIChart(pullChan chan PullCommand, release *ReleaseSpec chartPath := path.Join(pathElems...) err = helm.ChartExport(qualifiedChartName, chartPath) + if err != nil { + return nil, err + } fullChartPath, err := findChartDirectory(chartPath) if err != nil {