feat: add recipe versions command
This commit is contained in:
parent
dfc91a86a1
commit
6eee02d90a
2
TODO.md
2
TODO.md
|
@ -33,7 +33,7 @@ Disclaimer!: List is WIP
|
|||
- [x] `ls`
|
||||
- [ ] `create`
|
||||
- [ ] `release`
|
||||
- [ ] `versions`
|
||||
- [x] `versions`
|
||||
- [ ] `abra upgrade`
|
||||
- [x] `version`
|
||||
- [ ] `doctor`
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue