refactor: rename to RecipeMeta
Some checks failed
continuous-integration/drone/push Build is failing

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

View File

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