Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct space id support for creating variables #772

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading