bootstrap

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

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) (*bootstrapv1.Bootstrap, 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 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 WithComponentPath added in v0.2.13

func WithComponentPath(componentKey constant.ComponentKey, path string) Option

WithComponentPath sets the configuration path for a specific component. This allows overriding the framework's default path. Providing an empty string for the path ("") will explicitly disable the loading of that component.

func WithComponentPaths added in v0.2.13

func WithComponentPaths(paths map[constant.ComponentKey]string) Option

WithComponentPaths provides a map of component keys to their configuration paths. This map is merged with the framework's defaults, with these values taking precedence. Paths provided here can also be an empty string ("") to disable the corresponding component.

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 WithDirectly added in v0.2.7

func WithDirectly() 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 {
	// Config returns the raw configuration decoder.
	Config() interfaces.Config
	// StructuredConfig returns the structured configuration decoder,
	// which has merged defaults and applied transformers.
	StructuredConfig() interfaces.StructuredConfig
	// AppConfig returns the raw protobuf App message decoded from the bootstrap configuration.
	// This message contains application-specific information as defined in the configuration file.
	AppConfig() *appv1.App
}

Result defines the interface for the raw data produced by the bootstrap process. It provides access to the loaded configuration and the raw application protobuf message.

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. It now returns the Result interface, which contains configuration-related data and the raw App protobuf message.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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