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

[Vault-5736] Add (*Client).WithNamespace() for temporary namespace handling #14963

Merged
merged 12 commits into from
Apr 14, 2022

Conversation

VinnyHC
Copy link
Contributor

@VinnyHC VinnyHC commented Apr 7, 2022

Fixes: #14934

In the API Client should have a method to quickly set (or unset) namespaces on calls. Helpful for calls that are intended to be issued against the root.

Current flow for switching namespaces:

	// Create a Client
	nsClient, err := NewClient(DefaultConfig())
	nsClient.SetNamespace("sample-namespace")

	// Clone the client
	rootClient, err := nsClient.Clone()
	// Clear the namespace
	rootClient.ClearNamespace()
	// Make the call
	rootClient.Sys().Health()

Improved flow:

	// Create a client
	nsClient, err := NewClient(DefaultConfig())
	nsClient.SetNamespace("my-ns")
	
	// issued without a namespace
	nsClient.WithNamespace("").Sys().Health()
	
	// issued with X-Vault-Namespace: other-ns
	nsClient.WithNamespace("other-ns").Logical.Read()
	
	// nsClient retains original namespace
	nsClient.Logical.Read()

@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 20:17 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 20:17 Inactive
@VinnyHC VinnyHC requested review from ncabatoff and a team April 7, 2022 20:20
@VinnyHC VinnyHC added this to the 1.11.0-rc1 milestone Apr 7, 2022
@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 20:32 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 20:32 Inactive
api/client.go Show resolved Hide resolved
api/client.go Show resolved Hide resolved
api/client.go Show resolved Hide resolved
api/client.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 21:49 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 21:49 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 13, 2022 15:36 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 13, 2022 15:36 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 16:26 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 14, 2022 16:26 Inactive
@VinnyHC VinnyHC merged commit a442461 into main Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sys: don't set X-Vault-Namespace header for root-only paths
3 participants