lxc / terraform-provider-incus

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

Implement incus_images data source #96

Closed trunet closed 2 weeks ago

trunet commented 3 months ago

I have a custom pipeline that delivers enriched images (things like custom apt sources, custom ldap, sssd, security tooling, ...) to incus clusters versioned.

This datasource will allow these images to be versioned and selected by latest and/or specific version when specifying on incus_instance dynamically.

maveonair commented 3 weeks ago

@trunet When we introduce an image data source, it only works with images that are available on a specific instance server, like the ones you get with incus image list. For the normal images that you download from the image servers, you should use the resource definition.

Do we have the same understanding?

trunet commented 3 weeks ago

Do we have the same understanding?

@maveonair you mean the ones present in the cluster, right? I have “local” images available in all cluster members and that’s what I need.

maveonair commented 3 weeks ago

Do we have the same understanding?

@maveonair you mean the ones present in the cluster, right? I have “local” images available in all cluster members and that’s what I need.

Yes, exactly this is what I mean. So the definition would look like:

data "incus_image" "my_image" {
  name = "my_image" # is the alias of the image, fingerprint would also be possible to set instead
}

output "fingerprint" {
  value = data.incus_image.my_image.fingerprint
}

resource "incus_instance" "instance1" {
  image = data.incus_image.my_image.fingerprint
  name  = "instance1"
}
trunet commented 3 weeks ago

yes, that’s it. thanks.

trunet commented 3 weeks ago

ahh, one thing, would be nice to have an incus_images where you can query multiple images with wildcards or regex. in my case, I have versions and would like to query the latest.

maveonair commented 3 weeks ago

ahh, one thing, would be nice to have an incus_images where you can query multiple images with wildcards or regex. in my case, I have versions and would like to query the latest.

Do you mind if we start with a simple datasource first :)?

trunet commented 3 weeks ago

yeah, of course. appreciate the hard work.