From 7e1d38b59b375feb0fb02b03fa2b0c4dde565dde Mon Sep 17 00:00:00 2001 From: Ben Pearce Date: Mon, 2 Sep 2024 17:01:29 +1000 Subject: [PATCH] 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 --- migration-readme.md | 5 ++++- octopusdeploy_framework/resource_variable.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/migration-readme.md b/migration-readme.md index 0328319cc..539cbec5d 100644 --- a/migration-readme.md +++ b/migration-readme.md @@ -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) diff --git a/octopusdeploy_framework/resource_variable.go b/octopusdeploy_framework/resource_variable.go index e8ecd9448..96a842f14 100644 --- a/octopusdeploy_framework/resource_variable.go +++ b/octopusdeploy_framework/resource_variable.go @@ -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