Skip to content

Commit 6c7e871

Browse files
committed
fix linter
1 parent 3d74b3d commit 6c7e871

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

internal/services/baremetal/helpers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"context"
66
"errors"
77
"fmt"
8-
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
98
"sort"
109
"time"
1110

@@ -15,6 +14,7 @@ import (
1514
"github.com/scaleway/scaleway-sdk-go/scw"
1615
"github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors"
1716
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality"
17+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
1818
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
1919
"github.com/scaleway/terraform-provider-scaleway/v2/internal/meta"
2020
"github.com/scaleway/terraform-provider-scaleway/v2/internal/types"
@@ -231,6 +231,7 @@ func customDiffOffer() func(ctx context.Context, diff *schema.ResourceDiff, i in
231231
if diff.Get("offer") == "" || !diff.HasChange("offer") || diff.Id() == "" {
232232
return nil
233233
}
234+
234235
api, zone, err := NewAPIWithZoneAndID(i, diff.Id())
235236
if err != nil {
236237
return err
@@ -239,6 +240,7 @@ func customDiffOffer() func(ctx context.Context, diff *schema.ResourceDiff, i in
239240
oldOffer, newOffer := diff.GetChange("offer")
240241
newOfferID := regional.ExpandID(newOffer.(string))
241242
oldOfferID := regional.ExpandID(oldOffer.(string))
243+
242244
oldOfferDetails, err := FindOfferByID(ctx, api, zone.Zone, oldOfferID.ID)
243245
if err != nil {
244246
return errors.New("can not find the offer by id" + err.Error())
@@ -248,20 +250,25 @@ func customDiffOffer() func(ctx context.Context, diff *schema.ResourceDiff, i in
248250
if err != nil {
249251
return errors.New("can not find the offer by id" + err.Error())
250252
}
253+
251254
if oldOfferDetails.Name != newOfferDetails.Name {
252255
return diff.ForceNew("offer")
253256
}
257+
254258
if oldOfferDetails.SubscriptionPeriod == baremetal.OfferSubscriptionPeriodMonthly && newOfferDetails.SubscriptionPeriod == baremetal.OfferSubscriptionPeriodHourly {
255259
return errors.New("invalid plan transition: you cannot transition from a monthly plan to an hourly plan. Only the reverse (hourly to monthly) is supported. Please update your configuration accordingly")
256260
}
261+
257262
ServerID := regional.ExpandID(diff.Id())
263+
258264
_, err = api.MigrateServerToMonthlyOffer(&baremetal.MigrateServerToMonthlyOfferRequest{
259265
Zone: zone.Zone,
260266
ServerID: ServerID.ID,
261267
}, scw.WithContext(ctx))
262268
if err != nil {
263269
return errors.New("migration to monthly plan failed: " + err.Error())
264270
}
271+
265272
return nil
266273
}
267274
}

internal/services/baremetal/server_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,9 +1043,9 @@ func TestAccServer_UpdateSubscriptionPeriod(t *testing.T) {
10431043
tt := acctest.NewTestTools(t)
10441044
defer tt.Cleanup()
10451045

1046-
//if !IsOfferAvailable(OfferID, Zone", tt) {
1047-
// t.Skip("Offer is out of stock")
1048-
//}
1046+
if !IsOfferAvailable(OfferID, Zone, tt) {
1047+
t.Skip("Offer is out of stock")
1048+
}
10491049

10501050
resource.ParallelTest(t, resource.TestCase{
10511051
PreCheck: func() { acctest.PreCheck(t) },
@@ -1154,7 +1154,6 @@ func TestAccServer_UpdateSubscriptionPeriod(t *testing.T) {
11541154
},
11551155
},
11561156
})
1157-
11581157
}
11591158

11601159
func testAccCheckBaremetalServerExists(tt *acctest.TestTools, n string) resource.TestCheckFunc {

0 commit comments

Comments
 (0)