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)
| 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. |
| 17 | func 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 | |
| 35 | var knownPaidPlanNames = map[string]string{ |
| 36 | "grow": "Grow", |
no test coverage detected