config

package
v0.0.0-...-13d9b3d Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalDotEnv

func MarshalDotEnv(cfgs ...any) ([]byte, error)

func RegisterFlags

func RegisterFlags[T any](config *T, persistent bool, app *cobra.Command, options ...ParseOption) func() error

Parse takes every object and is able to fill and validate that object depending on config file, env file and flag values. https://github.com/knadh/koanf Your passed struct must define . delimited koanf struct tags in order to match env/.env and flag values to your struct. Additionally your struct may define a Validate() error method which is called at the end of parsing the config Registers flags and returns a parser function that can be used as PreRunE.

Types

type Config

type Config struct {
	DirsOnly  bool   `koanf:"dirs.only" short:"d" description:"only compare directories"`
	FilesOnly bool   `koanf:"files.only" short:"f" description:"only compare files or symlinks"`
	PermOnly  bool   `koanf:"perm.only" short:"p" description:"only compare file permissions and sticky bit"`
	OwnerOnly bool   `koanf:"owner.only" short:"o" description:"only compare owner, group, gid and uid"`
	Exclude   string `koanf:"exclude" short:"e" description:"exclude file paths matching regular expression after cut operation"`
	Include   string `koanf:"include" short:"i" description:"include file paths matching regular expression after cut operation"`
	Cut       string `koanf:"cut" short:"c" description:"cut ^prefix or suffix$ or any other regular expression before comparing archive paths"`

	FileOption   string                     `koanf:"-"`
	Equal        func(a, b model.File) bool `koanf:"-"`
	ExcludeRegex *regexp.Regexp             `koanf:"-"`
	IncludeRegex *regexp.Regexp             `koanf:"-"`
	CutRegex     *regexp.Regexp             `koanf:"-"`
}

func (*Config) Validate

func (c *Config) Validate() error

type ParseOption

type ParseOption func(*parseOption)

func WithDelimiter

func WithDelimiter(delimiter string) ParseOption

func WithDescriptionStructTagName

func WithDescriptionStructTagName(tag string) ParseOption

func WithEnvPrefix

func WithEnvPrefix(prefix string) ParseOption

func WithStructTagName

func WithStructTagName(tag string) ParseOption

type Validatable

type Validatable interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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