MCPcopy Create free account
hub / github.com/algolia/cli / resolveApplicationForAccount

Method resolveApplicationForAccount

pkg/cmd/open/open.go:383–406  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

381// appears in the account's application list; otherwise the user is prompted to
382// select one.
383func (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

Callers 2

runOpenCmdFunction · 0.80
openDashboardTargetFunction · 0.80

Calls 4

applicationInAccountFunction · 0.85
GetApplicationIDMethod · 0.80
ProfileMethod · 0.65

Tested by

no test coverage detected