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

Only set the namespace if the env var isn't present (#1519) #10556

Merged
merged 4 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,28 @@ func NewClient(c *Config) (*Client, error) {
return client, nil
}

func (c *Client) CloneConfig() *Config {
c.modifyLock.RLock()
defer c.modifyLock.RUnlock()

newConfig := DefaultConfig()
newConfig.Address = c.config.Address
newConfig.AgentAddress = c.config.AgentAddress
newConfig.MaxRetries = c.config.MaxRetries
newConfig.Timeout = c.config.Timeout
newConfig.Backoff = c.config.Backoff
newConfig.CheckRetry = c.config.CheckRetry
newConfig.Limiter = c.config.Limiter
newConfig.OutputCurlString = c.config.OutputCurlString
newConfig.SRVLookup = c.config.SRVLookup

// we specifically want a _copy_ of the client here, not a pointer to the original one
newClient := *c.config.HttpClient
newConfig.HttpClient = &newClient

return newConfig
}

// Sets the address of Vault in the client. The format of address should be
// "<Scheme>://<Host>:<Port>". Setting this on a client will override the
// value of VAULT_ADDR environment variable.
Expand Down
3 changes: 3 additions & 0 deletions changelog/10556.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
agent: Only set the namespace if the VAULT_NAMESPACE env var isn't present
```
3 changes: 0 additions & 3 deletions changelog/_1519.txt

This file was deleted.

8 changes: 5 additions & 3 deletions command/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,11 @@ func (c *AgentCommand) Run(args []string) int {

// Check if a default namespace has been set
mountPath := config.AutoAuth.Method.MountPath
if config.AutoAuth.Method.Namespace != "" {
namespace = config.AutoAuth.Method.Namespace
mountPath = path.Join(namespace, mountPath)
if cns := config.AutoAuth.Method.Namespace; cns != "" {
// Only set this value if the env var is empty, otherwise we end up with a nested namespace
if ens := os.Getenv(api.EnvVaultNamespace); ens == "" {
mountPath = path.Join(cns, mountPath)
}
}

authConfig := &auth.AuthConfig{
Expand Down
22 changes: 22 additions & 0 deletions vendor/github.com/hashicorp/vault/api/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.