@@ -28,19 +28,28 @@ function pull_helm_chart() {
2828 local _password=" "
2929 _password=" $( echo " ${_chart_repo_helm_section} " | common::yq4-get ' .password' ) "
3030 common::debug " downloading chart ${_name} form ${_url} with version ${_version} "
31-
32- _cmd=" ${HELM_COMMAND_LINE} pull --repo ${_url} ${_name} --version ${_version} "
31+ _cmd=" "
3332 if [[ " ${_url} " =~ ^oci:// ]]; then
34- # helm pull oci://troposphere/tsc-top-level-chart --version 0.1.0
35- # special case for oci repo: see: https://github.com/helm/helm/blob/0199b748aaea3091852d16687c9f9f809061777c/pkg/cmd/install.go#L116
36- _cmd=" ${HELM_COMMAND_LINE} pull ${_url} --version ${_version} "
37- fi
38- if [[ -n " ${_username} " ]]; then
39- _cmd=" ${_cmd} --username ${_username} "
40- fi
41-
42- if [[ -n " ${_password} " ]]; then
43- _cmd=" ${_cmd} --password ${_password} "
33+ export HELM_EXPERIMENTAL_OCI=1
34+ if [[ -n " ${_username} " && -n " ${_password} " ]]; then
35+ # helm v4 is going to break this: https://github.com/helm/helm/issues/31499
36+ common::info " OCI registry username and password are provided, performing helm registry login"
37+ echo " ${_password} " | ${HELM_COMMAND_LINE} registry login ${_url} --username ${_username} --password-stdin
38+ _res=$?
39+ if [ ${_res} -ne 0 ]; then
40+ common::err " OCI registry login error"
41+ return ${_res}
42+ fi
43+ fi
44+ _cmd=" ${HELM_COMMAND_LINE} pull ${_url} /${_name} --version ${_version} "
45+ else
46+ _cmd=" ${HELM_COMMAND_LINE} pull --repo ${_url} ${_name} --version ${_version} "
47+ if [[ -n " ${_username} " ]]; then
48+ _cmd=" ${_cmd} --username ${_username} "
49+ fi
50+ if [[ -n " ${_password} " ]]; then
51+ _cmd=" ${_cmd} --password ${_password} "
52+ fi
4453 fi
4554
4655 if ! eval " ${_cmd} " ; then
0 commit comments