cueconfig

package module
v0.0.0-...-7588326 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(configFilePath string, schema, defaults []byte, runtime any, dest any) error

Load loads the CUE configuration at the file or CUE package directory configFilePath. If the file does not exist, os.IsNotExist error is returned.

The schema for the user configuration is given in schema. Usually this will come from a CUE file embedded in the binary by the caller. If it's empty then any configuration data will be allowed.

The user configuration is first read and unified with the schema. Then if runtime is non-nil, it is used to fill in the field "runtime", thus providing the user configuration with any desired runtime values (e.g. environment variables).

Then the result is finalised (which applies any user-specified defaults), then unified with the CUE contained in the defaults argument. This allows the program to specify default values independently from the user.

The result is unmarshaled into the Go value pointed to by dest using cue.Value.Decode (similar to json.Unmarshal).

Types

This section is empty.

Jump to

Keyboard shortcuts

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