From 269df4dbfc969643f2bf56b9b267320474da735f Mon Sep 17 00:00:00 2001 From: peterdeme Date: Thu, 6 Feb 2025 15:18:49 +0100 Subject: [PATCH] Add description to `spacelift_mounted_file` Signed-off-by: peterdeme --- docs/resources/mounted_file.md | 1 + spacelift/resource_mounted_file.go | 14 ++++++++++++++ spacelift/resource_mounted_file_test.go | 2 ++ 3 files changed, 17 insertions(+) diff --git a/docs/resources/mounted_file.md b/docs/resources/mounted_file.md index 43ee9ba4..6aa0a5e9 100644 --- a/docs/resources/mounted_file.md +++ b/docs/resources/mounted_file.md @@ -46,6 +46,7 @@ resource "spacelift_mounted_file" "core-kubeconfig" { ### Optional - `context_id` (String) ID of the context on which the mounted file is defined +- `description` (String) Free-form description of the mounted file - `module_id` (String) ID of the module on which the mounted file is defined - `stack_id` (String) ID of the stack on which the mounted file is defined - `write_only` (Boolean) Indicates whether the content can be read back outside a Run. Defaults to `true`. diff --git a/spacelift/resource_mounted_file.go b/spacelift/resource_mounted_file.go index ffd89bd7..7ec8595b 100644 --- a/spacelift/resource_mounted_file.go +++ b/spacelift/resource_mounted_file.go @@ -73,6 +73,12 @@ func resourceMountedFile() *schema.Resource { Optional: true, ForceNew: true, }, + "description": { + Type: schema.TypeString, + Description: "Free-form description of the mounted file", + Optional: true, + ForceNew: true, + }, "write_only": { Type: schema.TypeBool, Description: "Indicates whether the content can be read back outside a Run. Defaults to `true`.", @@ -94,6 +100,10 @@ func resourceMountedFileCreate(ctx context.Context, d *schema.ResourceData, meta }, } + if desc, ok := d.GetOk("description"); ok { + variables["description"] = desc + } + if contextID, ok := d.GetOk("context_id"); ok { variables["context"] = toID(contextID) return resourceMountedFileCreateContext(ctx, d, meta.(*internal.Client), variables) @@ -195,6 +205,10 @@ func resourceMountedFileRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("relative_path", relativePath) d.Set("write_only", element.WriteOnly) + if element.Description != nil { + d.Set("description", *element.Description) + } + if value := element.Value; value != nil { d.Set("content", *value) } else { diff --git a/spacelift/resource_mounted_file_test.go b/spacelift/resource_mounted_file_test.go index 3bdf0e32..cb326d15 100644 --- a/spacelift/resource_mounted_file_test.go +++ b/spacelift/resource_mounted_file_test.go @@ -26,6 +26,7 @@ func TestMountedFileResource(t *testing.T) { context_id = spacelift_context.test.id content = base64encode("bacon is tasty") relative_path = "bacon.txt" + description = "description text" write_only = %t } `, randomID, writeOnly) @@ -40,6 +41,7 @@ func TestMountedFileResource(t *testing.T) { Attribute("checksum", Equals("fb13e7977b7548a324b598e155b5b5ba3dcca2dad5789abe1411a88fa544be9b")), Attribute("context_id", Contains(randomID)), Attribute("relative_path", Equals("bacon.txt")), + Attribute("description", Equals("description text")), Attribute("write_only", Equals("true")), ), },