forked from toolshed/abra
@ -53,25 +53,29 @@ type serviceMeta struct {
|
||||
|
||||
// RecipeMeta represents metadata for a recipe in the abra catalogue.
|
||||
type RecipeMeta struct {
|
||||
Category string `json:"category"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
Description string `json:"description"`
|
||||
Features features `json:"features"`
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
Repository string `json:"repository"`
|
||||
Versions map[tag]map[service]serviceMeta `json:"versions"`
|
||||
Website string `json:"website"`
|
||||
Category string `json:"category"`
|
||||
DefaultBranch string `json:"default_branch"`
|
||||
Description string `json:"description"`
|
||||
Features features `json:"features"`
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
Repository string `json:"repository"`
|
||||
Versions []map[tag]map[service]serviceMeta `json:"versions"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
|
||||
// LatestVersion returns the latest version of a recipe.
|
||||
func (r RecipeMeta) LatestVersion() string {
|
||||
var latestVersion string
|
||||
for tag := range r.Versions {
|
||||
// apps.json versions are sorted so the last key is latest
|
||||
latestVersion = tag
|
||||
var version string
|
||||
|
||||
// apps.json versions are sorted so the last key is latest
|
||||
latest := r.Versions[len(r.Versions)-1]
|
||||
|
||||
for tag := range latest {
|
||||
version = tag
|
||||
}
|
||||
return latestVersion
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
// Name represents a recipe name.
|
||||
@ -197,11 +201,12 @@ func VersionsOfService(recipe, serviceName string) ([]string, error) {
|
||||
|
||||
versions := []string{}
|
||||
alreadySeen := make(map[string]bool)
|
||||
for version := range rec.Versions {
|
||||
appVersion := rec.Versions[version][serviceName].Tag
|
||||
if _, ok := alreadySeen[appVersion]; !ok {
|
||||
alreadySeen[appVersion] = true
|
||||
versions = append(versions, appVersion)
|
||||
for _, serviceVersion := range rec.Versions {
|
||||
for tag := range serviceVersion {
|
||||
if _, ok := alreadySeen[tag]; !ok {
|
||||
alreadySeen[tag] = true
|
||||
versions = append(versions, tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user