-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add porter bundle list command #329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very close just some small help text changes and optional follow-ups.
cmd/porter/bundle.go
Outdated
@@ -77,6 +79,35 @@ func buildBuildCommand(p *porter.Porter) *cobra.Command { | |||
return cmd | |||
} | |||
|
|||
func buildBundleListCommand(p *porter.Porter) *cobra.Command { | |||
opts := struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up that I made a mistake when I first did some of the original commands, defining the structs anonymously here, instead of as a type in pkg/porter like we do for other commands like Install.
It would be really nice at some point to fix these older commands to use the new and improved pattern, instead of adding more commands that use my old mistake. I'm fine with merging this, but if you feel motivated, as a follow up maybe we could fix this one and the other one you used as a pattern for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. Definitely, I'll start a follow-up.
cmd/porter/bundle.go
Outdated
|
||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "list bundles", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to be a bit more clear what we are listing. How about "List installed bundles"?
I see that used managed bundles down below which I really like. So maybe you have better wording to suggest? "List managed bundles"? Up to you but just "List bundles" I think is too vague, especially since duffle lists bundles in a different way than porter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated....
cmd/porter/bundle.go
Outdated
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "list bundles", | ||
Long: `List all bundles managed by Porter`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get a bit more verbose here. Maybe let them know that they can see bundles that have been installed? They may not immediately connect the word "managed" with something that they did with "porter install", you know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated; let me know what you think... meanwhile, new ticket to address dissonance between bundles and clams in: #330
}{ | ||
{"no args", "bundle list", ""}, | ||
{"output json", "bundle list -o json", ""}, | ||
{"invalid format", "bundle list -o wingdings", "invalid format: wingdings"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha wingdings
pkg/cnab/provider/list.go
Outdated
if !ok { | ||
return nil | ||
} | ||
return []interface{}{cl.Name, cl.Created, cl.Modified, cl.Action, cl.Status} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to either in this PR or in a follow-up format the dates in a human friendly format. I'm cool with either finding a go format that looks less verbose or using a package like go humanize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with a friendlier format; let me know what you think.
pkg/porter/cnab.go
Outdated
@@ -18,6 +19,7 @@ type CNABProvider interface { | |||
Install(arguments cnabprovider.InstallArguments) error | |||
Upgrade(arguments cnabprovider.UpgradeArguments) error | |||
Uninstall(arguments cnabprovider.UninstallArguments) error | |||
List(opts printer.PrintOptions) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this needs to go on the CNAB provider interface. 🤔 The others were there because they were mapping to code that was all duffle implemented stuff, that later we may want to swap out with test stubs.
This is all porter's own code that doesn't need to be put into this interface. I'd be happy moving all the code out of provider/list.go into pkg/porter/list.go and removing this interface declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good call; moving out 👍
|
||
// tabify is a helper function which takes a slice and injects tab characters | ||
// between each element such that tabwriter can work its magic | ||
func tabify(untabified []interface{}) []interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh! I always use a better package than the stdlib text/tabwriter
and completely forgot to do this.
I think I'll do a follow-up later to switch to a table writer package that I like better but thank you, this fixes the stdlib for now. 👍
* update 'porter bundle list' verbiage * relocate list implementation into porter (remove from cnab/provider) * print times in a condensed, human-readable format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
rawFormat string | ||
format printer.Format | ||
}{} | ||
opts := porter.ListOptions{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! Thanks for fixing my past mistakes for me. 🙇♀
Short: "list bundles", | ||
Long: `List all bundles managed by Porter`, | ||
Short: "list installed bundles", | ||
Long: `List all bundles installed by Porter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
|
||
const ( | ||
// TimeFormat is used to generate a human-readable representation of a raw time.Time value | ||
TimeFormat = "Mon Jan _2 15:04:05" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Seriously, I'm so going to make a prettytime pkg now.
Adds
porter bundle list
to list installed bundles, optionally with json/yaml outputs.In doing so, I made some updates to
table.go
from theprinter
pkg, as it appeared previously we weren't actually utilizing the power of thetabWriter
library for table output spacing.Closes #284