Skip to content

Commit

Permalink
Don't clone OutputCurlString value (#14968)
Browse files Browse the repository at this point in the history
* Don't clone OutputCurlString value, add flag to docs

* Add changelog
  • Loading branch information
digivava authored and Matt Schultz committed Apr 27, 2022
1 parent ecd1ebc commit 38faab7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
32 changes: 15 additions & 17 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ func (c *Client) CloneConfig() *Config {
newConfig.CheckRetry = c.config.CheckRetry
newConfig.Logger = c.config.Logger
newConfig.Limiter = c.config.Limiter
newConfig.OutputCurlString = c.config.OutputCurlString
newConfig.SRVLookup = c.config.SRVLookup
newConfig.CloneHeaders = c.config.CloneHeaders
newConfig.CloneToken = c.config.CloneToken
Expand Down Expand Up @@ -1002,22 +1001,21 @@ func (c *Client) clone(cloneHeaders bool) (*Client, error) {
defer config.modifyLock.RUnlock()

newConfig := &Config{
Address: config.Address,
HttpClient: config.HttpClient,
MinRetryWait: config.MinRetryWait,
MaxRetryWait: config.MaxRetryWait,
MaxRetries: config.MaxRetries,
Timeout: config.Timeout,
Backoff: config.Backoff,
CheckRetry: config.CheckRetry,
Logger: config.Logger,
Limiter: config.Limiter,
OutputCurlString: config.OutputCurlString,
AgentAddress: config.AgentAddress,
SRVLookup: config.SRVLookup,
CloneHeaders: config.CloneHeaders,
CloneToken: config.CloneToken,
ReadYourWrites: config.ReadYourWrites,
Address: config.Address,
HttpClient: config.HttpClient,
MinRetryWait: config.MinRetryWait,
MaxRetryWait: config.MaxRetryWait,
MaxRetries: config.MaxRetries,
Timeout: config.Timeout,
Backoff: config.Backoff,
CheckRetry: config.CheckRetry,
Logger: config.Logger,
Limiter: config.Limiter,
AgentAddress: config.AgentAddress,
SRVLookup: config.SRVLookup,
CloneHeaders: config.CloneHeaders,
CloneToken: config.CloneToken,
ReadYourWrites: config.ReadYourWrites,
}
client, err := NewClient(newConfig)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ func TestClone(t *testing.T) {
if parent.MaxRetries() != clone.MaxRetries() {
t.Fatalf("maxRetries don't match: %v vs %v", parent.MaxRetries(), clone.MaxRetries())
}
if parent.OutputCurlString() != clone.OutputCurlString() {
t.Fatalf("outputCurlString doesn't match: %v vs %v", parent.OutputCurlString(), clone.OutputCurlString())
if parent.OutputCurlString() == clone.OutputCurlString() {
t.Fatalf("outputCurlString was copied over when it shouldn't have been: %v and %v", parent.OutputCurlString(), clone.OutputCurlString())
}
if parent.SRVLookup() != clone.SRVLookup() {
t.Fatalf("SRVLookup doesn't match: %v vs %v", parent.SRVLookup(), clone.SRVLookup())
Expand Down
3 changes: 3 additions & 0 deletions changelog/14968.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
api: Fixes bug where OutputCurlString field was unintentionally being copied over during client cloning
```
5 changes: 5 additions & 0 deletions website/content/docs/commands/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ To get help for a subcommand, run:
$ vault <subcommand> -h
```

To see the equivalent API call required to perform the same operation, use the `-output-curl-string` flag after the subcommand.
```shell-session
vault auth enable -output-curl-string approle
```

## CLI Command Structure

There are a number of command and subcommand options available: HTTP options,
Expand Down

0 comments on commit 38faab7

Please sign in to comment.