in tui/pre_processors.go [51:82]
func getBillingAccounts(q *Queue) tea.Cmd {
return func() tea.Msg {
p, err := q.client.BillingAccountList()
if err != nil {
return errMsg{err: err}
}
items := []list.Item{}
for _, v := range p {
id := strings.ReplaceAll(v.Name, "billingAccounts/", "")
items = append(items, item{
value: strings.TrimSpace(id),
label: strings.TrimSpace(v.DisplayName),
})
}
// If there is only 1 billing account, don't bother the user with
// setting it up.
if len(items) == 1 {
ba := strings.ReplaceAll(p[0].Name, "billingAccounts/", "")
key := strings.ReplaceAll(q.currentKey(), billNewSuffix, "")
project := q.stack.GetSetting(key)
if err := q.client.BillingAccountAttach(project, ba); err != nil {
return errMsg{err: fmt.Errorf("attachBilling: could not attach billing to project: %w", err)}
}
return successMsg{}
}
return items
}
}