dsco

package module
v1.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

README

dsco (pronounce /ˈdɪskoʊ/. Yes! as 70's music)

GitHub Workflow Status Go Reference Go Version Go Report Card

Maintainability Test Coverage codecov BCH compliance

Scc Count Badge

An easy go configuration helper with powerful features.

WIP! Not ready now!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAliasCollision = errors.New("alias collision")

ErrAliasCollision represents an error indicating that an alias is colliding with an actual key in the structure.

View Source
var ErrCmdlineAlreadyUsed = errors.New("")

ErrCmdlineAlreadyUsed represent an error where ....

View Source
var ErrDuplicateEnvPrefix = errors.New("")

ErrDuplicateEnvPrefix represent an error where ....

View Source
var ErrDuplicateInputStruct = errors.New("")

ErrDuplicateInputStruct represent an error where ....

View Source
var ErrDuplicateStructID = errors.New("")

ErrDuplicateStructID represent an error where ....

View Source
var ErrFiller = errors.New("")
View Source
var ErrGet = errors.New("")
View Source
var ErrInvalidInput = errors.New("")

ErrCmdlineAlreadyUsed represent an error where ....

View Source
var ErrInvalidType = errors.New("invalid type")

ErrInvalidType represent an error where ....

View Source
var ErrLayer = errors.New("")
View Source
var ErrNilInput = errors.New("nil input")

ErrNilInput is dummy...

View Source
var ErrNilProvider = errors.New("nil provider")

ErrNilProvider is shitty...

View Source
var ErrNoAliasesProvided = errors.New("no aliases provided")

ErrNoAliasesProvided represent an error where no aliases map was provided with option.

View Source
var ErrOverriddenKey = errors.New("overridden key")

ErrOverriddenKey represents an error indicating that a potential key binding wha overridden in another layer.

View Source
var ErrParse = errors.New("parse error")

ErrParse represents an error indicating that a value cannot be parsed.

View Source
var ErrStructTypeDiffer = errors.New("struct type differ")

ErrStructTypeDiffer represent an error where cannot produce a valid value bases because struct source type and struct type to fillHelper differs.

View Source
var ErrUnboundedLocation = errors.New("unbound key")

ErrUnboundedLocation represents an error indicating that a key is never bound to the structure.

Functions

func Fill

func Fill(
	inputModelRef any,
	layers ...Layer,
) (
	plocation.Locations,
	error,
)

Fill fills the structure using the layers.

func R

func R[T any](v T) *T

R returns a reference to any value thanks to generics in go1.18.

Types

type AliasCollisionError

type AliasCollisionError struct {
	Path string
}

func (AliasCollisionError) Error

func (a AliasCollisionError) Error() string

func (AliasCollisionError) Is

func (AliasCollisionError) Is(err error) bool

type AliasesOption

type AliasesOption map[string]string

AliasesOption defines keys aliasing.

func WithAliases

func WithAliases(mapping map[string]string) AliasesOption

WithAliases returns a keys aliasing option.

type CmdlineAlreadyUsedError

type CmdlineAlreadyUsedError struct {
	Index int
}

func (CmdlineAlreadyUsedError) Error

func (c CmdlineAlreadyUsedError) Error() string

func (CmdlineAlreadyUsedError) Is

type CmdlineLayer

type CmdlineLayer struct {
	// contains filtered or unexported fields
}

CmdlineLayer is a command line layer.

func WithCmdlineLayer

func WithCmdlineLayer(options ...Option) *CmdlineLayer

WithCmdlineLayer creates a command line layer.

type DuplicateEnvPrefixError

type DuplicateEnvPrefixError struct {
	Prefix string
	Index  int
}

func (DuplicateEnvPrefixError) Error

func (c DuplicateEnvPrefixError) Error() string

func (DuplicateEnvPrefixError) Is

type DuplicateInputStructError

type DuplicateInputStructError struct {
	Index int
}

func (DuplicateInputStructError) Error

func (DuplicateInputStructError) Is

type DuplicateStringProviderError

type DuplicateStringProviderError struct {
	ID    string
	Index int
}

func (DuplicateStringProviderError) Error

type DuplicateStructIDError

type DuplicateStructIDError struct {
	ID    string
	Index int
}

func (DuplicateStructIDError) Error

func (c DuplicateStructIDError) Error() string

func (DuplicateStructIDError) Is

type EnvLayer

type EnvLayer struct {
	// contains filtered or unexported fields
}

EnvLayer is an environnement variable layer.

func WithEnvLayer

func WithEnvLayer(prefix string, options ...Option) *EnvLayer

WithEnvLayer creates an environment variable layer.

type FieldValuesGetter

type FieldValuesGetter interface {
	GetFieldValuesFrom(model ModelInterface) (fvalue.Values, error)
}

FieldValuesGetter defines the ability to get a path/value set (bases).

type FillerErrors

type FillerErrors struct {
	merror.MError
}

func (FillerErrors) Is

func (FillerErrors) Is(err error) bool

type GetError

type GetError struct {
	merror.MError
}

func (GetError) Is

func (GetError) Is(err error) bool

type InvalidInputError

type InvalidInputError struct {
	Type reflect.Type
}

func (InvalidInputError) Error

func (c InvalidInputError) Error() string

func (InvalidInputError) Is

func (InvalidInputError) Is(err error) bool

type Layer

type Layer interface {
	// contains filtered or unexported methods
}

Layer defines a configuration layer.

type LayerErrors

type LayerErrors struct {
	merror.MError
}

func (LayerErrors) Is

func (LayerErrors) Is(err error) bool

type Layers

type Layers []Layer

func (Layers) GetPolicies

func (layers Layers) GetPolicies() (

	constraintLayerPolicies,
	error,
)

type ModelInterface

type ModelInterface interface {
	TypeName() string
	ApplyOn(g internal.Getter) (fvalue.Values, error)
	Expand(g internal.Expander) error
	GetFieldValuesFor(id string, v reflect.Value) fvalue.Values
	Fill(
		inputModelValue reflect.Value,
		layers []fvalue.Values,
	) (plocation.Locations, error)
}

type NamedStringValuesProvider

type NamedStringValuesProvider interface {
	StringValuesProvider
	GetName() string
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is processing option for string based binder.

type OverriddenKeyError

type OverriddenKeyError struct {
	Path             string
	Location         string
	OverrideLocation string
}

func (OverriddenKeyError) Error

func (a OverriddenKeyError) Error() string

func (OverriddenKeyError) Is

func (OverriddenKeyError) Is(err error) bool

type ParseError

type ParseError struct {
	Path     string
	Type     reflect.Type
	Location string
}

func (ParseError) Error

func (a ParseError) Error() string

func (ParseError) Is

func (ParseError) Is(err error) bool

type PoliciesGetter

type PoliciesGetter interface {
	GetPolicies() (constraintLayerPolicies, error)
}

type StrictCmdlineLayer

type StrictCmdlineLayer struct {
	// contains filtered or unexported fields
}

StrictCmdlineLayer is a strict command line layer.

func WithStrictCmdlineLayer

func WithStrictCmdlineLayer(options ...Option) *StrictCmdlineLayer

WithStrictCmdlineLayer creates a strict command line layer. It can be used only once.

type StrictEnvLayer

type StrictEnvLayer struct {
	// contains filtered or unexported fields
}

StrictEnvLayer is a strict environnement variables layer.

func WithStrictEnvLayer

func WithStrictEnvLayer(prefix string, options ...Option) *StrictEnvLayer

WithStrictEnvLayer creates a new strict environment layer.

type StrictStringProviderLayer

type StrictStringProviderLayer struct {
	StringProviderLayer
}

func WithStrictStringValueProvider

func WithStrictStringValueProvider(
	provider NamedStringValuesProvider,
	options ...Option,
) *StrictStringProviderLayer

type StrictStructLayer

type StrictStructLayer struct {
	// contains filtered or unexported fields
}

StrictStructLayer is a strict structure layer.

func WithStrictStructLayer

func WithStrictStructLayer(input any, id string) *StrictStructLayer

WithStrictStructLayer creates a new strict structure layer.

type StringBasedBuilder

type StringBasedBuilder struct {
	// contains filtered or unexported fields
}

StringBasedBuilder is a value bases builder depending on text values.

func CmdLine

func CmdLine(options ...Option) (
	*StringBasedBuilder,
	error,
)

CmdLine builds a command line manager.

func Env

func Env(prefix string, options ...Option) (
	*StringBasedBuilder,
	error,
)

Env builds a env manager.

func NewStringBasedBuilder

func NewStringBasedBuilder(
	provider StringValuesProvider,
	options ...Option,
) (
	*StringBasedBuilder,
	error,
)

NewStringBasedBuilder creates a bases builder for the provided path/text value set.

func (*StringBasedBuilder) Expand

func (s *StringBasedBuilder) Expand(
	path string,
	_type reflect.Type) (
	err error,
)

func (*StringBasedBuilder) Get

func (s *StringBasedBuilder) Get(
	path string,
	_type reflect.Type,
) (
	fieldValue *fvalue.Value,
	err error,
)

func (*StringBasedBuilder) GetFieldValuesFrom

func (s *StringBasedBuilder) GetFieldValuesFrom(
	model ModelInterface,
) (
	fvalue.Values,
	error,
)

GetBaseFor creates the bases.

type StringProviderLayer

type StringProviderLayer struct {
	// contains filtered or unexported fields
}

func WithStringValueProvider

func WithStringValueProvider(
	provider NamedStringValuesProvider,
	options ...Option,
) *StringProviderLayer

type StringValuesProvider

type StringValuesProvider interface {
	GetStringValues() svalue.Values
}

StringValuesProvider defines the behaviour if a string value provider.

type StructBuilder

type StructBuilder struct {
	// contains filtered or unexported fields
}

StructBuilder is a structure layer builder.

func NewStructBuilder

func NewStructBuilder(inputStruct any, id string) (*StructBuilder, error)

NewStructBuilder creates a new structure layer builder.

func (*StructBuilder) GetFieldValuesFrom

func (s *StructBuilder) GetFieldValuesFrom(model ModelInterface) (
	fvalue.Values, error,
)

type StructLayer

type StructLayer struct {
	// contains filtered or unexported fields
}

StructLayer is a structure layer.

func WithStructLayer

func WithStructLayer(input any, id string) *StructLayer

WithStructLayer creates a structure layer.

type UnboundedLocationError

type UnboundedLocationError struct {
	Location string
}

func (UnboundedLocationError) Error

func (a UnboundedLocationError) Error() string

func (UnboundedLocationError) Is

type UnboundedLocationErrors

type UnboundedLocationErrors []UnboundedLocationError

func (UnboundedLocationErrors) Len

func (u UnboundedLocationErrors) Len() int

func (UnboundedLocationErrors) Less

func (u UnboundedLocationErrors) Less(i, j int) bool

func (UnboundedLocationErrors) Swap

func (u UnboundedLocationErrors) Swap(i, j int)

Directories

Path Synopsis
dummy
d1
examples
env

Jump to

Keyboard shortcuts

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