Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change image resource to have source_image and source_instance #128

Merged
merged 4 commits into from
Aug 31, 2024

Conversation

maveonair
Copy link
Member

@maveonair maveonair commented Aug 23, 2024

Attention: This pull request (intentionally) breaks our existing Terraform Provider API!

This pull request changes the resource incus_image to have to new blocks: source_image and source_instance to replace the image_publish_resource as described in #89.

Example: source_image:

resource "incus_image" "alpine" {
  source_image = {
    remote = "images"
    name   = "alpine/edge"
  }
}

resource "incus_instance" "test1" {
  name      = "test1"
  image     = incus_image.alpine.fingerprint
  ephemeral = false
}

Example: source_instance:

resource "incus_image" "alpine" {
  project = "default"

  aliases = ["alpine"]

  source_image = {
    remote       = "images"
    name         = "alpine/edge"
    type         = "container"
    architecture = "aarch64"
  }
}

resource "incus_instance" "alpine" {
  project = "default"
  name    = "alpine"
  image   = incus_image.alpine.fingerprint
  running = false
}

resource "incus_image" "alpine2" {
  project = "default"

  aliases = ["alpine2"]

  source_instance = {
    name = incus_instance.alpine.name
  }
}

resource "incus_instance" "alpine2" {
  project = "default"
  name    = "alpine2"
  image   = incus_image.alpine2.fingerprint
}

resource "incus_instance_snapshot" "snapshot1" {
  project  = "default"
  name     = "snap0"
  instance = incus_instance.alpine2.name
  stateful = false
}

resource "incus_image" "alpine2_snapshot" {
  project = "default"

  aliases = ["alpine2-snap0"]

  source_instance = {
    name     = incus_instance.alpine2.name
    snapshot = incus_instance_snapshot.snapshot1.name
  }
}

resource "incus_instance" "alpine3" {
  project = "default"
  name    = "alpine3"
  image   = incus_image.alpine2_snapshot.fingerprint
}

What's been done

  • image: Added source_image block
  • image: Added source_instance block
  • tests: Created and updated tests
  • docs: Updated documentation
  • Removed image_publish resource

@maveonair maveonair force-pushed the image_source_instance branch 9 times, most recently from 895e2d9 to 5475f95 Compare August 27, 2024 18:59
@maveonair maveonair marked this pull request as ready for review August 27, 2024 19:05
@stgraber stgraber merged commit 8f92d50 into lxc:main Aug 31, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Replace incus_image_publish with an extended source field on incus_image
2 participants