config

package
v0.0.0-...-034e762 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

DefaultValidator is the default validator used by the config package.

Functions

func LoadForStruct

func LoadForStruct[T any](
	ctx context.Context,
	target target.Target,
	userInput map[string]any,
) (T, error)

LoadForStruct loads the given user input map into the given struct and validates it.

Types

type GetConfigProviderByName

type GetConfigProviderByName func(name string) (Provider, bool)

GetConfigProviderByName gets a provider by name.

type LoadAndValidateParams

type LoadAndValidateParams[T any] func(ctx context.Context, target target.Target, userInput map[string]any) (T, error)

LoadAndValidateParams restores and validates the parameters from the given user input map.

type Provider

type Provider interface {
	// Name - name of the provider.
	Name() string
	// Resolve - resolves the configuration for the given target and user input map.
	Resolve(ctx context.Context, target target.Target, userInput map[string]any) (string, error)
	// contains filtered or unexported methods
}

Provider provides a configuration.

func Provide

func Provide[T any](
	name string,
	loader LoadAndValidateParams[T],
	resolver ResolveConfig[T],
) Provider

Provide creates a config provider using the loader and resolver functions.

type ProviderRegistry

type ProviderRegistry interface {
	// Register - registers a config provider.
	Register(provider Provider) ProviderRegistry
	// GetByName - gets a provider by name.
	GetByName(name string) (Provider, bool)
	// GetNames - gets the names of all registered providers.
	GetNames() []string
}

ProviderRegistry is a registry of configuration providers.

func NewRegistry

func NewRegistry() ProviderRegistry

type ResolveConfig

type ResolveConfig[T any] func(ctx context.Context, target target.Target, params T) (string, error)

ResolveConfig resolves the configuration for the given target and parameters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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