Documentation
¶
Overview ¶
Package bootstrap implements the functions, types, and interfaces for the module.
Package bootstrap implements the functions, types, and interfaces for the module.
Index ¶
- func LoadBootstrapConfig(bootstrapPath string, opts ...Option) (*bootstrapv1.Bootstrap, error)
- func LoadConfig(bootstrapPath string, providerOpts *ProviderOptions) (interfaces.Config, error)
- func SourceWithFile(path string) *sourcev1.SourceConfig
- type ConfigTransformFunc
- type ConfigTransformer
- type Option
- func WithAppInfo(info *interfaces.AppInfo) Option
- func WithBootstrapPrefix(prefixes ...string) Option
- func WithComponent(key string, factory interfaces.ComponentFactory) Option
- func WithConfig(cfg interfaces.Config) Option
- func WithConfigTransformer(transformer ConfigTransformer) Option
- func WithDefaultPaths(paths map[string]string) Option
- func WithDirectly(directly bool) Option
- func WithDirectory(dir string) Option
- func WithPathResolver(resolver PathResolverFunc) Option
- type PathResolverFunc
- type ProviderOptions
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadBootstrapConfig ¶ added in v0.2.6
func LoadBootstrapConfig(bootstrapPath string, opts ...Option) (*bootstrapv1.Bootstrap, error)
LoadBootstrapConfig loads the bootstrapv1.Bootstrap definition from a local bootstrap configuration file. This function is the first step in the configuration process. The temporary config used to load the sources is closed internally.
func LoadConfig ¶ added in v0.2.6
func LoadConfig(bootstrapPath string, providerOpts *ProviderOptions) (interfaces.Config, error)
LoadConfig creates a new configuration decoder instance. It orchestrates the entire configuration decoding process, following a clear, layered approach.
func SourceWithFile ¶ added in v0.2.8
func SourceWithFile(path string) *sourcev1.SourceConfig
Types ¶
type ConfigTransformFunc ¶ added in v0.2.6
type ConfigTransformFunc func(interfaces.Config, interfaces.StructuredConfig) (interfaces.StructuredConfig, error)
ConfigTransformFunc is a function type that implements the ConfigTransformer interface.
func (ConfigTransformFunc) Transform ¶ added in v0.2.6
func (f ConfigTransformFunc) Transform(config interfaces.Config, sc interfaces.StructuredConfig) ( interfaces.StructuredConfig, error)
Transform implements the ConfigTransformer interface for ConfigTransformFunc.
type ConfigTransformer ¶ added in v0.2.6
type ConfigTransformer interface {
Transform(interfaces.Config, interfaces.StructuredConfig) (interfaces.StructuredConfig, error)
}
ConfigTransformer defines an interface for custom transformation of kratosconfig.Config to interfaces.Config.
type Option ¶ added in v0.1.0
Option defines the function signature for configuration options used in the bootstrap process.
func WithAppInfo ¶ added in v0.2.6
func WithAppInfo(info *interfaces.AppInfo) Option
WithAppInfo provides application metadata to the bootstrap process. This information is merged with any metadata loaded from the configuration source.
func WithBootstrapPrefix ¶ added in v0.2.7
WithBootstrapPrefix sets the prefix for environment variables that can override settings in the initial bootstrap configuration file (e.g., `bootstrap.yaml`).
func WithComponent ¶ added in v0.2.6
func WithComponent(key string, factory interfaces.ComponentFactory) Option
WithComponent registers a component factory to be used during bootstrap.
func WithConfig ¶ added in v0.2.6
func WithConfig(cfg interfaces.Config) Option
WithConfig provides a pre-initialized configuration instance. If this option is used, the bootstrap process will skip loading configuration from files.
func WithConfigTransformer ¶ added in v0.2.6
func WithConfigTransformer(transformer ConfigTransformer) Option
WithConfigTransformer allows providing an object that implements the ConfigTransformer interface. This provides a flexible way to customize the creation of the StructuredConfig.
func WithDefaultPaths ¶ added in v0.2.6
WithDefaultPaths provides a default path map for components. This map is merged with the framework's defaults, with these values taking precedence.
func WithDirectly ¶ added in v0.2.7
WithDirectly sets whether to treat the bootstrapPath as a direct configuration source, ignoring any `sources` defined within it.
func WithDirectory ¶ added in v0.2.7
WithDirectory sets the base directory for resolving relative paths in configuration files. If not set, paths are resolved relative to the current working directory.
func WithPathResolver ¶ added in v0.2.7
func WithPathResolver(resolver PathResolverFunc) Option
WithPathResolver provides a custom function to resolve relative paths in configuration sources.
type PathResolverFunc ¶ added in v0.2.7
PathResolverFunc defines the signature for a function that resolves a configuration path. It takes the base directory (of the bootstrap file) and the path from the config source and returns the final, resolved path.
type ProviderOptions ¶ added in v0.2.7
type ProviderOptions struct {
// contains filtered or unexported fields
}
ProviderOptions holds all the configurable settings for the bootstrap provider. It is populated by applying a series of Option functions.
func FromOptions ¶ added in v0.2.6
func FromOptions(opts ...Option) *ProviderOptions
FromOptions creates a ProviderOptions struct from a slice of Option functions. This is the single entry point for processing all bootstrap options.
type Result ¶ added in v0.2.7
type Result interface {
// AppInfo returns the application information.
AppInfo() *interfaces.AppInfo
// Container returns the initialized component provider.
Container() interfaces.Container
// Config returns the configuration decoder.
Config() interfaces.Config
// StructuredConfig returns the structured configuration decoder.
StructuredConfig() interfaces.StructuredConfig
// Logger returns the logger instance.
Logger() log.Logger
// Cleanup returns the cleanup function.
Cleanup() func()
}
Result defines the interface for the result of the bootstrap process. It provides access to the initialized Container, the Config decoder, and a cleanup function to release resources.