Documentation
¶
Overview ¶
Package config loads reusable Directory client context configuration.
Index ¶
- Constants
- func ClearExtractor(path string) error
- func DefaultPath() (string, error)
- func ResolveDoctor(opts ResolveOptions) (*Doctor, *ResolvedContext, error)
- func SaveContext(path string, name string, ctx Context, setCurrent bool) error
- func SaveExtractor(path string, e *Extractor) error
- func SaveFile(path string, file *File) error
- type Context
- type ContextSummary
- type ContextValidation
- type Doctor
- type Extractor
- type File
- type LoadOptions
- type ResolveOptions
- type ResolvedContext
Constants ¶
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 ClearExtractor ¶ added in v1.6.0
ClearExtractor removes the machine-wide extractor section, preserving all other config. It is a genuine no-op when the section is already absent (or no config file exists): it does not create or rewrite the file in that case.
func DefaultPath ¶
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 SaveContext ¶ added in v1.6.0
SaveContext adds or replaces a named context, preserving the other recognized config (current_context, extractor, and the other contexts). When setCurrent is true it also marks that context as current_context. Callers that must not overwrite an existing context should check first (e.g. ListContexts).
func SaveExtractor ¶ added in v1.6.0
SaveExtractor persists the machine-wide extractor section, preserving all other config (contexts, current_context).
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 ¶
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 ¶
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 Extractor ¶ added in v1.6.0
Extractor is the machine-wide OASF taxonomy extractor provisioning record, written by `dirctl init` so import/search consumers can load the provisioned assets in-process without re-choosing the endpoint or asset location.
func LoadExtractor ¶ added in v1.6.0
LoadExtractor returns the persisted machine-wide extractor section, or nil when it is unset or the config file does not exist.
type File ¶
type File struct {
CurrentContext string `yaml:"current_context"`
Contexts map[string]Context `yaml:"contexts"`
Extractor *Extractor `yaml:"extractor,omitempty"`
}
File is the top-level reusable client context configuration file.
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 ¶
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 ¶
func Resolve(opts ResolveOptions) (*dirclient.Config, *ResolvedContext, error)
Resolve resolves the effective Directory client config.
func SetCurrentContext ¶
func SetCurrentContext(path string, name string) (*ResolvedContext, error)
SetCurrentContext persists name as the active context.