Skip to content

Commit

Permalink
fix: alpine vm images do not support secureboot
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcstephens committed Nov 6, 2023
1 parent 91053f8 commit 5e86c96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
25 changes: 20 additions & 5 deletions lxd/resource_lxd_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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 {
Expand Down
27 changes: 21 additions & 6 deletions lxd/resource_lxd_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "-")

Expand All @@ -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"),
Expand All @@ -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"),
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5e86c96

Please sign in to comment.