config

package
v0.0.0-...-5da7bf1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 18 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 {
	OpenAPIFilePath string `koanf:"file" short:"f" description:"file path to your openapi.yaml"`
	OutFilePath     string `koanf:"out" short:"o" description:"out file path or 'stdout'"`
	PackageName     string `koanf:"package" short:"p" description:"package name of the generated file"`
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig() Config

func (*Config) Close

func (c *Config) Close() error

func (*Config) Context

func (c *Config) Context() context.Context

func (*Config) Document

func (c *Config) Document() *openapi3.T

func (*Config) Out

func (c *Config) Out() io.Writer

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