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

Read vault token from ~/.vault-token if none supplied #11529

Closed
wants to merge 4 commits into from
Closed

Read vault token from ~/.vault-token if none supplied #11529

wants to merge 4 commits into from

Conversation

eraserhd
Copy link
Contributor

This closes #11365 (a feature request).

Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

Hi @eraserhd! Thanks for submitting this.

This seems like a great idea, and a fine implementation. I just left a minor comment inline about consistency with the behavior of Vault itself.

token := d.Get("token").(string)
if token == "" {
// Use the vault CLI's token, if present.
tokenFile := fmt.Sprintf("%s/.vault-token", os.Getenv("HOME"))
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like vault's own implementation of this uses the go-homedir library, which tries various different means to locate the user's home directory, including some specialized support for Windows systems.

Do you think using that here would make sense, so we can ensure that the behavior will be consistent with Vault itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha, I noticed and pushed a patch apparently just as you were commenting. This is done.

@eraserhd
Copy link
Contributor Author

eraserhd commented Feb 1, 2017

I think the CI issue is not related. This should be good to go.

// Use the vault CLI's token, if present.
homePath, err := homedir.Dir()
if err != nil {
return nil, fmt.Errorf("No vault token found: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't this error be called if the homedir was unable to be found? The error text might need to be clarified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clarified.

@apparentlymart
Copy link
Contributor

Thanks @eraserhd! This is merged in f1803ba.

@ghost
Copy link

ghost commented Apr 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vault provider should use ~/.vault-token if VAULT_TOKEN isn't set
4 participants