mvisonneau / helm-charts

Personal Helm charts repository
Apache License 2.0
67 stars 58 forks source link

chart doesn't allow setting of gitlab token via env var. #79

Open gurpalw opened 9 months ago

gurpalw commented 9 months ago

The exporter allows you to set the gitlab token via an environmental variable. However the helm chart does not.

From the pipeline exporter documentation (https://github.com/mvisonneau/gitlab-ci-pipelines-exporter#helm)

# Configure a minimal configuration for the exporter
~$ cat <<EOF > values.yml
config:
  gitlab:
    url: https://gitlab.example.com
    # You can also configure the token using --gitlab-token
    # or the $GCPE_GITLAB_TOKEN environment variable

However when you do this in the chart, via terraform, you get the following error:

╷
│ Error: execution error at (gitlab-ci-pipelines-exporter/templates/secret.yaml:11:24): gitlab token must be set
│ 
│   with helm_release.helm,
│   on helm.tf line 1, in resource "helm_release" "helm":
│    1: resource "helm_release" "helm" {
│ 

Here is the terraform code:

resource "helm_release" "helm" {
  name             = "gitlab-ci-pipelines-exporter"
  repository       = "https://charts.visonneau.fr/"
  chart            = "gitlab-ci-pipelines-exporter"
  namespace        = "gitlab"
  create_namespace = true
  max_history      = 3

  values = [
    file("${path.root}/values.yaml")
  ]

  set {
    name  = "envVariables[0].name"
    value = "GCPE_INTERNAL_MONITORING_LISTENER_ADDRESS"
  }

  set {
    name  = "envVariables[0].value"
    value = "tcp://127.0.0.1:8082"
  }

  set_sensitive {
    name  = "envVariables[1].name"
    value = "GCPE_GITLAB_TOKEN"
  }

  set_sensitive {
    name  = "envVariables[1].value"
    value = data.aws_secretsmanager_secret_version.gitlab_token.secret_string

  }

  timeout = 180
}

The charts secret.yaml should be updated so that .Values.config.gitlab.token is not a required value if GCPE_GITLAB_TOKEN has been set as an environment variable via values.envVariables.