Skip to content

Commit 5beaaae

Browse files
committed
tests
1 parent d1869db commit 5beaaae

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

v1/providers/nebius/image.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ func getImageDescription(image *compute.Image) string {
202202
return ""
203203
}
204204

205+
const (
206+
ArchitectureX86_64 = "x86_64"
207+
ArchitectureArm64 = "arm64"
208+
ArchitectureAMD64 = "amd64"
209+
ArchitectureAArch64 = "aarch64"
210+
)
211+
205212
// extractArchitecture extracts architecture information from image metadata
206213
func extractArchitecture(image *compute.Image) string {
207214
// Check labels for architecture info
@@ -217,16 +224,15 @@ func extractArchitecture(image *compute.Image) string {
217224
// Infer from image name
218225
if image.Metadata != nil {
219226
name := strings.ToLower(image.Metadata.Name)
220-
if strings.Contains(name, "arm64") || strings.Contains(name, "aarch64") {
221-
return "arm64"
227+
if strings.Contains(name, ArchitectureArm64) || strings.Contains(name, ArchitectureAArch64) {
228+
return ArchitectureArm64
222229
}
223-
if strings.Contains(name, "x86_64") || strings.Contains(name, "amd64") {
224-
//nolint:goconst // Architecture string used in detection and returned as default
225-
return "x86_64"
230+
if strings.Contains(name, ArchitectureX86_64) || strings.Contains(name, ArchitectureAMD64) {
231+
return ArchitectureX86_64
226232
}
227233
}
228234

229-
return "x86_64"
235+
return ArchitectureX86_64
230236
}
231237

232238
// filterImagesByArchitectures filters images by multiple architectures

v1/providers/nebius/instancetype.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ func (c *NebiusClient) GetInstanceTypes(ctx context.Context, args v1.GetInstance
2929
// Default behavior: check ALL regions to show all available quota
3030
var locations []v1.Location
3131

32-
if len(args.Locations) > 0 && !args.Locations.IsAll() {
32+
if args.Locations.IsAll() { //nolint:gocritic // prefer if statement over switch statement
33+
allLocations, err := c.GetLocations(ctx, v1.GetLocationsArgs{})
34+
if err != nil {
35+
return nil, errors.WrapAndTrace(err)
36+
}
37+
locations = allLocations
38+
} else if len(args.Locations) > 0 {
3339
// User requested specific locations - filter to those
3440
allLocations, err := c.GetLocations(ctx, v1.GetLocationsArgs{})
3541
if err == nil {
@@ -48,15 +54,8 @@ func (c *NebiusClient) GetInstanceTypes(ctx context.Context, args v1.GetInstance
4854
locations = []v1.Location{{Name: c.location}}
4955
}
5056
} else {
51-
// Default behavior: enumerate ALL regions for quota-aware discovery
52-
// This shows users all instance types they have quota for, regardless of region
53-
allLocations, err := c.GetLocations(ctx, v1.GetLocationsArgs{})
54-
if err == nil {
55-
locations = allLocations
56-
} else {
57-
// Fallback to client's configured location if we can't get all locations
58-
locations = []v1.Location{{Name: c.location}}
59-
}
57+
// Fallback to client's configured location if we can't get all locations
58+
locations = []v1.Location{{Name: c.location}}
6059
}
6160

6261
// Get quota information for all regions

0 commit comments

Comments
 (0)