Skip to content

Commit f9157ba

Browse files
dhowdenClément Denoix
andauthored
profile/list: show errors in table listing instead of failing (#145)
* 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]>
1 parent d7fd922 commit f9157ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/cmd/profile/list/list.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ func runListCmd(opts *AddOptions) error {
6868

6969
opts.IO.StartProgressIndicatorWithLabel("Fetching configured profiles")
7070
for _, profile := range profiles {
71+
table.AddField(profile.Name, nil, nil)
72+
table.AddField(profile.ApplicationID, nil, nil)
73+
7174
client := search.NewClient(profile.ApplicationID, profile.APIKey)
7275
res, err := client.ListIndices()
7376
if err != nil {
74-
return err
77+
table.AddField(err.Error(), nil, nil)
78+
} else {
79+
table.AddField(fmt.Sprintf("%d", len(res.Items)), nil, nil)
7580
}
7681

77-
table.AddField(profile.Name, nil, nil)
78-
table.AddField(profile.ApplicationID, nil, nil)
79-
table.AddField(fmt.Sprintf("%d", len(res.Items)), nil, nil)
8082
if profile.Default {
8183
table.AddField(cs.SuccessIcon(), nil, nil)
8284
} else {

0 commit comments

Comments
 (0)