Skip to content

Commit

Permalink
add context argument to resource.nomad_csi_volume
Browse files Browse the repository at this point in the history
The `context` output is missing from `resource.nomad_csi_volume`. This prevents
successfully migrating from the deprecated `resource.nomad_external_volume`.

Fixes: #494
Ref: https://hashicorp.atlassian.net/browse/NET-11851
  • Loading branch information
tgross committed Jan 17, 2025
1 parent c722c62 commit 7629241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nomad/resource_csi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
}
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/csi_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ can be referenced:
- `nodes_expected`: `(integer)`
- `schedulable`: `(boolean)`
- `topologies`: `(List of topologies)`
- `context`: `(map[string]string)`

### Timeouts

Expand Down

0 comments on commit 7629241

Please sign in to comment.