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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement porter credential show command #401

Merged
merged 3 commits into from Jun 8, 2019

Conversation

vdice
Copy link
Member

@vdice vdice commented Jun 7, 2019

  • Implements the porter credential show command
  • Uses a new tablewriter for this command

Sample:

 $ porter creds show porter-azure-wordpress
Name: porter-azure-wordpress

-----------------------------------------------------------------
  Name             Local Source                       Source Type
-----------------------------------------------------------------
  CLIENT_ID        AZURE_SP_ID                        EnvVar
  CLIENT_SECRET    AZURE_SP_SECRET                    EnvVar
  SUBSCRIPTION_ID  SUBSCRIPTION_ID                    EnvVar
  TENANT_ID        AZURE_SP_TENANT                    EnvVar
  kubeconfig       /Users/vdice/.kubes/mk/kubeconfig  Path

Question(s) for the reviewer:

  • Do we want to update the table writer in our printer pkg to use the tablewriter enlisted for credential show -- and therefore, apply same table formatting/config for all table printing -- or just keep it for this particular command?
  • Is the reflect craziness used for determining credential source type a sign I wildly missed an easier route?! 馃槄

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.

Looks good! Just 2 refactorings that are going to be very helpful for our testing going forward. If you prefer to do it follow-ons, that's fine too.

return errors.Wrap(err, "unable to determine credentials directory")
}

credSet := &credentials.CredentialSet{}
Copy link
Member

Choose a reason for hiding this comment

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

Can you break this up into 2 functions: GetCredential and ShowCredential? It makes it easier for testing and automating porter that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh, you'd think I would've learned this best practice from the last credentials list PR! Thank you for the reminder (again). Updated.

// Iterate through all CredentialStrategies to build up our data set
for _, cs := range credSet.Credentials {
// Build a reflected Source of type reflectedStruct, for use below
reflectedSource := reflectedStruct{
Copy link
Member

Choose a reason for hiding this comment

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

I suggest making an exported function that accepts Source and returns the string representing the the source type. It will be easier to read and I bet others will want to use it too. This looks like it was hard to figure out! 馃憤

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call; now broken out into exported function.

Copy link
Contributor

@jeremyrickard jeremyrickard left a comment

Choose a reason for hiding this comment

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

LGTM

@vdice vdice changed the title Feat/cred show Implement porter credential show command Jun 7, 2019
@jeremyrickard jeremyrickard merged commit 341aea0 into getporter:master Jun 8, 2019
@jeremyrickard
Copy link
Contributor

@vdice let's get the changes from @carolynvs in a follow up, i merged this for the goodness

@vdice vdice deleted the feat/cred-show branch June 10, 2019 15:51
@vdice
Copy link
Member Author

vdice commented Jun 10, 2019

@jeremyrickard @carolynvs I think requested changes were all addressed prior to merge... let me know if not.

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.

None yet

3 participants