refactor: rename to RecipeMeta
continuous-integration/drone/push Build is failing Details

This commit is contained in:
decentral1se 2021-09-06 01:47:59 +02:00
parent d1527741ba
commit 9862cf17a9
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 11 additions and 11 deletions

View File

@ -21,7 +21,7 @@ var recipeVersionCommand = &cli.Command{
logrus.Fatal(err) logrus.Fatal(err)
} }
rec, ok := catalogue[recipe.Name] recipeMeta, ok := catalogue[recipe.Name]
if !ok { if !ok {
logrus.Fatalf("'%s' recipe doesn't exist?", recipe.Name) logrus.Fatalf("'%s' recipe doesn't exist?", recipe.Name)
} }
@ -29,9 +29,9 @@ var recipeVersionCommand = &cli.Command{
tableCol := []string{"Version", "Service", "Image", "Digest"} tableCol := []string{"Version", "Service", "Image", "Digest"}
table := formatter.CreateTable(tableCol) table := formatter.CreateTable(tableCol)
for version := range rec.Versions { for version := range recipeMeta.Versions {
for service := range rec.Versions[version] { for service := range recipeMeta.Versions[version] {
meta := rec.Versions[version][service] meta := recipeMeta.Versions[version][service]
table.Append([]string{version, service, meta.Image, meta.Digest}) table.Append([]string{version, service, meta.Image, meta.Digest})
} }
} }

View File

@ -51,8 +51,8 @@ type serviceMeta struct {
Tag string `json:"tag"` Tag string `json:"tag"`
} }
// Recipe represents a recipe in the abra catalogue // RecipeMeta represents metadata for a recipe in the abra catalogue.
type Recipe struct { type RecipeMeta struct {
Category string `json:"category"` Category string `json:"category"`
DefaultBranch string `json:"default_branch"` DefaultBranch string `json:"default_branch"`
Description string `json:"description"` Description string `json:"description"`
@ -65,7 +65,7 @@ type Recipe struct {
} }
// LatestVersion returns the latest version of a recipe. // LatestVersion returns the latest version of a recipe.
func (r Recipe) LatestVersion() string { func (r RecipeMeta) LatestVersion() string {
var latestVersion string var latestVersion string
for tag := range r.Versions { for tag := range r.Versions {
// apps.json versions are sorted so the last key is latest // apps.json versions are sorted so the last key is latest
@ -78,11 +78,11 @@ func (r Recipe) LatestVersion() string {
type Name = string type Name = string
// RecipeCatalogue represents the entire recipe catalogue. // RecipeCatalogue represents the entire recipe catalogue.
type RecipeCatalogue map[Name]Recipe type RecipeCatalogue map[Name]RecipeMeta
// Flatten converts AppCatalogue to slice // Flatten converts AppCatalogue to slice
func (r RecipeCatalogue) Flatten() []Recipe { func (r RecipeCatalogue) Flatten() []RecipeMeta {
recipes := make([]Recipe, 0, len(r)) recipes := make([]RecipeMeta, 0, len(r))
for name := range r { for name := range r {
recipes = append(recipes, r[name]) recipes = append(recipes, r[name])
} }
@ -90,7 +90,7 @@ func (r RecipeCatalogue) Flatten() []Recipe {
} }
// ByRecipeName sorts recipes by name. // ByRecipeName sorts recipes by name.
type ByRecipeName []Recipe type ByRecipeName []RecipeMeta
func (r ByRecipeName) Len() int { return len(r) } func (r ByRecipeName) Len() int { return len(r) }
func (r ByRecipeName) Swap(i, j int) { r[i], r[j] = r[j], r[i] } func (r ByRecipeName) Swap(i, j int) { r[i], r[j] = r[j], r[i] }