Skip to content

Commit

Permalink
Support Helm 3.7.0's reworked OCI support (#1970)
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Menon <[email protected]>
  • Loading branch information
aditmeno authored Oct 4, 2021
1 parent 787e6c8 commit 9a0ce53
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .circleci/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.helm3
Original file line number Diff line number Diff line change
Expand Up @@ -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}... && \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.helm3.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -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}... && \
Expand Down
30 changes: 28 additions & 2 deletions pkg/helmexec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9a0ce53

Please sign in to comment.