Skip to content

Commit

Permalink
Merge pull request #129 from auth0/fix-qs-download
Browse files Browse the repository at this point in the history
Fix quickstarts type mapping [CLI-55]
  • Loading branch information
Widcket authored Mar 5, 2021
2 parents 204fda3 + 1caa30a commit 72c1a66
Showing 1 changed file with 25 additions and 8 deletions.
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"
}
}

0 comments on commit 72c1a66

Please sign in to comment.