Skip to content

Commit

Permalink
profile/list: show errors in table listing instead of failing (#145)
Browse files Browse the repository at this point in the history
* profile/list: annotate error for easier debugging

Without annotation the error is not helpful when you have multiple profiles.

This also appears to require an AdminAPIKey, which might need another change to ammend.

* report errors in the table listing instead of failing

---------

Co-authored-by: Clément Denoix <[email protected]>
  • Loading branch information
dhowden and clemfromspace authored Mar 8, 2024
1 parent d7fd922 commit f9157ba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/cmd/profile/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ func runListCmd(opts *AddOptions) error {

opts.IO.StartProgressIndicatorWithLabel("Fetching configured profiles")
for _, profile := range profiles {
table.AddField(profile.Name, nil, nil)
table.AddField(profile.ApplicationID, nil, nil)

client := search.NewClient(profile.ApplicationID, profile.APIKey)
res, err := client.ListIndices()
if err != nil {
return err
table.AddField(err.Error(), nil, nil)
} else {
table.AddField(fmt.Sprintf("%d", len(res.Items)), nil, nil)
}

table.AddField(profile.Name, nil, nil)
table.AddField(profile.ApplicationID, nil, nil)
table.AddField(fmt.Sprintf("%d", len(res.Items)), nil, nil)
if profile.Default {
table.AddField(cs.SuccessIcon(), nil, nil)
} else {
Expand Down

0 comments on commit f9157ba

Please sign in to comment.