resolveApplicationForAccount returns an application ID that belongs to the signed-in account. The configured profile application is used only when it appears in the account's application list; otherwise the user is prompted to select one.
( client *dashboard.Client, accessToken string, )
| 381 | // appears in the account's application list; otherwise the user is prompted to |
| 382 | // select one. |
| 383 | func (opts *OpenOptions) resolveApplicationForAccount( |
| 384 | client *dashboard.Client, |
| 385 | accessToken string, |
| 386 | ) (string, error) { |
| 387 | apps, err := opts.fetchAccountApplications(client, accessToken) |
| 388 | if err != nil { |
| 389 | return "", err |
| 390 | } |
| 391 | |
| 392 | appID, err := opts.config.Profile().GetApplicationID() |
| 393 | if err == nil && applicationInAccount(apps, appID) { |
| 394 | return appID, nil |
| 395 | } |
| 396 | |
| 397 | app, selErr := opts.SelectApplication() |
| 398 | if selErr != nil { |
| 399 | return "", selErr |
| 400 | } |
| 401 | if app == nil { |
| 402 | return "", nil |
| 403 | } |
| 404 | |
| 405 | return app.ID, nil |
| 406 | } |
| 407 | |
| 408 | // dashboardURL builds the dashboard URL for an application page. Application |
| 409 | // pages are scoped via the /apps/{appID} path; account pages carry the |
no test coverage detected