Skip to content

Commit

Permalink
fix: correct space id support for creating variables (#772)
Browse files Browse the repository at this point in the history
* fix: correct space id support for creating variables

* chore: added note about space id on create
  • Loading branch information
benPearce1 authored Sep 2, 2024
1 parent 4d9acca commit 7e1d38b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion migration-readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ func (b *blahResource) Create(ctx context.Context, request resource.CreateReques
newResource := ...

// call client for create
blah := blahResources.Add(b.Client, util.GetSpace(), newResource)
// the space id here should come from the plan.
// If the user doesn't provide a space_id on the plan, this will return an empty string, which the client will replace with the
// space_id configured on the provider, otherwise the API will assume the default space.
blah := blahResources.Add(b.Client, plan.SpaceID.ValueString(), newResource)

// map result to state
plan.Name := types.StringValue(blah.Name)
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy_framework/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *variableTypeResource) Create(ctx context.Context, req resource.CreateRe

tflog.Info(ctx, fmt.Sprintf("creating variable: %#v", newVariable))

variableSet, err := variables.AddSingle(r.Config.Client, r.Config.SpaceID, variableOwnerId.ValueString(), newVariable)
variableSet, err := variables.AddSingle(r.Config.Client, data.SpaceID.ValueString(), variableOwnerId.ValueString(), newVariable)
if err != nil {
resp.Diagnostics.AddError("create variable failed", err.Error())
return
Expand Down

0 comments on commit 7e1d38b

Please sign in to comment.