Skip to content

Commit 25b9415

Browse files
committed
style: add comment explaining whats going on
1 parent 0f79292 commit 25b9415

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

spacelift/resource_stack.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func resourceStack() *schema.Resource {
5151
Version: 0,
5252
Type: resourceStackResourceV0().CoreConfigSchema().ImpliedType(),
5353
Upgrade: func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
54+
// This function will upgrade any existing state files and will remove any data saved to the `import_state` key.
5455
rawState["import_state"] = ""
5556
return rawState, nil
5657
},
@@ -685,6 +686,8 @@ func resourceStackCreate(ctx context.Context, d *schema.ResourceData, meta inter
685686
return diag.Errorf(`"import_state" requires "manage_state" to be true`)
686687
} else if ok {
687688
stateContent = content.(string)
689+
// After we've saved the imported state to memory, set the value to an empty string so it doesn't get saved to this state file.
690+
// We purposefully ignore this value after creation, so we have no reason to save it.
688691
d.Set("import_state", "")
689692
}
690693

0 commit comments

Comments
 (0)