Skip to content
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

Merged
merged 3 commits into from
May 10, 2019
Merged

Conversation

vdice
Copy link
Member

@vdice vdice commented May 9, 2019

Adds porter bundle list to list installed bundles, optionally with json/yaml outputs.

In doing so, I made some updates to table.go from the printer pkg, as it appeared previously we weren't actually utilizing the power of the tabWriter library for table output spacing.

  $ porter bundle list
NAME              CREATED               MODIFIED              LAST ACTION   LAST STATUS
porter-keyvault   Fri Apr 26 11:38:27   Fri Apr 26 11:38:41   install       success

 $ porter bundle list -o json
[
  {
    "Name": "porter-keyvault",
    "Created": "Fri Apr 26 11:38:27",
    "Modified": "Fri Apr 26 11:38:41",
    "Action": "install",
    "Status": "success"
  }
]

 $ porter bundle list -o yaml
- name: porter-keyvault
  created: Fri Apr 26 11:38:27
  modified: Fri Apr 26 11:38:41
  action: install
  status: success

Closes #284

@ghost ghost assigned vdice May 9, 2019
@ghost ghost added the review label May 9, 2019
Copy link
Member

@carolynvs carolynvs left a 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.

@@ -77,6 +79,35 @@ func buildBuildCommand(p *porter.Porter) *cobra.Command {
return cmd
}

func buildBundleListCommand(p *porter.Porter) *cobra.Command {
opts := struct {
Copy link
Member

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?

Copy link
Member Author

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 := &cobra.Command{
Use: "list",
Short: "list bundles",
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated....

cmd := &cobra.Command{
Use: "list",
Short: "list bundles",
Long: `List all bundles managed by Porter`,
Copy link
Member

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?

Copy link
Member Author

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"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha wingdings

if !ok {
return nil
}
return []interface{}{cl.Name, cl.Created, cl.Modified, cl.Action, cl.Status}
Copy link
Member

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.

Copy link
Member Author

@vdice vdice May 10, 2019

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.

@@ -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
Copy link
Member

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.

Copy link
Member Author

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{} {
Copy link
Member

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
@vdice vdice mentioned this pull request May 10, 2019
Copy link
Member

@carolynvs carolynvs left a 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{}
Copy link
Member

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.
Copy link
Member

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"
Copy link
Member

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.

@carolynvs carolynvs merged commit 23c1960 into getporter:master May 10, 2019
@ghost ghost removed the review label May 10, 2019
@vdice vdice deleted the feat/list-bundles branch May 10, 2019 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add 'porter bundle(s) list' command
2 participants