loader

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 10 Imported by: 2

README

loader

Loader is a library for loading configuration from various sources.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogToCtx added in v0.1.1

func SetLogToCtx(ctx context.Context, log Logger) context.Context

Types

type Cache

type Cache struct {
	Consul   *consul.API
	Vault    *vault.API
	File     *file.API
	Template *templatex.Template
}

type Config

type Config struct {
	Export        string
	ExportToValue bool
	Statics       []ConfigStatic
	Dynamics      []ConfigDynamic
}

type ConfigConsul

type ConfigConsul struct {
	// Path is the location in consul KV
	Path string
	// PathPrefix default is empty
	PathPrefix string
	// Raw to load as raw, don't mix with other loaders
	Raw bool
	// Codec YAML,JSON,TOML default is YAML
	Codec string
}

type ConfigContent

type ConfigContent struct {
	// Codec YAML,JSON,TOML default is YAML
	Codec    string
	Content  string
	Raw      bool
	Template bool
}

type ConfigDynamic

type ConfigDynamic struct {
	Consul *ConfigConsul
}

type ConfigFile

type ConfigFile struct {
	// Path is the file location, [toml, yml, yaml, json] supported
	Path string
	// Raw to load as raw, don't mix with other loaders
	Raw bool
}

type ConfigStatic

type ConfigStatic struct {
	Consul  *ConfigConsul
	Vault   *ConfigVault
	File    *ConfigFile
	Content *ConfigContent
}

type ConfigVault

type ConfigVault struct {
	Path string
	// PathPrefix default is empty, path_prefix is must!
	PathPrefix string
	// AppRoleBasePath default is auth/approle/login, not need to set
	AppRoleBasePath string
	// AdditionalPaths additional paths to get from extra content, default is none
	AdditionalPaths []ConfigVaultAdditional
}

type ConfigVaultAdditional

type ConfigVaultAdditional struct {
	// Map is the where to add as trace/config -> ["trace"]["config"]
	Map string
	// Path show location in vault config
	Path string
}

type Configs

type Configs []Config

func (Configs) Load

func (c Configs) Load(ctx context.Context, wg *sync.WaitGroup, cache *Cache, export *Data) error

Load loads all configs to export location. If loads with dynamic config, cancel context to stop loading. Export is used to export data if ExportToValue enabled. Currently just static config supported to export data.

type Data

type Data struct {
	Map map[string]interface{}
	Raw []byte
}

func (*Data) Merge

func (d *Data) Merge(v map[string]interface{})

type Logger added in v0.1.1

type Logger interface {
	Error(msg string, keysAndValues ...interface{})
	Warn(msg string, keysAndValues ...interface{})
	Info(msg string, keysAndValues ...interface{})
	Debug(msg string, keysAndValues ...interface{})
}

Directories

Path Synopsis
consul module
file module
httpx module
vault module

Jump to

Keyboard shortcuts

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