Skip to content

Commit

Permalink
fix dns validation (#11)
Browse files Browse the repository at this point in the history
update docs on vSphere and macs
  • Loading branch information
FrankT1983 authored Jun 27, 2023
1 parent a80f724 commit a70f111
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
6 changes: 3 additions & 3 deletions examples/advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ resource "virtomize_iso" "debian_iso" {
networks = [{
dhcp = true
no_internet = false,
mac = "00-1B-63-84-45-E5"
mac = "ca:8c:65:0d:e7:57"
},{
dhcp = false
domain = "custom_domain"
mac = "00-1B-63-84-45-E6"
mac = "ca:8c:65:0d:e7:58"
ip_net = "10.0.0.0/24"
gateway = "10.0.0.1"
dns = ["1.1.1.1", "8.8.8.8"]
Expand Down Expand Up @@ -82,7 +82,7 @@ Please consult your network admin for the correct values for these parameters.
{
dhcp = false
domain = "custom_domain"
mac = "00-1B-63-84-45-E6"
mac = "ca:8c:65:0d:e7:58"
ip_net = "10.0.0.0/24"
gateway = "10.0.0.1"
dns = ["1.1.1.1", "8.8.8.8"]
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/virtomize.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ resource "virtomize_iso" "debian_iso" {
networks = [{
dhcp = true
no_internet = false
mac = "00-1B-63-84-45-E5"
mac = "ca:8c:65:0d:e7:57"
},{
dhcp = false
domain = "custom_domain"
mac = "00-1B-63-84-45-E6"
mac = "ca:8c:65:0d:e7:58"
ip_net = "10.0.0.0/24"
gateway = "10.0.0.1"
dns = ["1.1.1.1", "8.8.8.8"]
Expand Down
7 changes: 6 additions & 1 deletion examples/vmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ To use multiple network adapters, follow
[the official documentation](https://registry.terraform.io/providers/hashicorp/vsphere/1.17.0/docs/resources/virtual_machine)
and add the `use_static_mac` and `mac_address` properties to the individual network interfaces.

Notice that at least in our test the vSphere provider prefer MAC addresses to be in the format
`xx:xx:xx:xx:xx:xx`
instead of
`xx-xx-xx-xx-xx-xx`.

```terraform
network_interface {
network_id = "${data.vsphere_network.mgmt_lan.id}"
use_static_mac = true
mac_address = "CA-8C-65-0D-E7-58"
mac_address = "ca:8c:65:0d:e7:57"
}
```
37 changes: 37 additions & 0 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,43 @@ resource "virtomize_iso" "debian_iso" {
})
}

func TestSimpleIsoLifeCycleStaticConfig(t *testing.T) {
testConfiguration := `
provider "virtomize" {
# apitoken = retrieved from env variables
# localstorage = use local folder
}
resource "virtomize_iso" "debian_iso" {
name = "debian_iso"
distribution = "debian"
version = "11"
hostname = "examplehost"
networks = [{
dhcp = false
domain = "custom_domain"
mac = "ca:8c:65:0d:e7:58"
ip_net = "10.0.0.0/24"
gateway = "10.0.0.1"
dns = ["1.1.1.1", "8.8.8.8"]
no_internet = false
}]
}`

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testConfiguration,
Check: resource.ComposeTestCheckFunc(
checkSimpleIsoProperties,
),
},
},
})
}

func checkSimpleIsoProperties(state *terraform.State) error {
resource_name := "virtomize_iso.debian_iso"
rs, ok := state.RootModule().Resources[resource_name]
Expand Down
2 changes: 1 addition & 1 deletion provider/resource_iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func stringListWithValidElements(list []types.String) []string {
continue
}

result = append(result, item.String())
result = append(result, item.ValueString())
}

return result
Expand Down

0 comments on commit a70f111

Please sign in to comment.