Extended info message regarding VAULT_ADDR env variable for Windows when running server -dev (#5970)

* Improved info message for Windows when running `server -dev`

Improvement for https://github.com/hashicorp/vault/issues/3405

* output updated to:

You may need to set the following environment variable:
PowerShell:
    $env:VAULT_ADDR="http://127.0.0.1:8200"
cmd.exe:
    set VAULT_ADDR=http://127.0.0.1:8200
This commit is contained in:
Pawel Gorczynski
2018-12-20 19:27:21 +01:00
committed by Brian Kassouf
parent 7cf6b245fb
commit fe0bb20c04

View File

@@ -1008,13 +1008,6 @@ CLUSTER_SYNTHESIS_COMPLETE:
sort.Strings(plugins) sort.Strings(plugins)
} }
export := "export"
quote := "'"
if runtime.GOOS == "windows" {
export = "set"
quote = ""
}
// Print the big dev mode warning! // Print the big dev mode warning!
c.UI.Warn(wrapAtLength( c.UI.Warn(wrapAtLength(
"WARNING! dev mode is enabled! In this mode, Vault runs entirely " + "WARNING! dev mode is enabled! In this mode, Vault runs entirely " +
@@ -1024,8 +1017,16 @@ CLUSTER_SYNTHESIS_COMPLETE:
c.UI.Warn("") c.UI.Warn("")
c.UI.Warn("You may need to set the following environment variable:") c.UI.Warn("You may need to set the following environment variable:")
c.UI.Warn("") c.UI.Warn("")
c.UI.Warn(fmt.Sprintf(" $ %s VAULT_ADDR=%s%s%s",
export, quote, "http://"+config.Listeners[0].Config["address"].(string), quote)) endpointURL := "http://"+config.Listeners[0].Config["address"].(string)
if runtime.GOOS == "windows" {
c.UI.Warn("PowerShell:")
c.UI.Warn(fmt.Sprintf(" $env:VAULT_ADDR=\"%s\"", endpointURL))
c.UI.Warn("cmd.exe:")
c.UI.Warn(fmt.Sprintf(" set VAULT_ADDR=%s", endpointURL))
} else {
c.UI.Warn(fmt.Sprintf(" $ export VAULT_ADDR='%s'", endpointURL))
}
// Unseal key is not returned if stored shares is supported // Unseal key is not returned if stored shares is supported
if len(init.SecretShares) > 0 { if len(init.SecretShares) > 0 {