diff --git a/Makefile b/Makefile index 1f716bab..d8c2ea84 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VERSION=$(shell git describe --tags --abbrev=0) all: docs compile checksum clean test: - /usr/bin/go test -timeout 30s github.com/terraform-routeros/terraform-provider-routeros + go test -timeout 30s github.com/terraform-routeros/terraform-provider-routeros docs: go generate diff --git a/docs/resources/ipv6_dhcp_client.md b/docs/resources/ipv6_dhcp_client.md index ef12f7c4..57d4bcce 100644 --- a/docs/resources/ipv6_dhcp_client.md +++ b/docs/resources/ipv6_dhcp_client.md @@ -24,7 +24,7 @@ resource "routeros_ipv6_dhcp_client" "inet_provider" { ### Optional -- `add-default-route` (Boolean) Whether to add default IPv6 route after a client connects. +- `add_default_route` (Boolean) Whether to add default IPv6 route after a client connects. - `comment` (String) - `disabled` (Boolean) - `prefix_hint ` (Number) Include a preferred prefix length. diff --git a/examples/resources/routeros_ipv6_dhcp_client/resource.tf b/examples/resources/routeros_ipv6_dhcp_client/resource.tf index 59aa0f86..a9bdc73f 100644 --- a/examples/resources/routeros_ipv6_dhcp_client/resource.tf +++ b/examples/resources/routeros_ipv6_dhcp_client/resource.tf @@ -6,3 +6,12 @@ resource "routeros_ipv6_dhcp_client" "inet_provider" { request = ["prefix"] disabled = false } + +resource "routeros_ipv6_dhcp_client" "client" { + pool_name = "pub-add-pool" + interface = "ether1" + add-default-route = true + pool_prefix_length = "64" + request = ["prefix"] + interface = "ether1" +} \ No newline at end of file diff --git a/routeros/resource_ipv6_dhcp_client.go b/routeros/resource_ipv6_dhcp_client.go index 9eb24e5b..b8ca6018 100644 --- a/routeros/resource_ipv6_dhcp_client.go +++ b/routeros/resource_ipv6_dhcp_client.go @@ -30,10 +30,10 @@ import ( // ResourceIPv6DhcpClient https://help.mikrotik.com/docs/display/ROS/DHCP#DHCP-DHCPv6Client func ResourceIPv6DhcpClient() *schema.Resource { resSchema := map[string]*schema.Schema{ - MetaResourcePath: PropResourcePath("/ipv6/dhcp-client/"), + MetaResourcePath: PropResourcePath("/ipv6/dhcp-client"), MetaId: PropId(Id), - "add-default-route": { + "add_default_route": { Type: schema.TypeBool, Optional: true, Description: "Whether to add default IPv6 route after a client connects.", @@ -70,16 +70,18 @@ func ResourceIPv6DhcpClient() *schema.Resource { Computed: true, Description: "Shows received IPv6 prefix from DHCPv6-PD server", }, - "prefix_hint ": { - Type: schema.TypeInt, - Optional: true, - Description: "Include a preferred prefix length.", - ValidateFunc: validation.IntBetween(0, 128), + "prefix_hint": { + Type: schema.TypeString, + Optional: true, + Description: "Include a preferred prefix length.", + ValidateFunc: validation.IsIPv6Address, + DiffSuppressFunc: AlwaysPresentNotUserProvided, }, "request": { Type: schema.TypeList, - Computed: true, + Required: true, Description: "To choose if the DHCPv6 request will ask for the address or the IPv6 prefix, or both.", + Elem: &schema.Schema{Type: schema.TypeString}, }, "status": { Type: schema.TypeString, diff --git a/routeros/resource_ipv6_dhcp_client_test.go b/routeros/resource_ipv6_dhcp_client_test.go index ef6c8879..9c0aed43 100644 --- a/routeros/resource_ipv6_dhcp_client_test.go +++ b/routeros/resource_ipv6_dhcp_client_test.go @@ -17,7 +17,7 @@ func TestAccIPv6DhcpClient_basic(t *testing.T) { testSetTransportEnv(t, name) }, ProviderFactories: testAccProviderFactories, - CheckDestroy: testCheckResourceDestroy("/ipv6/dhcp-client/client", "routeros_ipv6_dhcp_client"), + CheckDestroy: testCheckResourceDestroy("/ipv6/dhcp-client", "routeros_ipv6_dhcp_client"), Steps: []resource.TestStep{ { Config: testAccIPv6DhcpClientConfig(), @@ -25,11 +25,11 @@ func TestAccIPv6DhcpClient_basic(t *testing.T) { testResourcePrimaryInstanceId(testIPv6DhcpClient), resource.TestCheckResourceAttr(testIPv6DhcpClient, "interface", "ether1"), resource.TestCheckResourceAttr(testIPv6DhcpClient, "pool_name", "inet-provider-pool"), + resource.TestCheckResourceAttr(testIPv6DhcpClient, "request.0", "prefix"), ), }, }, }) - }) } } @@ -37,10 +37,11 @@ func TestAccIPv6DhcpClient_basic(t *testing.T) { func testAccIPv6DhcpClientConfig() string { return providerConfig + ` -resource "routeros_ipv6_dhcp_client" "client" { - interface = "ether1" +resource "routeros_ipv6_dhcp_client" "client" { request = ["prefix"] pool_name = "inet-provider-pool" + pool_prefix_length = "64" + interface = "ether1" } `