Skip to content

Commit e78126b

Browse files
committed
fix logic
1 parent aa23056 commit e78126b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

internal/services/baremetal/helpers.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ func getOfferInformations(ctx context.Context, offer interface{}, id string, i i
233233
return nil, err
234234
}
235235
if validation.IsUUID(offer.(string)) {
236+
offerID := regional.ExpandID(offer.(string))
237+
return FindOfferByID(ctx, api, zone.Zone, offerID.ID)
238+
} else {
236239
return api.GetOfferByName(&baremetal.GetOfferByNameRequest{
237240
OfferName: offer.(string),
238241
Zone: zone.Zone,
239242
})
240-
} else {
241-
offerID := regional.ExpandID(offer.(string))
242-
return FindOfferByID(ctx, api, zone.Zone, offerID.ID)
243243
}
244244
}
245245

@@ -250,10 +250,15 @@ func customDiffOffer() func(ctx context.Context, diff *schema.ResourceDiff, i in
250250
}
251251

252252
oldOffer, newOffer := diff.GetChange("offer")
253+
253254
oldOfferInfo, err := getOfferInformations(ctx, oldOffer, diff.Id(), i)
255+
if err != nil {
256+
return errors.New(err.Error())
257+
}
258+
254259
newOfferInfo, err := getOfferInformations(ctx, newOffer, diff.Id(), i)
255260
if err != nil {
256-
return errors.New("can not find offer" + err.Error())
261+
return errors.New(err.Error())
257262
}
258263

259264
if oldOfferInfo.Name != newOfferInfo.Name {

0 commit comments

Comments
 (0)