cellarspoon
3b5354b2a5
All checks were successful
continuous-integration/drone/push Build is passing
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package recipe
|
|
|
|
import (
|
|
"coopcloud.tech/abra/cli/formatter"
|
|
"coopcloud.tech/abra/cli/internal"
|
|
"coopcloud.tech/abra/pkg/catalogue"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var recipeVersionCommand = &cli.Command{
|
|
Name: "versions",
|
|
Usage: "List recipe versions",
|
|
Aliases: []string{"v"},
|
|
ArgsUsage: "<recipe>",
|
|
Action: func(c *cli.Context) error {
|
|
recipe := internal.ValidateRecipe(c)
|
|
|
|
catalogue, err := catalogue.ReadRecipeCatalogue()
|
|
if err != nil {
|
|
logrus.Fatal(err)
|
|
}
|
|
|
|
recipeMeta, ok := catalogue[recipe.Name]
|
|
if !ok {
|
|
logrus.Fatalf("%s recipe doesn't exist?", recipe.Name)
|
|
}
|
|
|
|
tableCol := []string{"Version", "Service", "Image", "Tag", "Digest"}
|
|
table := formatter.CreateTable(tableCol)
|
|
|
|
for _, serviceVersion := range recipeMeta.Versions {
|
|
for tag, meta := range serviceVersion {
|
|
for service, serviceMeta := range meta {
|
|
table.Append([]string{tag, service, serviceMeta.Image, serviceMeta.Tag, serviceMeta.Digest})
|
|
}
|
|
}
|
|
}
|
|
|
|
table.SetAutoMergeCells(true)
|
|
table.Render()
|
|
|
|
return nil
|
|
},
|
|
}
|