Skip to content

Commit 7e1d38b

Browse files
authored
fix: correct space id support for creating variables (#772)
* fix: correct space id support for creating variables * chore: added note about space id on create
1 parent 4d9acca commit 7e1d38b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

migration-readme.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ func (b *blahResource) Create(ctx context.Context, request resource.CreateReques
161161
newResource := ...
162162

163163
// call client for create
164-
blah := blahResources.Add(b.Client, util.GetSpace(), newResource)
164+
// the space id here should come from the plan.
165+
// 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
166+
// space_id configured on the provider, otherwise the API will assume the default space.
167+
blah := blahResources.Add(b.Client, plan.SpaceID.ValueString(), newResource)
165168

166169
// map result to state
167170
plan.Name := types.StringValue(blah.Name)

octopusdeploy_framework/resource_variable.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (r *variableTypeResource) Create(ctx context.Context, req resource.CreateRe
9090

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

93-
variableSet, err := variables.AddSingle(r.Config.Client, r.Config.SpaceID, variableOwnerId.ValueString(), newVariable)
93+
variableSet, err := variables.AddSingle(r.Config.Client, data.SpaceID.ValueString(), variableOwnerId.ValueString(), newVariable)
9494
if err != nil {
9595
resp.Diagnostics.AddError("create variable failed", err.Error())
9696
return

0 commit comments

Comments
 (0)