Skip to content

Commit 1ef07d2

Browse files
authored
Fix available Hetzner server types (#623)
Filtered availability by location
1 parent 0399b7d commit 1ef07d2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

pkg/server/hetzner/provider.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,23 @@ func (p *Provider) GetSizes(ctx context.Context, region string) ([]types.Size, e
193193

194194
if region != "" {
195195
available = false
196-
for _, price := range t.Pricings {
197-
if price.Location.Name == region {
196+
// Check if server type is available in the selected location
197+
for _, loc := range t.Locations {
198+
if loc.Location.Name == region {
198199
available = true
199-
priceMonthly, _ = strconv.ParseFloat(price.Monthly.Gross, 64)
200-
priceHourly, _ = strconv.ParseFloat(price.Hourly.Gross, 64)
201200
break
202201
}
203202
}
203+
// Get pricing for the selected location
204+
if available {
205+
for _, price := range t.Pricings {
206+
if price.Location.Name == region {
207+
priceMonthly, _ = strconv.ParseFloat(price.Monthly.Gross, 64)
208+
priceHourly, _ = strconv.ParseFloat(price.Hourly.Gross, 64)
209+
break
210+
}
211+
}
212+
}
204213
} else if len(t.Pricings) > 0 {
205214
priceMonthly, _ = strconv.ParseFloat(t.Pricings[0].Monthly.Gross, 64)
206215
priceHourly, _ = strconv.ParseFloat(t.Pricings[0].Hourly.Gross, 64)

0 commit comments

Comments
 (0)