Correctly fail if no Image matches filter
This commit is contained in:
parent
c5fe1e9e34
commit
bd1961b927
|
@ -38,15 +38,13 @@ func (s *StepSourceImageInfo) Run(_ context.Context, state multistep.StateBag) m
|
||||||
}
|
}
|
||||||
|
|
||||||
switch len(i) {
|
switch len(i) {
|
||||||
case 0:
|
|
||||||
return false, fmt.Errorf("No image was found matching filters: %v", s.SourceImageOpts)
|
|
||||||
case 1:
|
case 1:
|
||||||
*image = i[0]
|
*image = i[0]
|
||||||
return true, nil
|
return false, nil
|
||||||
default:
|
default:
|
||||||
if s.SourceMostRecent {
|
if s.SourceMostRecent {
|
||||||
*image = i[0]
|
*image = i[0]
|
||||||
return true, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, fmt.Errorf(
|
return false, fmt.Errorf(
|
||||||
"Your query returned more than one result. Please try a more specific search, or set most_recent to true. Search filters: %v",
|
"Your query returned more than one result. Please try a more specific search, or set most_recent to true. Search filters: %v",
|
||||||
|
@ -54,6 +52,13 @@ func (s *StepSourceImageInfo) Run(_ context.Context, state multistep.StateBag) m
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if image.ID == "" {
|
||||||
|
err := fmt.Errorf("No image was found matching filters: %v", s.SourceImageOpts)
|
||||||
|
state.Put("error", err)
|
||||||
|
ui.Error(err.Error())
|
||||||
|
return multistep.ActionHalt
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error querying image: %s", err)
|
err := fmt.Errorf("Error querying image: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
Loading…
Reference in New Issue