config

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads reusable Directory client context configuration.

Index

Constants

View Source
const (
	// DefaultEnvPrefix is the default environment variable prefix for client config.
	DefaultEnvPrefix = dirclient.DefaultEnvPrefix

	// ClientContextEnv is the DIRECTORY_CLIENT-prefixed context selection environment variable.
	ClientContextEnv = "DIRECTORY_CLIENT_CONTEXT"
)

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the default reusable client config file path.

func ResolveDoctor

func ResolveDoctor(opts ResolveOptions) (*Doctor, *ResolvedContext, error)

ResolveDoctor resolves diagnostic-only settings for the selected context.

func SaveFile

func SaveFile(path string, file *File) error

SaveFile writes a reusable client context config file.

Types

type Context

type Context struct {
	ServerAddress    string `yaml:"server_address"`
	TlsSkipVerify    bool   `yaml:"tls_skip_verify"`
	TlsCertFile      string `yaml:"tls_cert_file"`
	TlsKeyFile       string `yaml:"tls_key_file"`
	TlsCAFile        string `yaml:"tls_ca_file"`
	SpiffeSocketPath string `yaml:"spiffe_socket_path"`
	SpiffeToken      string `yaml:"spiffe_token"`
	AuthMode         string `yaml:"auth_mode"`
	JWTAudience      string `yaml:"jwt_audience"`
	OIDCIssuer       string `yaml:"oidc_issuer"`
	OIDCClientID     string `yaml:"oidc_client_id"`
	AuthToken        string `yaml:"auth_token"`
	Doctor           Doctor `yaml:"doctor"`
}

Context is a named client configuration block.

type ContextSummary

type ContextSummary struct {
	Name    string
	Current bool
}

ContextSummary is a list entry for a configured context.

func ListContexts

func ListContexts(path string) ([]ContextSummary, error)

ListContexts lists configured contexts in name order.

type ContextValidation

type ContextValidation struct {
	Name  string
	Error error
}

ContextValidation describes the validation result for a configured context.

func ValidateContexts

func ValidateContexts(path string, name string) ([]ContextValidation, error)

ValidateContexts validates stored context definitions without applying environment overrides.

type Doctor

type Doctor struct {
	BootstrapPeers []string `yaml:"bootstrap_peers"`
}

Doctor holds diagnostic-only settings for dirctl doctor.

type File

type File struct {
	CurrentContext string             `yaml:"current_context"`
	Contexts       map[string]Context `yaml:"contexts"`
}

File is the top-level reusable client context configuration file.

func LoadFile

func LoadFile(path string) (*File, error)

LoadFile loads a reusable client context config file from path.

func LoadFileWithOptions

func LoadFileWithOptions(path string, opts LoadOptions) (*File, error)

LoadFileWithOptions loads a reusable client context config file from path with parsing options.

type LoadOptions

type LoadOptions struct {
	// AllowUnknownFields permits forward-compatible parsing for callers that only
	// need known client fields from a config that may include command extensions.
	AllowUnknownFields bool
}

LoadOptions controls how a reusable client context config file is loaded.

type ResolveOptions

type ResolveOptions struct {
	// Path is the config file path. If empty, DefaultPath is used.
	Path string

	// Context is an explicit context name override.
	Context string

	// EnvPrefix is the client environment variable prefix. If empty,
	// DefaultEnvPrefix is used.
	EnvPrefix string

	// Overrides contains explicit values, typically from CLI flags.
	Overrides *dirclient.Config

	// OverrideFields lists schema field names from Overrides that should be
	// applied, including zero values. If empty, non-zero override values are
	// applied.
	OverrideFields []string

	// SkipValidation skips required-field validation for callers that only need
	// a subset of client config, such as auth token cache commands.
	SkipValidation bool

	// AllowUnknownFields permits forward-compatible parsing for callers that only
	// need known client fields from a config that may include command extensions.
	AllowUnknownFields bool
}

ResolveOptions controls context and client configuration resolution.

type ResolvedContext

type ResolvedContext struct {
	Name   string
	Source string
	Path   string
}

ResolvedContext describes which context was selected during resolution.

func CurrentContext

func CurrentContext(path string) (*ResolvedContext, error)

CurrentContext returns the persisted current_context without resolving client settings.

func Resolve

Resolve resolves the effective Directory client config.

func SetCurrentContext

func SetCurrentContext(path string, name string) (*ResolvedContext, error)

SetCurrentContext persists name as the active context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL