conf

package
v0.0.0-...-577c19e Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig[C any]() (C, error)

Create a new configuration from the default config json file. Return an error if the config cannot be read or parsed.

This will read two files:

  • /etc/config/conf.json
  • /etc/secrets/secrets.json

The values read from secrets.json will override the values in conf.json

func GetConfigOrDie

func GetConfigOrDie[C any]() C

Create a new configuration from the default config json file.

This will read two files:

  • /etc/config/conf.json
  • /etc/secrets/secrets.json

The values read from secrets.json will override the values in conf.json

func UnmarshalParams

func UnmarshalParams(p *v1alpha1.Parameters, into any) error

Unmarshal a list of parameters into a strongly typed struct.

The struct must have json tags that match the keys of the parameters. If the parameters cannot be unmarshaled into the struct, an error is returned.

Types

type JsonOpts

type JsonOpts[Options any] struct {
	// Options loaded from a json config using the Load method.
	Options Options
}

Mixin that adds the ability to load options from a json map. Usage: type StructUsingOpts struct { conf.JsonOpts[MyOpts] }

func (*JsonOpts[Options]) Load

func (s *JsonOpts[Options]) Load(opts RawOpts) error

Set the options contained in the opts json map.

type RawOpts

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

Raw options that are not directly unmarshalled when loading from json. Usage: call Unmarshal to unmarshal the options into a struct.

func NewRawOpts

func NewRawOpts(rawJson string) RawOpts

Create a new RawOpts instance with the given json string.

func NewRawOptsBytes

func NewRawOptsBytes(rawJson []byte) RawOpts

func (*RawOpts) Unmarshal

func (msg *RawOpts) Unmarshal(v any) error

Call the postponed unmarshal function and unmarshal the options into a struct.

func (*RawOpts) UnmarshalJSON

func (msg *RawOpts) UnmarshalJSON(data []byte) error

Override the default json unmarshal behavior to postpone the unmarshal.

Jump to

Keyboard shortcuts

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