forked from coop-cloud/abra
parent
8aaedee39e
commit
448dadd292
@ -29,10 +29,11 @@ var recipeVersionCommand = &cli.Command{
|
||||
tableCol := []string{"Version", "Service", "Image", "Digest"}
|
||||
table := formatter.CreateTable(tableCol)
|
||||
|
||||
for version := range recipeMeta.Versions {
|
||||
for service := range recipeMeta.Versions[version] {
|
||||
meta := recipeMeta.Versions[version][service]
|
||||
table.Append([]string{version, service, meta.Image, meta.Digest})
|
||||
for _, serviceVersion := range recipeMeta.Versions {
|
||||
for tag, meta := range serviceVersion {
|
||||
for service, serviceMeta := range meta {
|
||||
table.Append([]string{tag, service, serviceMeta.Image, serviceMeta.Digest})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user