decentral1se
e1a10723ce
All checks were successful
continuous-integration/drone/push Build is passing
46 lines
1.0 KiB
Go
46 lines
1.0 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)
|
|
return nil
|
|
}
|
|
|
|
rec, ok := catalogue[recipe]
|
|
if !ok {
|
|
logrus.Fatalf("'%s' recipe doesn't exist?", recipe)
|
|
}
|
|
|
|
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]
|
|
table.Append([]string{version, service, meta.Image, meta.Digest})
|
|
}
|
|
}
|
|
|
|
table.SetAutoMergeCells(true)
|
|
table.Render()
|
|
|
|
return nil
|
|
},
|
|
}
|