2021-09-05 20:33:07 +00:00
|
|
|
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 {
|
2021-09-05 23:41:16 +00:00
|
|
|
recipe := internal.ValidateRecipe(c)
|
2021-09-05 20:33:07 +00:00
|
|
|
|
|
|
|
catalogue, err := catalogue.ReadRecipeCatalogue()
|
|
|
|
if err != nil {
|
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-09-05 23:47:59 +00:00
|
|
|
recipeMeta, ok := catalogue[recipe.Name]
|
2021-09-05 22:45:29 +00:00
|
|
|
if !ok {
|
2021-12-25 01:03:09 +00:00
|
|
|
logrus.Fatalf("%s recipe doesn't exist?", recipe.Name)
|
2021-09-05 22:45:29 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 08:15:46 +00:00
|
|
|
tableCol := []string{"Version", "Service", "Image", "Tag", "Digest"}
|
2021-09-05 22:45:29 +00:00
|
|
|
table := formatter.CreateTable(tableCol)
|
|
|
|
|
2021-09-06 14:51:42 +00:00
|
|
|
for _, serviceVersion := range recipeMeta.Versions {
|
|
|
|
for tag, meta := range serviceVersion {
|
|
|
|
for service, serviceMeta := range meta {
|
2021-09-08 08:15:46 +00:00
|
|
|
table.Append([]string{tag, service, serviceMeta.Image, serviceMeta.Tag, serviceMeta.Digest})
|
2021-09-06 14:51:42 +00:00
|
|
|
}
|
2021-09-05 20:33:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-05 22:45:29 +00:00
|
|
|
table.SetAutoMergeCells(true)
|
|
|
|
table.Render()
|
|
|
|
|
2021-09-05 20:33:07 +00:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|