Skip to content

Commit ffe572e

Browse files
authored
Merge pull request kubernetes-sigs#2135 from shiftstack/error-messages
🌱 cloud: Better error message on image lookup failure
2 parents c197a1f + 4d9cc63 commit ffe572e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/cloud/services/compute/instance.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,20 @@ func (s *Service) GetImageID(image infrav1.ImageParam) (string, error) {
346346

347347
switch len(allImages) {
348348
case 0:
349-
return "", fmt.Errorf("no images were found with the given image filter: %v", image)
349+
var name string
350+
if image.Filter.Name != nil {
351+
name = *image.Filter.Name
352+
}
353+
return "", fmt.Errorf("no images were found with the given image filter: name=%v, tags=%v", name, image.Filter.Tags)
350354
case 1:
351355
return allImages[0].ID, nil
352356
default:
353357
// this should never happen
354-
return "", fmt.Errorf("too many images were found with the given image filter: %v", image)
358+
var name string
359+
if image.Filter.Name != nil {
360+
name = *image.Filter.Name
361+
}
362+
return "", fmt.Errorf("too many images were found with the given image filter: name=%v, tags=%v", name, image.Filter.Tags)
355363
}
356364
}
357365

0 commit comments

Comments
 (0)