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

Function ResolvePlan

pkg/cmd/shared/apputil/plan.go:17–33  ·  view source on GitHub ↗

ResolvePlan maps a --plan value to one of the available plans. An exact match on the plan id wins; the user-facing "free" choice maps to the free-type template, whose id is not fixed (it can be "build"), so it is matched on type.

(plans []dashboard.Plan, value string)

Source from the content-addressed store, hash-verified

15// on the plan id wins; the user-facing "free" choice maps to the free-type
16// template, whose id is not fixed (it can be "build"), so it is matched on type.
17func ResolvePlan(plans []dashboard.Plan, value string) (*dashboard.Plan, error) {
18 for i := range plans {
19 if plans[i].ID == value {
20 return &plans[i], nil
21 }
22 }
23 if value == dashboard.PlanTypeFree {
24 if free := FindFreePlan(plans); free != nil {
25 return free, nil
26 }
27 }
28 return nil, cmdutil.FlagErrorf(
29 "invalid plan %q; available plans: %s",
30 value,
31 strings.Join(PlanChoices(plans), ", "),
32 )
33}
34
35var knownPaidPlanNames = map[string]string{
36 "grow": "Grow",

Callers 1

selectPlanFunction · 0.92

Calls 3

FlagErrorfFunction · 0.92
FindFreePlanFunction · 0.85
PlanChoicesFunction · 0.85

Tested by

no test coverage detected