From 1caa30a4df3bea6b4663eb9e4f066126c4c3521c Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Fri, 5 Mar 2021 17:41:54 -0300 Subject: [PATCH] Fix quickstarts mapping --- internal/cli/quickstarts.go | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/internal/cli/quickstarts.go b/internal/cli/quickstarts.go index c95d6a260..6c89a829a 100644 --- a/internal/cli/quickstarts.go +++ b/internal/cli/quickstarts.go @@ -254,27 +254,44 @@ func quickstartPathFor(client *management.Client) (p string, exists bool, err er return target, exists, nil } -func getQuickstart(typ, stack string) (quickstart, error) { - quickstarts, ok := quickstartsByType[typ] +func getQuickstart(t, stack string) (quickstart, error) { + qsType := quickstartsTypeFor(t) + quickstarts, ok := quickstartsByType[qsType] if !ok { - return quickstart{}, fmt.Errorf("unknown quickstart type %s", typ) + return quickstart{}, fmt.Errorf("unknown quickstart type %s", qsType) } for _, q := range quickstarts { if q.Name == stack { return q, nil } } - return quickstart{}, fmt.Errorf("quickstart not found for %s/%s", typ, stack) + return quickstart{}, fmt.Errorf("quickstart not found for %s/%s", qsType, stack) } func quickstartStacksFromType(t string) ([]string, error) { - _, ok := quickstartsByType[t] + qsType := quickstartsTypeFor(t) + _, ok := quickstartsByType[qsType] if !ok { - return nil, fmt.Errorf("unknown quickstart type %s", t) + return nil, fmt.Errorf("unknown quickstart type %s", qsType) } - stacks := make([]string, 0, len(quickstartsByType[t])) - for _, s := range quickstartsByType[t] { + stacks := make([]string, 0, len(quickstartsByType[qsType])) + for _, s := range quickstartsByType[qsType] { stacks = append(stacks, s.Name) } return stacks, nil } + +func quickstartsTypeFor(v string) string { + switch { + case v == "native": + return "native" + case v == "spa": + return "spa" + case v == "regular_web": + return "webapp" + case v == "non_interactive": + return "backend" + default: + return "generic" + } +}