diff --git a/lxd/resource_lxd_container_test.go b/lxd/resource_lxd_container_test.go index f9c7050d..e2824e78 100644 --- a/lxd/resource_lxd_container_test.go +++ b/lxd/resource_lxd_container_test.go @@ -58,7 +58,7 @@ func TestAccContainer_typeContainer(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccContainer_type(containerName, "container"), + Config: testAccContainer_container(containerName), Check: resource.ComposeTestCheckFunc( testAccContainerRunning(t, "lxd_container.container1", &container), resource.TestCheckResourceAttr("lxd_container.container1", "type", "container"), @@ -77,7 +77,7 @@ func TestAccContainer_typeVirtualMachine(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccContainer_type(containerName, "virtual-machine"), + Config: testAccContainer_virtualmachine(containerName), Check: resource.ComposeTestCheckFunc( testAccContainerRunning(t, "lxd_container.container1", &container), resource.TestCheckResourceAttr("lxd_container.container1", "type", "virtual-machine"), @@ -833,15 +833,30 @@ resource "lxd_container" "container1" { `, name) } -func testAccContainer_type(name string, cType string) string { +func testAccContainer_container(name string) string { return fmt.Sprintf(` resource "lxd_container" "container1" { name = "%s" - type = "%s" + type = "container" image = "images:alpine/3.18/amd64" profiles = ["default"] } - `, name, cType) + `, name) +} + +func testAccContainer_virtualmachine(name string) string { + return fmt.Sprintf(` +resource "lxd_container" "virtualmachine1" { + name = "%s" + type = "virtual-machine" + image = "images:alpine/3.18/amd64" + # alpine images do not support secureboot + config = { + "security.secureboot" = false + } + profiles = ["default"] +} + `, name) } func testAccContainer_config(name string) string { diff --git a/lxd/resource_lxd_instance_test.go b/lxd/resource_lxd_instance_test.go index 6a469f8a..e2d11799 100644 --- a/lxd/resource_lxd_instance_test.go +++ b/lxd/resource_lxd_instance_test.go @@ -49,7 +49,7 @@ func TestAccInstance_basicEphemeral(t *testing.T) { }) } -func TestAccInstance_typeInstance(t *testing.T) { +func TestAccInstance_typeContainer(t *testing.T) { var instance api.Instance instanceName := petname.Generate(2, "-") @@ -58,7 +58,7 @@ func TestAccInstance_typeInstance(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccInstance_type(instanceName, "container"), + Config: testAccInstance_container(instanceName), Check: resource.ComposeTestCheckFunc( testAccInstanceRunning(t, "lxd_instance.instance1", &instance), resource.TestCheckResourceAttr("lxd_instance.instance1", "type", "container"), @@ -77,7 +77,7 @@ func TestAccInstance_typeVirtualMachine(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccInstance_type(instanceName, "virtual-machine"), + Config: testAccInstance_virtualmachine(instanceName), Check: resource.ComposeTestCheckFunc( testAccInstanceRunning(t, "instance.instance1", &instance), resource.TestCheckResourceAttr("lxd_instance.instance1", "type", "virtual-machine"), @@ -834,15 +834,30 @@ resource "lxd_instance" "instance1" { `, name) } -func testAccInstance_type(name string, cType string) string { +func testAccInstance_container(name string) string { return fmt.Sprintf(` resource "lxd_instance" "instance1" { name = "%s" - type = "%s" + type = "container" image = "images:alpine/3.18/amd64" profiles = ["default"] } - `, name, cType) + `, name) +} + +func testAccInstance_virtualmachine(name string) string { + return fmt.Sprintf(` +resource "lxd_instance" "instance1" { + name = "%s" + type = "virtual-machine" + image = "images:alpine/3.18/amd64" + # alpine images do not support secureboot + config = { + "security.secureboot" = false + } + profiles = ["default"] +} + `, name) } func testAccInstance_config(name string) string {