Logging and error handling improvements, bug fixes (#21)
- Uniformed logs and diagnostics: - Logging and adding to diagnostics is done by the highest level function (Create/Read/Update/Delete/Import) using `LogAndAddError` - Lower-level routines' signature changed to return error instead of writing to diagnostics - Standardize summary and details across services - Removed manual adding of relevant variables to details (they're in the context, TF adds them to logs) - Changed validators to be closer to official implementation - Fix logging wrong output after wait - Fix Argus checking wrong diagnostics - Fix Resource Manager not updating state after project update - Fix unnecessary pointer in LogAndAddError
This commit is contained in:
parent
29b8c91999
commit
4e8514df00
51 changed files with 1389 additions and 1092 deletions
|
|
@ -6,12 +6,12 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/core"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/validate"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/postgresql"
|
||||
)
|
||||
|
|
@ -45,7 +45,7 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
|
|||
|
||||
providerData, ok := req.ProviderData.(core.ProviderData)
|
||||
if !ok {
|
||||
resp.Diagnostics.AddError("Unexpected Data Source Configure Type", fmt.Sprintf("Expected stackit.ProviderData, got %T. Please report this issue to the provider developers.", req.ProviderData))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error configuring API client", fmt.Sprintf("Expected configure type stackit.ProviderData, got %T", req.ProviderData))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -64,12 +64,12 @@ func (r *instanceDataSource) Configure(ctx context.Context, req datasource.Confi
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Could not Configure API Client", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error configuring API client", fmt.Sprintf("Configuring client: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Postgresql zone client configured")
|
||||
r.client = apiClient
|
||||
tflog.Info(ctx, "PostgreSQL zone client configured")
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
|
|
@ -169,37 +169,41 @@ func (r *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
|
|||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *instanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var state Model
|
||||
diags := req.Config.Get(ctx, &state)
|
||||
var model Model
|
||||
diags := req.Config.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
projectId := state.ProjectId.ValueString()
|
||||
instanceId := state.InstanceId.ValueString()
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
|
||||
instanceResp, err := r.client.GetInstance(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Unable to read instance", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
err = mapFields(instanceResp, &state)
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Mapping fields", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Compute and store values not present in the API response
|
||||
loadPlanNameAndVersion(ctx, r.client, &resp.Diagnostics, &state)
|
||||
if resp.Diagnostics.HasError() {
|
||||
err = loadPlanNameAndVersion(ctx, r.client, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Loading service plan details: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Set refreshed state
|
||||
diags = resp.State.Set(ctx, &state)
|
||||
diags = resp.State.Set(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
tflog.Info(ctx, "Postgresql instance read")
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "PostgreSQL instance read")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@ import (
|
|||
|
||||
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/diag"
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/conversion"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/core"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/validate"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/path"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
|
||||
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/stackitcloud/stackit-sdk-go/core/config"
|
||||
"github.com/stackitcloud/stackit-sdk-go/services/postgresql"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/conversion"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/core"
|
||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/validate"
|
||||
)
|
||||
|
||||
// Ensure the implementation satisfies the expected interfaces.
|
||||
|
|
@ -92,7 +92,7 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
|
|||
|
||||
providerData, ok := req.ProviderData.(core.ProviderData)
|
||||
if !ok {
|
||||
resp.Diagnostics.AddError("Unexpected Resource Configure Type", fmt.Sprintf("Expected stackit.ProviderData, got %T. Please report this issue to the provider developers.", req.ProviderData))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error configuring API client", fmt.Sprintf("Expected configure type stackit.ProviderData, got %T", req.ProviderData))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -111,12 +111,12 @@ func (r *instanceResource) Configure(ctx context.Context, req resource.Configure
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
resp.Diagnostics.AddError("Could not Configure API Client", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error configuring API client", fmt.Sprintf("Configuring client: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
tflog.Info(ctx, "Postgresql zone client configured")
|
||||
r.client = apiClient
|
||||
tflog.Info(ctx, "PostgreSQL instance client configured")
|
||||
}
|
||||
|
||||
// Schema defines the schema for the resource.
|
||||
|
|
@ -250,7 +250,6 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
|
|||
|
||||
// Create creates the resource and sets the initial Terraform state.
|
||||
func (r *instanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
// Retrieve values from plan
|
||||
var model Model
|
||||
diags := req.Plan.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
|
|
@ -260,11 +259,6 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
projectId := model.ProjectId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
|
||||
r.loadPlanId(ctx, &resp.Diagnostics, &model)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
var parameters = ¶metersModel{}
|
||||
var parametersPlugins *[]string
|
||||
if !(model.Parameters.IsNull() || model.Parameters.IsUnknown()) {
|
||||
|
|
@ -288,6 +282,12 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
}
|
||||
}
|
||||
|
||||
err := r.loadPlanId(ctx, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Loading service plan: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Generate API request body from model
|
||||
payload, err := toCreatePayload(&model, parameters, parametersPlugins)
|
||||
if err != nil {
|
||||
|
|
@ -309,19 +309,23 @@ func (r *instanceResource) Create(ctx context.Context, req resource.CreateReques
|
|||
}
|
||||
got, ok := wr.(*postgresql.Instance)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Wait result conversion, got %+v", got))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error mapping fields", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Set state to fully populated data
|
||||
diags = resp.State.Set(ctx, model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Postgresql instance created")
|
||||
}
|
||||
|
||||
|
|
@ -352,40 +356,44 @@ func toCreatePayload(model *Model, parameters *parametersModel, parametersPlugin
|
|||
|
||||
// Read refreshes the Terraform state with the latest data.
|
||||
func (r *instanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
|
||||
var state Model
|
||||
diags := req.State.Get(ctx, &state)
|
||||
var model Model
|
||||
diags := req.State.Get(ctx, &model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
projectId := state.ProjectId.ValueString()
|
||||
instanceId := state.InstanceId.ValueString()
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
|
||||
instanceResp, err := r.client.GetInstance(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instances", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
err = mapFields(instanceResp, &state)
|
||||
// Map response body to schema
|
||||
err = mapFields(instanceResp, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error mapping fields", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Compute and store values not present in the API response
|
||||
loadPlanNameAndVersion(ctx, r.client, &resp.Diagnostics, &state)
|
||||
if resp.Diagnostics.HasError() {
|
||||
err = loadPlanNameAndVersion(ctx, r.client, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading instance", fmt.Sprintf("Loading service plan details: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Set refreshed state
|
||||
diags = resp.State.Set(ctx, state)
|
||||
diags = resp.State.Set(ctx, model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
tflog.Info(ctx, "Postgresql instance read")
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "PostgreSQL instance read")
|
||||
}
|
||||
|
||||
// Update updates the resource and sets the updated Terraform state on success.
|
||||
|
|
@ -401,11 +409,6 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
|
||||
r.loadPlanId(ctx, &resp.Diagnostics, &model)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
var parameters = ¶metersModel{}
|
||||
var parametersPlugins *[]string
|
||||
if !(model.Parameters.IsNull() || model.Parameters.IsUnknown()) {
|
||||
|
|
@ -426,16 +429,22 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
}
|
||||
}
|
||||
|
||||
err := r.loadPlanId(ctx, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating instance", fmt.Sprintf("Loading service plan: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
// Generate API request body from model
|
||||
payload, err := toUpdatePayload(&model, parameters, parametersPlugins)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Could not create API payload: %v", err))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Creating API payload: %v", err))
|
||||
return
|
||||
}
|
||||
// Update existing instance
|
||||
err = r.client.UpdateInstance(ctx, projectId, instanceId).UpdateInstancePayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
wr, err := postgresql.UpdateInstanceWaitHandler(ctx, r.client, projectId, instanceId).SetTimeout(15 * time.Minute).WaitWithContext(ctx)
|
||||
|
|
@ -445,19 +454,23 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
}
|
||||
got, ok := wr.(*postgresql.Instance)
|
||||
if !ok {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Wait result conversion, got %+v", got))
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Wait result conversion, got %+v", wr))
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
// Map response body to schema
|
||||
err = mapFields(got, &model)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error mapping fields in update", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error updating instance", fmt.Sprintf("Processing API payload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
diags = resp.State.Set(ctx, model)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
tflog.Info(ctx, "Postgresql instance updated")
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "PostgreSQL instance updated")
|
||||
}
|
||||
|
||||
func toUpdatePayload(model *Model, parameters *parametersModel, parametersPlugins *[]string) (*postgresql.UpdateInstancePayload, error) {
|
||||
|
|
@ -500,7 +513,7 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
// Delete existing instance
|
||||
err := r.client.DeleteInstance(ctx, projectId, instanceId).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", err.Error())
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Calling API: %v", err))
|
||||
return
|
||||
}
|
||||
_, err = postgresql.DeleteInstanceWaitHandler(ctx, r.client, projectId, instanceId).SetTimeout(15 * time.Minute).WaitWithContext(ctx)
|
||||
|
|
@ -508,7 +521,7 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting instance", fmt.Sprintf("Instance deletion waiting: %v", err))
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "Postgresql instance deleted")
|
||||
tflog.Info(ctx, "PostgreSQL instance deleted")
|
||||
}
|
||||
|
||||
// ImportState imports a resource into the Terraform state on success.
|
||||
|
|
@ -517,8 +530,8 @@ func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportS
|
|||
idParts := strings.Split(req.ID, core.Separator)
|
||||
|
||||
if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" {
|
||||
resp.Diagnostics.AddError(
|
||||
"Unexpected Import Identifier",
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics,
|
||||
"Error importing instance",
|
||||
fmt.Sprintf("Expected import identifier with format: [project_id],[instance_id] Got: %q", req.ID),
|
||||
)
|
||||
return
|
||||
|
|
@ -526,7 +539,7 @@ func (r *instanceResource) ImportState(ctx context.Context, req resource.ImportS
|
|||
|
||||
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("project_id"), idParts[0])...)
|
||||
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("instance_id"), idParts[1])...)
|
||||
tflog.Info(ctx, "Postgresql instance state imported")
|
||||
tflog.Info(ctx, "PostgreSQL instance state imported")
|
||||
}
|
||||
|
||||
func mapFields(instance *postgresql.Instance, model *Model) error {
|
||||
|
|
@ -669,12 +682,11 @@ func mapParameters(params map[string]interface{}) (types.Object, error) {
|
|||
return output, nil
|
||||
}
|
||||
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, diags *diag.Diagnostics, model *Model) {
|
||||
func (r *instanceResource) loadPlanId(ctx context.Context, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
res, err := r.client.GetOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
diags.AddError("Failed to list PostgreSQL offerings", err.Error())
|
||||
return
|
||||
return fmt.Errorf("getting PostgreSQL offerings: %w", err)
|
||||
}
|
||||
|
||||
version := model.Version.ValueString()
|
||||
|
|
@ -695,26 +707,24 @@ func (r *instanceResource) loadPlanId(ctx context.Context, diags *diag.Diagnosti
|
|||
}
|
||||
if strings.EqualFold(*plan.Name, planName) && plan.Id != nil {
|
||||
model.PlanId = types.StringPointerValue(plan.Id)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
availablePlanNames = fmt.Sprintf("%s\n- %s", availablePlanNames, *plan.Name)
|
||||
}
|
||||
}
|
||||
|
||||
if !isValidVersion {
|
||||
diags.AddError("Invalid version", fmt.Sprintf("Couldn't find version '%s', available versions are:%s", version, availableVersions))
|
||||
return
|
||||
return fmt.Errorf("couldn't find version '%s', available versions are: %s", version, availableVersions)
|
||||
}
|
||||
diags.AddError("Invalid plan_name", fmt.Sprintf("Couldn't find plan_name '%s' for version %s, available names are:%s", planName, version, availablePlanNames))
|
||||
return fmt.Errorf("couldn't find plan_name '%s' for version %s, available names are: %s", planName, version, availablePlanNames)
|
||||
}
|
||||
|
||||
func loadPlanNameAndVersion(ctx context.Context, client *postgresql.APIClient, diags *diag.Diagnostics, model *Model) {
|
||||
func loadPlanNameAndVersion(ctx context.Context, client *postgresql.APIClient, model *Model) error {
|
||||
projectId := model.ProjectId.ValueString()
|
||||
planId := model.PlanId.ValueString()
|
||||
res, err := client.GetOfferings(ctx, projectId).Execute()
|
||||
if err != nil {
|
||||
diags.AddError("Failed to list PostgreSQL offerings", err.Error())
|
||||
return
|
||||
return fmt.Errorf("getting PostgreSQL offerings: %w", err)
|
||||
}
|
||||
|
||||
for _, offer := range *res.Offerings {
|
||||
|
|
@ -722,10 +732,10 @@ func loadPlanNameAndVersion(ctx context.Context, client *postgresql.APIClient, d
|
|||
if strings.EqualFold(*plan.Id, planId) && plan.Id != nil {
|
||||
model.PlanName = types.StringPointerValue(plan.Name)
|
||||
model.Version = types.StringPointerValue(offer.Version)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
diags.AddWarning("Failed to get plan_name and version", fmt.Sprintf("Couldn't find plan_name and version for plan_id = %s", planId))
|
||||
return fmt.Errorf("couldn't find plan_name and version for plan_id '%s'", planId)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue