Skip to content

Commit

Permalink
style: add comment explaining whats going on
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollorion committed Dec 9, 2024
1 parent 0f79292 commit 25b9415
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spacelift/resource_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func resourceStack() *schema.Resource {
Version: 0,
Type: resourceStackResourceV0().CoreConfigSchema().ImpliedType(),
Upgrade: func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) {
// This function will upgrade any existing state files and will remove any data saved to the `import_state` key.
rawState["import_state"] = ""
return rawState, nil
},
Expand Down Expand Up @@ -685,6 +686,8 @@ func resourceStackCreate(ctx context.Context, d *schema.ResourceData, meta inter
return diag.Errorf(`"import_state" requires "manage_state" to be true`)
} else if ok {
stateContent = content.(string)
// 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.
// We purposefully ignore this value after creation, so we have no reason to save it.
d.Set("import_state", "")
}

Expand Down

0 comments on commit 25b9415

Please sign in to comment.