Skip to content

Commit 4ee6025

Browse files
authored
fix : service instance update with new service plan (#248)
1 parent 6b89c86 commit 4ee6025

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

internal/provider/resource_service_instance.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -451,23 +451,8 @@ func (r *serviceInstanceResource) Update(ctx context.Context, req resource.Updat
451451
if plan.Name.ValueString() != previousState.Name.ValueString() {
452452
updateServiceInstance.Name = plan.Name.ValueStringPointer()
453453
}
454-
// Check if the service plan is different from the previous state
454+
//Check if service plan is different from the previous state
455455
if plan.ServicePlan.ValueString() != previousState.ServicePlan.ValueString() {
456-
ok, err := isServiceInstanceUpgradable(ctx, previousState.ID.ValueString(), *r.cfClient)
457-
if err != nil {
458-
resp.Diagnostics.AddError(
459-
"Error in checking service instance upgradability",
460-
"Unable to check service instance upgradability"+plan.Name.ValueString()+": "+err.Error(),
461-
)
462-
return
463-
}
464-
if !ok {
465-
resp.Diagnostics.AddError(
466-
"Service instance not upgradable",
467-
"Service instance "+plan.Name.ValueString()+" is not upgradable",
468-
)
469-
return
470-
}
471456
updateServiceInstance.Relationships = &cfv3resource.ServiceInstanceRelationships{
472457
ServicePlan: &cfv3resource.ToOneRelationship{
473458
Data: &cfv3resource.Relationship{

internal/provider/types_service_instance.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package provider
22

33
import (
44
"context"
5-
"time"
6-
7-
cfv3client "github.com/cloudfoundry/go-cfclient/v3/client"
85
"github.com/cloudfoundry/go-cfclient/v3/resource"
96
"github.com/hashicorp/terraform-plugin-framework-jsontypes/jsontypes"
107
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
118
"github.com/hashicorp/terraform-plugin-framework/attr"
129
"github.com/hashicorp/terraform-plugin-framework/diag"
1310
"github.com/hashicorp/terraform-plugin-framework/types"
11+
"time"
1412
)
1513

1614
type serviceInstanceType struct {
@@ -275,16 +273,6 @@ func mapMaintenanceInfo(value resource.ServiceInstanceMaintenanceInfo) maintenan
275273

276274
}
277275

278-
// isServiceInstanceUpgradable checks if the service instance is upgradable
279-
// some service instances may not be upgradable.
280-
func isServiceInstanceUpgradable(ctx context.Context, guid string, c cfv3client.Client) (bool, error) {
281-
svc, err := c.ServiceInstances.Get(ctx, guid)
282-
if err != nil {
283-
return false, err
284-
}
285-
return svc.UpgradeAvailable != nil && *svc.UpgradeAvailable, nil
286-
}
287-
288276
// toTagsList converts aliases of type types.Set into a slice of strings.
289277
func toTagsList(ctx context.Context, tagsSet types.List) ([]string, diag.Diagnostics) {
290278

0 commit comments

Comments
 (0)