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

No vault addr dont panic #85

Merged

Conversation

drmdrew
Copy link

@drmdrew drmdrew commented Nov 22, 2016

A second attempt at a fix for #84. PTAL @hairyhenderson

This time, rather than twisting gomplate into a pretzel trying to propagate errors, a small testing hack is being made to allow log.Fatal to be overwritten inside tests to inject a mock/spy that doesn't cause the process to exit.

Added unit tests and also checked on the command-line that gomplate doesn't panic when some/all of the VAULT_* environment variables are missing:

echo -n '{{(datasource "vault" "secret/foo").value}}' | gomplate -d vault="vault://"
2016/11/22 09:49:45 VAULT_ADDR is an unparseable URL!

export VAULT_ADDR=https://localhost:8500
echo -n '{{(datasource "vault" "secret/foo").value}}' | gomplate -d vault="vault://"
2016/11/22 09:49:37 No vault auth strategy configured

@@ -0,0 +1,23 @@
package vault
Copy link
Owner

Choose a reason for hiding this comment

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

can you throw these into client_test.go?

@drmdrew drmdrew force-pushed the no-vault-addr-dont-panic branch from 9923ef9 to 3e775e9 Compare November 22, 2016 14:59
@drmdrew
Copy link
Author

drmdrew commented Nov 22, 2016

Removed log.go

@@ -81,9 +89,13 @@ func (c *Client) Do(req *http.Request) (*http.Response, error) {

// Login - log in to Vault with the discovered auth backend and save the token
func (c *Client) Login() error {
if c.Auth == nil {
Copy link
Owner

Choose a reason for hiding this comment

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

Can you move this check inside getAuthStrategy()?

@drmdrew drmdrew force-pushed the no-vault-addr-dont-panic branch from b826f5e to 456eebd Compare November 22, 2016 15:08
@drmdrew
Copy link
Author

drmdrew commented Nov 22, 2016

Moved logFatal to getAuthStrategy

Copy link
Owner

@hairyhenderson hairyhenderson left a comment

Choose a reason for hiding this comment

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

LGTM!

@hairyhenderson hairyhenderson merged commit d12a938 into hairyhenderson:master Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants