From 76292414277f975a1eb03567b67bc1951c01d0b2 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Thu, 16 Jan 2025 16:21:36 -0500 Subject: [PATCH] add context argument to resource.nomad_csi_volume The `context` output is missing from `resource.nomad_csi_volume`. This prevents successfully migrating from the deprecated `resource.nomad_external_volume`. Fixes: https://github.com/hashicorp/terraform-provider-nomad/issues/494 Ref: https://hashicorp.atlassian.net/browse/NET-11851 --- nomad/resource_csi_volume.go | 7 +++++++ website/docs/r/csi_volume.html.markdown | 1 + 2 files changed, 8 insertions(+) diff --git a/nomad/resource_csi_volume.go b/nomad/resource_csi_volume.go index d0f75a1e..ecb20b68 100644 --- a/nomad/resource_csi_volume.go +++ b/nomad/resource_csi_volume.go @@ -340,6 +340,11 @@ func resourceCSIVolume() *schema.Resource { Computed: true, Type: schema.TypeString, }, + "context": { + Description: "The volume context provided by the storage provider", + Computed: true, + Type: schema.TypeMap, + }, }, } } @@ -402,6 +407,7 @@ func resourceCSIVolumeRead(d *schema.ResourceData, meta interface{}) error { d.Set("capability", flattenCSIVolumeCapabilities(volume.RequestedCapabilities)) d.Set("topologies", flattenCSIVolumeTopologies(volume.Topologies)) d.Set("topology_request", flattenCSIVolumeTopologyRequests(volume.RequestedTopologies)) + d.Set("context", volume.Context) // The Nomad API redacts `mount_options` and `secrets`, so we don't update them // with the response payload; they will remain as is. @@ -451,6 +457,7 @@ func resourceCSIVolumeCreate(ctx context.Context, d *schema.ResourceData, meta i RequestedTopologies: topologyRequest, Secrets: helper.ToMapStringString(d.Get("secrets")), Parameters: helper.ToMapStringString(d.Get("parameters")), + Context: helper.ToMapStringString(d.Get("context")), } // Unpack the mount_options if we have any and configure the volume struct. diff --git a/website/docs/r/csi_volume.html.markdown b/website/docs/r/csi_volume.html.markdown index 11fa58db..2a779bf3 100644 --- a/website/docs/r/csi_volume.html.markdown +++ b/website/docs/r/csi_volume.html.markdown @@ -128,6 +128,7 @@ can be referenced: - `nodes_expected`: `(integer)` - `schedulable`: `(boolean)` - `topologies`: `(List of topologies)` +- `context`: `(map[string]string)` ### Timeouts