lxc / terraform-provider-incus

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

Support NULL values in configs #82

Closed stgraber closed 3 weeks ago

stgraber commented 3 weeks ago

Terraform allows for configuration to be set to NULL. This is generally assumed to be equivalent to not having put the configuration line in question and is particularly useful when dealing with conditional behaviors.

A couple of examples:

resource "incus_network" "this" {
  name = "foo"

  config = {
    "ipv4.address" = var.deploy == "production" ? "none" : null
  }
}

resource "incus_profile" "this" {
  name = "foo"

  config = {
    "environment.http_proxy" = var.deploy == "production" ? "http://my-proxy:3128" : null
    "environment.https_proxy" = var.deploy == "production" ? "http://my-proxy:3128" : null
  }
}

To handle this properly, a few changes are needed:

stgraber commented 3 weeks ago

That'd probably make sense. I never played with the test infrastructure yet, I'll have to look at how that works.

stgraber commented 3 weeks ago

finally got it passing :)