MCPcopy Create free account
hub / github.com/anchordotdev/cli / serviceAPID

Method serviceAPID

lcl/setup.go:290–324  ·  view source on GitHub ↗
(ctx context.Context, cfg *cli.Config, drv *ui.Driver, orgAPID, realmAPID string)

Source from the content-addressed store, hash-verified

288}
289
290func (c *Setup) serviceAPID(ctx context.Context, cfg *cli.Config, drv *ui.Driver, orgAPID, realmAPID string) (string, error) {
291 if c.ServiceAPID != "" {
292 return c.ServiceAPID, nil
293 }
294
295 if cfg.Service.APID != "" {
296 drv.Activate(ctx, &componentmodels.ConfigVia{
297 Config: cfg,
298 ConfigFetchFn: func(cfg *cli.Config) any { return cfg.Service.APID },
299 Flag: "--service",
300 Singular: "service",
301 })
302 return cfg.Service.APID, nil
303 }
304
305 selector := &component.Selector[api.Service]{
306 Prompt: fmt.Sprintf("Which %s/%s service's lcl.host local development environment do you want to setup?", ui.Emphasize(orgAPID), ui.Emphasize(realmAPID)),
307 Flag: "--service",
308
309 Creatable: true,
310
311 Fetcher: &component.Fetcher[api.Service]{
312 FetchFn: func() ([]api.Service, error) { return c.anc.GetOrgServices(ctx, orgAPID, api.NonDiagnosticServices) },
313 },
314 }
315
316 service, err := selector.Choice(ctx, drv)
317 if err != nil {
318 return "", err
319 }
320 if service == nil || (*service == api.Service{}) {
321 return "", nil
322 }
323 return service.Slug, nil
324}
325
326func (c *Setup) serviceName(ctx context.Context, cfg *cli.Config, drv *ui.Driver) (string, error) {
327 if cfg.Service.Name != "" {

Callers 1

performMethod · 0.95

Calls 3

ActivateMethod · 0.80
GetOrgServicesMethod · 0.80
ChoiceMethod · 0.80

Tested by

no test coverage detected