hashicorp / terraform-provider-helm

Terraform Helm provider
https://www.terraform.io/docs/providers/helm/
Mozilla Public License 2.0
997 stars 367 forks source link

[.tgz Chart URL] Error: could not download chart: no cached repo found #1475

Open mateustanaka opened 1 week ago

mateustanaka commented 1 week ago

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: 1.4.5
Provider version: 2.12.1
Kubernetes version: 1.29.5
Helm version (asdf): 3.11.0 and 2.14.2

Affected Resource(s)

Terraform Configuration Files

resource "helm_release" "k8s_config" {
  name                = "k8s-config"
  namespace           = "default"
  chart               = "https://nexus.company.com.br/repository/myrepo/K8sConfig-1.2.0.tgz"
  repository_username = var.username
  repository_password = var.password

  values = [
    file("values/K8sConfig/values.yaml")
  ]
}

Panic Output

helm_release.k8s_config: Creating...
2024-09-02T11:51:25.437-0300 [ERROR] provider.terraform-provider-helm_v2.12.1_x5: Response contains error diagnostic: diagnostic_detail= diagnostic_summary="could not download chart: no cached repo found. (try 'helm repo update'): open /home/user/.cache/helm/repository/other-helm-repo-index.yaml: no such file or directory" tf_proto_version=5.4 tf_provider_addr=provider tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_severity=ERROR tf_req_id=37d9fb27-d72d-421c-bae6-043c6866ae9b tf_resource_type=helm_release timestamp=2024-09-02T11:51:25.437-0300
2024-09-02T11:51:25.437-0300 [ERROR] vertex "helm_release.k8s_config" error: could not download chart: no cached repo found. (try 'helm repo update'): open /home/user/.cache/helm/repository/other-helm-repo-index.yaml: no such file or directory
╷
│ Error: could not download chart: no cached repo found. (try 'helm repo update'): open /home/user/.cache/helm/repository/other-helm-repo-index.yaml: no such file or directory
│ 
│   with helm_release.k8s_config,
│   on main.tf line 23, in resource "helm_release" "k8s_config":
│   23: resource "helm_release" "k8s_config" {

Steps to Reproduce

  1. Use an absolute URL to the .tgz of the Chart from a private Registry
  2. Set env var ASDF_HELM_VERSION=3.11.0 to force use helm 3 in Azure Pipeline terraform task
  3. terraform apply

Expected Behavior

Apply performed and helm release installed successfully from private my registry using an absolute URL to the .tgz of the Chart.

Actual Behavior

Error: could not download chart: no cached repo found

Is there a way to force helm repo update via terraform? Should we peform it even using .tgz url instead of chart repository?

arybolovlev commented 1 week ago

Hi @mateustanaka,

I wasn't able to reproduce this issue. Have you tried to download the chart with curl? Does it work with your username and password in the above Terraform code snippet?

Thanks.

mateustanaka commented 6 days ago

Hi @mateustanaka,

I wasn't able to reproduce this issue. Have you tried to download the chart with curl? Does it work with your username and password in the above Terraform code snippet?

Thanks.

Yes @arybolovlev the URL and credentials are correct. Even using the .tgz URL, it is necessary to perform the helm repo update? Would be nice to have a property in helm_release to set true and terraform do automatically.