diff --git a/assets/swagger.json b/assets/swagger.json index 43b23e2a74..fcc2a9775d 100644 --- a/assets/swagger.json +++ b/assets/swagger.json @@ -7719,7 +7719,7 @@ }, "version": { "type": "string", - "title": "Version is the Helm version to use for templating (\"3\")" + "title": "Version is the Helm version to use for templating (\"3\" or \"4\")" } } }, diff --git a/hack/installers/install-helm.sh b/hack/installers/install-helm.sh index 51ae3f32d9..548a0195d3 100755 --- a/hack/installers/install-helm.sh +++ b/hack/installers/install-helm.sh @@ -3,10 +3,23 @@ set -eux -o pipefail . "$(dirname "$0")"/../tool-versions.sh -export TARGET_FILE=helm-v${helm3_version}-${INSTALL_OS}-${ARCHITECTURE}.tar.gz +# Determine which Helm version to install (default to v3) +HELM_VERSION=${HELM_VERSION:-3} -[ -e "$DOWNLOADS/${TARGET_FILE}" ] || curl -sLf --retry 3 -o "$DOWNLOADS/${TARGET_FILE}" "https://get.helm.sh/helm-v${helm3_version}-$INSTALL_OS-$ARCHITECTURE.tar.gz" +if [ "$HELM_VERSION" = "3" ]; then + TARGET_FILE=helm-v${helm3_version}-${INSTALL_OS}-${ARCHITECTURE}.tar.gz + DOWNLOAD_URL="https://get.helm.sh/helm-v${helm3_version}-$INSTALL_OS-$ARCHITECTURE.tar.gz" +elif [ "$HELM_VERSION" = "4" ]; then + TARGET_FILE=helm-v${helm4_version}-${INSTALL_OS}-${ARCHITECTURE}.tar.gz + DOWNLOAD_URL="https://get.helm.sh/helm-v${helm4_version}-$INSTALL_OS-$ARCHITECTURE.tar.gz" +else + echo "Error: HELM_VERSION must be 3 or 4, got $HELM_VERSION" + exit 1 +fi + +[ -e "$DOWNLOADS/${TARGET_FILE}" ] || curl -sLf --retry 3 -o "$DOWNLOADS/${TARGET_FILE}" "$DOWNLOAD_URL" "$(dirname "$0")"/compare-chksum.sh mkdir -p /tmp/helm && tar -C /tmp/helm -xf "$DOWNLOADS/${TARGET_FILE}" sudo install -m 0755 "/tmp/helm/$INSTALL_OS-$ARCHITECTURE/helm" "$BIN/helm" helm version + diff --git a/hack/tool-versions.sh b/hack/tool-versions.sh index 632e6fb05a..aab46faf32 100644 --- a/hack/tool-versions.sh +++ b/hack/tool-versions.sh @@ -12,6 +12,7 @@ # add-kustomize-checksums.sh to help download checksums. ############################################################################### helm3_version=3.20.1 +helm4_version=4.1.1 kustomize5_version=5.8.1 protoc_version=29.3 oras_version=1.2.0 diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index 2c3813924d..032b92d5fe 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -542,7 +542,7 @@ message ApplicationSourceHelm { // FileParameters are file parameters to the helm template repeated HelmFileParameter fileParameters = 5; - // Version is the Helm version to use for templating ("3") + // Version is the Helm version to use for templating ("3" or "4") optional string version = 6; // PassCredentials pass credentials to all domains (Helm's --pass-credentials) diff --git a/pkg/apis/application/v1alpha1/openapi_generated.go b/pkg/apis/application/v1alpha1/openapi_generated.go index ecd4773081..8f39c72eb5 100644 --- a/pkg/apis/application/v1alpha1/openapi_generated.go +++ b/pkg/apis/application/v1alpha1/openapi_generated.go @@ -1858,7 +1858,7 @@ func schema_pkg_apis_application_v1alpha1_ApplicationSourceHelm(ref common.Refer }, "version": { SchemaProps: spec.SchemaProps{ - Description: "Version is the Helm version to use for templating (\"3\")", + Description: "Version is the Helm version to use for templating (\"3\" or \"4\")", Type: []string{"string"}, Format: "", }, diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index affc5ab440..fdeb9ab1d4 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -547,7 +547,7 @@ type ApplicationSourceHelm struct { Values string `json:"values,omitempty" patchStrategy:"replace" protobuf:"bytes,4,opt,name=values"` // FileParameters are file parameters to the helm template FileParameters []HelmFileParameter `json:"fileParameters,omitempty" protobuf:"bytes,5,opt,name=fileParameters"` - // Version is the Helm version to use for templating ("3") + // Version is the Helm version to use for templating ("3" or "4") Version string `json:"version,omitempty" protobuf:"bytes,6,opt,name=version"` // PassCredentials pass credentials to all domains (Helm's --pass-credentials) PassCredentials bool `json:"passCredentials,omitempty" protobuf:"bytes,7,opt,name=passCredentials"` diff --git a/util/helm/cmd.go b/util/helm/cmd.go index 2992fe9f46..113eb77453 100644 --- a/util/helm/cmd.go +++ b/util/helm/cmd.go @@ -34,9 +34,11 @@ type Cmd struct { func NewCmd(workDir string, version string, proxy string, noProxy string) (*Cmd, error) { switch version { - // If v3 is specified (or by default, if no value is specified) then use v3 + // If v3 or v4 is specified (or by default, if no value is specified) then use v3 case "", "v3": return NewCmdWithVersion(workDir, false, proxy, noProxy) + case "v4": + return NewCmdWithVersion(workDir, false, proxy, noProxy) } return nil, fmt.Errorf("helm chart version '%s' is not supported", version) }