lxc / terraform-provider-incus

Incus provider for Terraform/OpenTofu
https://linuxcontainers.org/incus
Mozilla Public License 2.0
50 stars 11 forks source link

When config.yml doesn't exist, a directory called "$HOME" is created in the terraform directory #19

Closed johnmaguire closed 8 months ago

johnmaguire commented 8 months ago

I have not created a ~/.config/incus/config.yml and my config looks like this:

provider "incus" {
  generate_client_certificates = true
  accept_remote_certificate    = true

  remote {
    name    = "demeter"
    scheme  = "https"
    address = "192.168.123.15"
    token = "<redacted>"
    default = true
  }

  //config_dir = "/Users/jmaguire/.config/incus"
}

Running terraform apply creates a new keypair saved to $HOME/.config/incus directory structure in the local directory. Additionally, if I move the config directory to my home directory, it's ignored. This is because config.yml does not exist:

https://github.com/lxc/terraform-provider-incus/blob/68e8e4670989554e85a9b83d98215a2f4c9057dc/internal/provider/provider.go#L141-L154

Note that os.ExpandEnv is only applied to the complete config.yml file name, not the configDir var assigned to the new config struct.

❯ terraform version
Terraform v1.6.6
on darwin_arm64
+ provider registry.terraform.io/lxc/incus v0.0.2