Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message and refactoring #200

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions builder/common/omi_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package common

import (
"fmt"
"log"

oscgo "github.com/outscale/osc-sdk-go/v2"
)
Expand Down Expand Up @@ -41,23 +40,17 @@ func (d *OmiFilterOptions) GetFilteredImage(params oscgo.ReadImagesRequest, oscc
params.Filters.AccountAliases = &oali
}

log.Printf("filters to pass to API are %#v", params.GetFilters().ImageIds)
log.Printf("Using OMI Filters %#v", params)

imageResp, _, err := oscconn.Api.ImageApi.ReadImages(oscconn.Auth).ReadImagesRequest(params).Execute()
if err != nil {
err := fmt.Errorf("Error querying OMI: %s", err)
return nil, err
return nil, fmt.Errorf("Error querying OMI: %s", err)
}

if len(imageResp.GetImages()) == 0 {
err := fmt.Errorf("No OMI was found matching filters: %#v", params)
return nil, err
return nil, fmt.Errorf("No OMI was found matching filters: %v", params.Filters.GetImageNames())
}

if len(imageResp.GetImages()) > 1 && !d.MostRecent {
err := fmt.Errorf("your query returned more than one result. Please try a more specific search, or set most_recent to true")
return nil, err
return nil, fmt.Errorf("your query returned more than one result. Please try a more specific search, or set most_recent to true")
}

var image oscgo.Image
Expand Down
2 changes: 1 addition & 1 deletion builder/common/step_source_omi_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *StepSourceOMIInfo) Run(_ context.Context, state multistep.StateBag) mul
}

if len(*imageResp.Images) == 0 {
err := fmt.Errorf("No OMI was found matching filters: %#v", params)
err := fmt.Errorf("No OMI was found matching filters: %v", params.Filters.GetImageNames())
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt
Expand Down
Loading