terraform-provider-argocd icon indicating copy to clipboard operation
terraform-provider-argocd copied to clipboard

username, password, auth_token shouldn't be mandatory

Open kmai opened this issue 3 years ago • 3 comments

If the option to read the parameters from environment variables is present, the requirement of having username/password or auth_token shouldn't be enforced.

terraform validate will raise a validation issue if I don't set any through the provider definition, but have an environment variable with the value.

Somehow related to https://github.com/oboukili/terraform-provider-argocd/issues/83

kmai avatar Jul 08 '21 10:07 kmai

I have never personally used username/password or auth_token from the provider arguments, always used the environment variables instead, can you give an example of what you are actually encountering?

oboukili avatar Jul 08 '21 15:07 oboukili

For example, if I have a workspace set up and I run terraform validate, I will get the error.

The workaround is to set the environment variable for the auth token on my computer to any value.

We have a pre-commit hook linting and validating the code from the workspace before a commit and on push events in the repo.

When planning/applying it does work okay because the variable for the auth token is populated in terraform cloud.

kmai avatar Jul 08 '21 17:07 kmai

The workaround is to set the environment variable for the auth token on my computer to any value.

I guess we could add a logic inside the provider code and out of the provider schema spec. I'll see what I can do.

oboukili avatar Sep 08 '21 09:09 oboukili

Hi @kmai,

I am doing some cleanup on open issues on this repository. Has this issue been resolved? I have tried to reproduce but am unable to do so. E.g. using the following Terraform code:

terraform {
  required_providers {
    argocd = {
      source  = "oboukili/argocd"
      version = ">= 5.0.0"
    }
  }
}

provider "argocd" {}

resource "argocd_project" "foo" {
  metadata {
    name      = "foo"
    namespace = "argocd"
  }

  spec {
    description  = "foo"
    source_repos = ["*"]

    destination {
      server    = "https://kubernetes.default.svc"
      namespace = "*"
    }
  }
}

If I run terraform validate then I get:

$ terraform validate
Success! The configuration is valid.

If I run terraform plan (with no env vars set) then I get the expected error:

╷
│ Error: Missing required argument
│ 
│   on versions.tf line 14, in provider "argocd":
│   14: provider "argocd" {
│ 
│ The argument "server_addr" is required, but no definition was found.
╵

onematchfox avatar Mar 29 '23 16:03 onematchfox

This issue is stale because of a lack of response from the original author. Please provide the requested feedback or this will be closed in 10 days.

github-actions[bot] avatar May 30 '23 12:05 github-actions[bot]