Skip to content

Commit

Permalink
bugfix/sc-92561 issue with variable space_id
Browse files Browse the repository at this point in the history
  • Loading branch information
HuyPhanNguyen committed Sep 12, 2024
1 parent bc07af6 commit e654542
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions octopusdeploy_framework/resource_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,20 @@ func (r *variableTypeResource) Read(ctx context.Context, req resource.ReadReques
}

variable, err := variables.GetByID(r.Config.Client, data.SpaceID.ValueString(), variableOwnerID.ValueString(), data.ID.ValueString())

// API don't return SpaceID with the variable, so we need to manually set it here from the state
variable.SpaceID = data.SpaceID.ValueString()
if err != nil {
if err := errors.ProcessApiErrorV2(ctx, resp, data, err, schemas.VariableResourceDescription); err != nil {
resp.Diagnostics.AddError("unable to load variable", err.Error())
}
return
}

tflog.Info(ctx, fmt.Sprintf("variable read (%s)", data.ID))
tflog.Info(ctx, fmt.Sprintf("Read variable: %+v", variable))
mapVariableToState(&data, variable)

tflog.Info(ctx, fmt.Sprintf("SpaceID after mapping: %s", data.SpaceID.ValueString()))

resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
}

Expand Down

0 comments on commit e654542

Please sign in to comment.