Documentation
¶
Overview ¶
Package config loads reusable Directory client context configuration.
Index ¶
- Constants
- func ClearExtractor(path string) error
- func DefaultPath() (string, error)
- func ResolveConfigured(localOpts ...sdk.Option) (extractor.Extractor, error)
- func ResolveDoctor(opts ResolveOptions) (*Doctor, *ResolvedContext, error)
- func ResolveSigstore(opts ResolveOptions) (*ResolvedSigstore, *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
- type ResolvedSigstore
- type Sigstore
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 ResolveConfigured ¶ added in v1.7.0
ResolveConfigured resolves the extractor from the machine-wide config saved by `dirctl init`, returning the Extractor interface. It honors a persisted RemoteAddr (remote backend) and otherwise loads the provisioned local assets. localOpts tune the local backend only. It errors clearly when init has not run.
func ResolveDoctor ¶
func ResolveDoctor(opts ResolveOptions) (*Doctor, *ResolvedContext, error)
ResolveDoctor resolves diagnostic-only settings for the selected context.
func ResolveSigstore ¶ added in v1.8.0
func ResolveSigstore(opts ResolveOptions) (*ResolvedSigstore, *ResolvedContext, error)
ResolveSigstore resolves the Sigstore settings for the selected context, with DIRECTORY_CLIENT_SIGSTORE_* environment variables applied over the context's sigstore section. An environment variable set to an empty string counts as unset. Flag precedence is left to the caller, which knows which flags were set explicitly.
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).
func SaveFile ¶
SaveFile writes a reusable client context config file.
Preserving unrecognized top-level sections requires file to have come from the tolerant load path, which is where they are captured; every writer in this package does that. A File built by hand, or loaded through the strict LoadFile, carries none, so saving it drops any section this binary does not model. Only whole-document rewrites should do that deliberately.
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"`
OIDCScopes []string `yaml:"oidc_scopes"`
OIDCAudience string `yaml:"oidc_audience"`
AuthToken string `yaml:"auth_token"`
Doctor Doctor `yaml:"doctor"`
Sigstore Sigstore `yaml:"sigstore,omitempty"`
}
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
type Extractor struct {
OASFURL string `yaml:"oasf_url"`
AssetDir string `yaml:"asset_dir"`
// RemoteAddr is an optional gRPC OASF-SDK server address. When set,
// consumers resolve the remote extractor backend instead of loading the
// in-process assets under AssetDir.
RemoteAddr string `yaml:"remote_addr,omitempty"`
}
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"`
// contains filtered or unexported fields
}
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.
type ResolvedSigstore ¶ added in v1.8.0
type ResolvedSigstore struct {
Sigstore
// Sources maps the key of every set setting (for example "ignore_tlog") to
// where its value came from: `context "corp"`, or the name of the
// environment variable. Unset settings have no entry.
Sources map[string]string
}
ResolvedSigstore is the effective Sigstore settings with the origin of each setting that is set.
type Sigstore ¶ added in v1.8.0
type Sigstore struct {
// Signing.
FulcioURL string `yaml:"fulcio_url,omitempty"`
RekorURL string `yaml:"rekor_url,omitempty"`
TimestampURL string `yaml:"timestamp_url,omitempty"`
SkipTlog bool `yaml:"skip_tlog,omitempty"`
OIDCProviderURL string `yaml:"oidc_provider_url,omitempty"`
// OIDCClientID is the client used to obtain a Fulcio certificate. It is a
// different client from the context's top-level oidc_client_id, which
// dirctl auth login uses.
OIDCClientID string `yaml:"oidc_client_id,omitempty"`
// Verification.
TufMirrorURL string `yaml:"tuf_mirror_url,omitempty"`
TrustedRootPath string `yaml:"trusted_root_path,omitempty"`
IgnoreTlog bool `yaml:"ignore_tlog,omitempty"`
IgnoreTsa bool `yaml:"ignore_tsa,omitempty"`
IgnoreSct bool `yaml:"ignore_sct,omitempty"`
}
Sigstore holds the keyless (OIDC) signing and verification settings used by dirctl sign and dirctl verify.
A zero value means "unset" and leaves the built-in public-good default in place. Two consequences follow. A boolean can only be turned on from config, never forced to false; that is safe because every boolean default is false today, but flipping a default to true would make a configured false a silent no-op. And a string cannot be set to empty from config or the environment (for example to drop the timestamp authority); only an explicitly passed flag such as --timestamp-url "" can do that.
Secrets (the OIDC client secret and ID token) are deliberately absent: they are accepted only as flags so they never land in the config file.