Skip to content

Commit 4be8d73

Browse files
committed
Add description to spacelift_mounted_file
Signed-off-by: peterdeme <[email protected]>
1 parent ace8fec commit 4be8d73

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

docs/resources/mounted_file.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ resource "spacelift_mounted_file" "core-kubeconfig" {
4646
### Optional
4747

4848
- `context_id` (String) ID of the context on which the mounted file is defined
49+
- `description` (String) Free-form description of the mounted file
4950
- `module_id` (String) ID of the module on which the mounted file is defined
5051
- `stack_id` (String) ID of the stack on which the mounted file is defined
5152
- `write_only` (Boolean) Indicates whether the content can be read back outside a Run. Defaults to `true`.

spacelift/resource_mounted_file.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ func resourceMountedFile() *schema.Resource {
7373
Optional: true,
7474
ForceNew: true,
7575
},
76+
"description": {
77+
Type: schema.TypeString,
78+
Description: "Free-form description of the mounted file",
79+
Optional: true,
80+
ForceNew: true,
81+
},
7682
"write_only": {
7783
Type: schema.TypeBool,
7884
Description: "Indicates whether the content can be read back outside a Run. Defaults to `true`.",
@@ -87,10 +93,11 @@ func resourceMountedFile() *schema.Resource {
8793
func resourceMountedFileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
8894
variables := map[string]interface{}{
8995
"config": structs.ConfigInput{
90-
ID: toID(d.Get("relative_path")),
91-
Type: structs.ConfigType("FILE_MOUNT"),
92-
Value: toString(d.Get("content")),
93-
WriteOnly: graphql.Boolean(d.Get("write_only").(bool)),
96+
ID: toID(d.Get("relative_path")),
97+
Type: structs.ConfigType("FILE_MOUNT"),
98+
Value: toString(d.Get("content")),
99+
WriteOnly: graphql.Boolean(d.Get("write_only").(bool)),
100+
Description: toOptionalString(d.Get("description")),
94101
},
95102
}
96103

@@ -195,6 +202,10 @@ func resourceMountedFileRead(ctx context.Context, d *schema.ResourceData, meta i
195202
d.Set("relative_path", relativePath)
196203
d.Set("write_only", element.WriteOnly)
197204

205+
if element.Description != nil {
206+
d.Set("description", *element.Description)
207+
}
208+
198209
if value := element.Value; value != nil {
199210
d.Set("content", *value)
200211
} else {

spacelift/resource_mounted_file_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func TestMountedFileResource(t *testing.T) {
2626
context_id = spacelift_context.test.id
2727
content = base64encode("bacon is tasty")
2828
relative_path = "bacon.txt"
29+
description = "description text"
2930
write_only = %t
3031
}
3132
`, randomID, writeOnly)
@@ -40,6 +41,7 @@ func TestMountedFileResource(t *testing.T) {
4041
Attribute("checksum", Equals("fb13e7977b7548a324b598e155b5b5ba3dcca2dad5789abe1411a88fa544be9b")),
4142
Attribute("context_id", Contains(randomID)),
4243
Attribute("relative_path", Equals("bacon.txt")),
44+
Attribute("description", Equals("description text")),
4345
Attribute("write_only", Equals("true")),
4446
),
4547
},

0 commit comments

Comments
 (0)