openDashboardTarget signs the user in, resolves the current application (selecting one if needed), then opens the dashboard page.
(opts *OpenOptions, target dashboardTarget)
| 311 | // openDashboardTarget signs the user in, resolves the current application |
| 312 | // (selecting one if needed), then opens the dashboard page. |
| 313 | func openDashboardTarget(opts *OpenOptions, target dashboardTarget) error { |
| 314 | client := opts.NewDashboardClient(auth.OAuthClientID()) |
| 315 | accessToken, err := opts.Authenticate(opts.IO, client) |
| 316 | if err != nil { |
| 317 | return err |
| 318 | } |
| 319 | |
| 320 | appID, err := opts.resolveApplicationForAccount(client, accessToken) |
| 321 | if err != nil { |
| 322 | return err |
| 323 | } |
| 324 | if appID == "" { |
| 325 | // No application is available to scope to; the selection flow has |
| 326 | // already explained the situation to the user. |
| 327 | return nil |
| 328 | } |
| 329 | |
| 330 | // The base URL is resolved from ALGOLIA_DASHBOARD_URL by the dashboard |
| 331 | // client (falling back to its compiled-in default). |
| 332 | url := dashboardURL(client.DashboardURL, appID, target) |
| 333 | |
| 334 | cs := opts.IO.ColorScheme() |
| 335 | fmt.Fprintf(opts.IO.Out, "Opening %s\n", cs.Bold(url)) |
| 336 | |
| 337 | return opts.Browser(url) |
| 338 | } |
| 339 | |
| 340 | func applicationInAccount(apps []dashboard.Application, appID string) bool { |
| 341 | for _, app := range apps { |
no test coverage detected