Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quickstarts type mapping [CLI-55] #129

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions internal/cli/quickstarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}