package namespaces

import "github.com/hashicorp/vault/sdk/helper/testhelpers/namespaces"

Index

Constants

const RootNamespaceID = "root"

RootNamespaceID is the ID of the root namespace.

const RootNamespacePath = ""

RootNamespacePath is the path of the root namespace.

Variables

var ErrNotFound = errors.New("no namespaces found")

ErrNotFound is returned by funcs in this package when something isn't found, instead of returning (nil, nil).

Functions

func DeleteAllNamespaces

func DeleteAllNamespaces(ctx context.Context, client *api.Client) error

DeleteAllNamespaces uses WalkNamespaces to delete all namespaces, waiting for deletion to complete before returning. The same caveats about namespaces changing underneath us apply as in WalkNamespaces. Traversal is depth-first pre-order, but we must do the deletion in the reverse order, since a namespace containing namespaces cannot be deleted.

func GetNamespaceIDPaths

func GetNamespaceIDPaths(client *api.Client) (map[string]string, error)

GetNamespaceIDPaths does a namespace list and extracts the resulting paths and namespace IDs, returning a map from namespace ID to path. Returns ErrNotFound if no namespaces exist beneath the current namespace set on the client.

func PollDeleteNamespace

func PollDeleteNamespace(ctx context.Context, client *api.Client, nsPath string) error

PollDeleteNamespace issues a namespace delete request and waits for it to complete (since namespace deletes are asynchronous), at least until ctx expires.

func WalkNamespaces

func WalkNamespaces(client *api.Client, f func(id, apiPath string) error) error

WalkNamespaces does recursive namespace list commands to discover the complete namespace hierarchy. This may yield an error or inconsistent results if namespaces change while we're querying them. The callback f is invoked for every namespace discovered. Namespace traversal is pre-order depth-first. If f returns an error, traversal is aborted and the error is returned. Otherwise, an error is only returned if a request results in an error.

Source Files

namespaces.go

Version
v0.18.0 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
1 month ago

Tools for package owners.