config

package
v1.5.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileName = "config.yaml"
)

Variables

Functions

func GenerateNodeID

func GenerateNodeID(ctx context.Context, nodeNameProviderType string) (string, error)

func KeyAsEnvVar added in v1.0.4

func KeyAsEnvVar(key string) string

KeyAsEnvVar returns the environment variable corresponding to a config key

func MigrateV1

func MigrateV1(in v1types.BacalhauConfig) (types.Bacalhau, error)

Types

type Config

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

func New added in v1.3.2

func New(opts ...Option) (*Config, error)

New returns a configuration with the provided options applied. If no options are provided, the returned config contains only the default values.

func (*Config) Load

func (c *Config) Load(path string) error

Load reads in the configuration file specified by `path` overriding any previously set configuration with the values from the read config file. Load returns an error if the file cannot be read.

func (*Config) Merge

func (c *Config) Merge(path string) error

Merge merges a new configuration file specified by `path` with the existing config. Merge returns an error if the file cannot be read

func (*Config) Unmarshal

func (c *Config) Unmarshal(out interface{}) error

Unmarshal returns the current configuration. Unmarshal returns an error if the configuration cannot be unmarshalled.

type Option added in v1.1.5

type Option = func(s *Config)

func WithDefault

func WithDefault(cfg interface{}) Option

WithDefault sets the default config to be used when no values are provided.

func WithEnvironmentVariables

func WithEnvironmentVariables(ev map[string][]string) Option

func WithFlags

func WithFlags(flags map[string][]*pflag.Flag) Option

func WithPaths

func WithPaths(path ...string) Option

WithPaths sets paths to configuration files to be loaded paths to configuration files merged from [0] to [N] e.g. file at index 1 overrides index 0, index 2 overrides index 1 and 0, etc.

func WithValues

func WithValues(values map[string]any) Option

WithValues sets values to be injected into the config, taking precedence over all other options.

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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