bootstrap

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 21 Imported by: 0

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

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

ConfigTransformFunc is a function type that implements the ConfigTransformer interface.

func (ConfigTransformFunc) Transform added in v0.2.6

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

type Option = options.Option

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

func WithBootstrapPrefix(prefixes ...string) Option

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

func WithDefaultPaths(paths map[string]string) Option

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

func WithDirectly(directly bool) Option

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

func WithDirectory(dir string) Option

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

type PathResolverFunc func(baseDir, path string) string

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.

func New

func New(bootstrapPath string, opts ...Option) (res Result, err error)

New creates a new component provider, which is the main entry point for application startup. It orchestrates the entire process of configuration loading and component initialization. It now returns the Result interface.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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