config

package
v0.0.0-...-1331670 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package config provides configuration utilities for dealing with configuration from both environment variables and configuration files

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrEnvVarNotFound is returned when an environment variable is not found (os.LookupEnv error)
	ErrEnvVarNotFound = env.ErrEnvVarNotFound
	// ErrParseEnvVar is returned when an environment variable is found but cannot be parsed
	ErrParseEnvVar = env.ErrParseEnvVar
)

define errors for config

View Source
var (
	// EnvOr grabs the env variable or the default
	EnvOr = env.Or

	// Env returns the named env variable if it exists,
	// otherwise returns empty string and an ErrEnvVarNotFound error.
	Env = env.OrError

	// EnvIntOr grabs the env variable as an int or the default
	EnvIntOr = env.IntOr
	// EnvInt returns the named env variable if it exists,
	// otherwise returns 0 and either an ErrEnvVarNotFound or an ErrParseEnvVar error.
	EnvInt = env.IntOrError

	// EnvBoolOr grabs the env variable as an int or the default
	EnvBoolOr = env.BoolOr

	// EnvBool returns the named env variable if it exists,
	// otherwise returns false and either an ErrEnvVarNotFound or an ErrParseEnvVar error.
	EnvBool = env.BoolOrError

	// EnvArrayOr grabs the env variable as an array.  Returns an empty array if
	EnvArrayOr = env.ArrayOr

	// EnvPathOr grabs the env variable as an array splitting on the default (OS specific) path list separator
	EnvPathOr = env.PathOr

	// EnvDurationOr grabs the env variable as a Duration or the default
	EnvDurationOr = env.DurationOr

	// EnvDuration returns the named env variable if it exists,
	// otherwise returns 0 and either an ErrEnvVarNotFound or an ErrParseEnvVar error.
	EnvDuration = env.DurationOrError
)

Redirect functions for backwards compatibility

Functions

func DefaultConfigPath

func DefaultConfigPath(parts ...string) string

DefaultConfigPath is the path we would save the configuration to if needed. In a sense it is the preferred configuration path.

func DefaultConfigSearchPath

func DefaultConfigSearchPath(parts ...string) []string

DefaultConfigSearchPath returns the list of locations to look for configuration files

Example
fmt.Println(DefaultConfigSearchPath("ace", "dt", "config.yaml"))
Output:

func DefaultConfigValidatePath

func DefaultConfigValidatePath(parts ...string) []string

DefaultConfigValidatePath returns the list of paths to validate as configuration files

func Load

func Load(log *slog.Logger, scheme *runtime.Scheme, conf runtime.Object, configFiles []string) error

Load reads in config file by searching for the first in configFiles

Types

This section is empty.

Directories

Path Synopsis
Package env defines functions to load configuration from environment variables
Package env defines functions to load configuration from environment variables

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳