feat: add recipe versions command

This commit is contained in:
decentral1se 2021-07-24 23:18:23 +02:00
parent dfc91a86a1
commit 6eee02d90a
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 37 additions and 1 deletions

View File

@ -33,7 +33,7 @@ Disclaimer!: List is WIP
- [x] `ls`
- [ ] `create`
- [ ] `release`
- [ ] `versions`
- [x] `versions`
- [ ] `abra upgrade`
- [x] `version`
- [ ] `doctor`

View File

@ -174,10 +174,46 @@ var recipeListCommand = &cli.Command{
},
}
var recipeVersionCommand = &cli.Command{
Name: "versions",
Usage: "List available versions for <recipe>",
ArgsUsage: "<recipe>",
Action: func(c *cli.Context) error {
recipe := c.Args().First()
if recipe == "" {
cli.ShowSubcommandHelp(c)
return nil
}
apps, err := ReadApps()
if err != nil {
logrus.Fatal(err)
}
if app, ok := apps[recipe]; ok {
tableCol := []string{"Version", "Service", "Image", "Digest"}
table := createTable(tableCol)
for version := range app.Versions {
for service := range app.Versions[version] {
meta := app.Versions[version][service]
table.Append([]string{version, service, meta.Image, meta.Digest})
}
}
table.SetAutoMergeCells(true)
table.Render()
return nil
}
logrus.Fatalf("'%s' recipe doesn't exist?", recipe)
return nil
},
}
var RecipeCommand = &cli.Command{
Name: "recipe",
HideHelp: true,
Subcommands: []*cli.Command{
recipeListCommand,
recipeVersionCommand,
},
}