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

Adding --value flag to credhub get #3

Closed
ljfranklin opened this issue May 11, 2017 · 12 comments
Closed

Adding --value flag to credhub get #3

ljfranklin opened this issue May 11, 2017 · 12 comments

Comments

@ljfranklin
Copy link

To make the CLI more usable in automated scripts, a flag that pulls out just the value of a credential would be super helpful. A current workaround would be setting --output-json and using jq, but a simple flag feels nicer.

For example:

Plain get:

$ credhub get --name /vbox/cf/uaa_scim_users_admin_password
type: password
name: /vbox/cf/uaa_scim_users_admin_password
value: MY_PASSWORD
updated: 2017-05-10T21:25:53Z

With flag:

$ credhub get --name /vbox/cf/uaa_scim_users_admin_password --value
MY_PASSWORD

If this seems reasonable but y'all don't have time, I'd be willing to throw a PR your way.

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/145284463

The labels on this github issue will be updated when the story is started.

@ljfranklin
Copy link
Author

Now that I think about it, would be nice to be able to retrieve nested values as well, e.g. etcd_ca.certificate. Not sure what the right flag syntax is in that case. Maybe --value-path=/ for the whole thing and --value-path=/certificate to grab just a nested field?

@danjahner
Copy link
Contributor

Hey Lyle -

Thanks for the feature request. Can you summarize your use case where you are consuming CLI value programmatically?

It feels consistent to allow property accessors like etcd_ca.certificate, similar to how they are provided by BOSH, but we have some complications to resolve before that would be possible.

@ljfranklin
Copy link
Author

@pivotal-danjahner For example, CI scripts that need the CF admin password in order to run a test suite or programmatically push an app. Also developer workflows for targeting a given CF environment with a one-liner rather than copy-pasting creds in the terminal. For example:

# authenticating against CF
cf auth admin "$( credhub get --name /director/cf/uaa_scim_admin_users_password --value )"
# or pretending the CF CLI has a --ca-cert flag
cf api https://api.bosh-lite.com --ca-cert="$( credhub get --name /director/cf/ca/certificate --value )"

I'd be happy with the first line as a start, sound like getting nested values like in the second line is more complicated.

Does the --value flag that returns only the value of the field seem doable as a backlog item or would you rather take a PR?

@danjahner
Copy link
Contributor

@ljfranklin

We've recently finished a story that restricts credential names to disallow dots as part of the name. After a migration period, we should be able to implement property accessors using the cred-name.property syntax with expected results.

@voelzmo
Copy link

voelzmo commented Jul 9, 2018

ping
We find ourselves writing things like this

CREDHUB_OUTPUT="$(credhub get -n "${CRED-NAME}" 2> /dev/null)"
jq -r ".value" <<< "$(yaml2json <<< "${CREDHUB_OUTPUT}")"

That would be much easier, if the cli could provide just the value with a flag.

@voelzmo
Copy link

voelzmo commented Jul 25, 2018

How do you feel about what Lyle said above?

Does the --value flag that returns only the value of the field seem doable as a backlog item or would you rather take a PR?

I'm not sure if that's a feature you entirely rejected or just didn't prioritize.

@voelzmo
Copy link

voelzmo commented Aug 20, 2018

ping @crawsible

@aegershman
Copy link

aegershman commented Sep 27, 2018

Any updates on feelings about this by any chance?

@mdelillo
Copy link
Contributor

mdelillo commented Oct 1, 2018

@ljfranklin @voelzmo @aegershman we're going to prioritize a story for adding the --value flag to the get command. You can follow along here.

@ankeesler
Copy link

This is done! It is available in the latest version of the CLI. :)

@voelzmo
Copy link

voelzmo commented Aug 30, 2019

@ankeesler I recently tried to use --value but couldn't find that flag. Could you point me to the right direction how I can try that?

EDIT: I just now realized this switch is named --quiet – seems like I didn't understand what that switch is supposed to do. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants