From 036939480d7c0bbc2822f9653880b311628ffb6d Mon Sep 17 00:00:00 2001 From: jenxie <32846807+jenxie@users.noreply.github.com> Date: Sat, 12 Oct 2024 21:00:17 +0200 Subject: [PATCH 1/2] Fixes 635: added missing Default to data in resourceNetboxCustomFieldUpdate and resourceNetboxCustomFieldCreate --- netbox/resource_netbox_custom_field.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netbox/resource_netbox_custom_field.go b/netbox/resource_netbox_custom_field.go index 0e9ae0ef..a3507e64 100644 --- a/netbox/resource_netbox_custom_field.go +++ b/netbox/resource_netbox_custom_field.go @@ -108,6 +108,7 @@ func resourceNetboxCustomFieldUpdate(d *schema.ResourceData, m interface{}) erro data := &models.WritableCustomField{ Name: strToPtr(d.Get("name").(string)), Type: d.Get("type").(string), + Default: d.Get("default").(string), Description: d.Get("description").(string), GroupName: d.Get("group_name").(string), Label: d.Get("label").(string), @@ -157,6 +158,7 @@ func resourceNetboxCustomFieldCreate(d *schema.ResourceData, m interface{}) erro data := &models.WritableCustomField{ Name: strToPtr(d.Get("name").(string)), Type: d.Get("type").(string), + Default: d.Get("default").(string), Description: d.Get("description").(string), GroupName: d.Get("group_name").(string), Label: d.Get("label").(string), From de2126714354db517fa54236c4f7633e05a40552 Mon Sep 17 00:00:00 2001 From: jenxie <32846807+jenxie@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:05:38 +0200 Subject: [PATCH 2/2] added testing the default field --- netbox/resource_netbox_custom_field_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/netbox/resource_netbox_custom_field_test.go b/netbox/resource_netbox_custom_field_test.go index e71c2d3c..3ea498c5 100644 --- a/netbox/resource_netbox_custom_field_test.go +++ b/netbox/resource_netbox_custom_field_test.go @@ -22,6 +22,7 @@ resource "netbox_custom_field" "test" { type = "text" content_types = ["virtualization.vminterface"] weight = 100 + default = "red" validation_regex = "^.*$" }`, testName), Check: resource.ComposeTestCheckFunc( @@ -29,6 +30,7 @@ resource "netbox_custom_field" "test" { resource.TestCheckResourceAttr("netbox_custom_field.test", "type", "text"), resource.TestCheckTypeSetElemAttr("netbox_custom_field.test", "content_types.*", "virtualization.vminterface"), resource.TestCheckResourceAttr("netbox_custom_field.test", "weight", "100"), + resource.TestCheckResourceAttr("netbox_custom_field.test", "default", "red"), resource.TestCheckResourceAttr("netbox_custom_field.test", "validation_regex", "^.*$"), ), },