From 49601577cff3ae8bcedafe21869e067eab98ef08 Mon Sep 17 00:00:00 2001 From: HuanMeng0 <11138015+HuanMeng0@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:57:22 +0800 Subject: [PATCH] add config_context field to resource.netbox_device --- docs/resources/device.md | 3 +-- netbox/resource_netbox_device.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/resources/device.md b/docs/resources/device.md index 87df123a2..7482347ed 100644 --- a/docs/resources/device.md +++ b/docs/resources/device.md @@ -84,5 +84,4 @@ resource "netbox_device" "test" { - `id` (String) The ID of this resource. - `primary_ipv4` (Number) - `primary_ipv6` (Number) - - +- `config_context` (String) Rendered Context \ No newline at end of file diff --git a/netbox/resource_netbox_device.go b/netbox/resource_netbox_device.go index 6e854c04a..2416cd288 100644 --- a/netbox/resource_netbox_device.go +++ b/netbox/resource_netbox_device.go @@ -134,6 +134,10 @@ func resourceNetboxDevice() *schema.Resource { Optional: true, Description: "This is best managed through the use of `jsonencode` and a map of settings.", }, + "config_context": { + Type: schema.TypeString, + Computed: true, + }, customFieldsKey: customFieldsSchema, }, Importer: &schema.ResourceImporter{ @@ -400,6 +404,14 @@ func resourceNetboxDeviceRead(ctx context.Context, d *schema.ResourceData, m int d.Set("local_context_data", nil) } + if device.ConfigContext != nil { + if jsonArr, err := json.Marshal(device.ConfigContext); err == nil { + d.Set("config_context", string(jsonArr)) + } + } else { + d.Set("config_context", nil) + } + d.Set(tagsKey, getTagListFromNestedTagList(device.Tags)) return diags }