env

package
v0.0.0-...-fe5372a Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package env reads configuration values from an ordered list of sources: the database-stored console config, the process environment, a CF user-provided service, config.properties and /etc/secrets. The first source that has a name wins.

It replaces github.com/govau/cf-common/env (unmaintained since 2020), keeping the API jetstream calls so call sites only change their import.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoopLookup

func NoopLookup(string) (string, bool)

NoopLookup finds nothing. It stands in for a source that does not apply, such as a config file that is not there.

Types

type Lookup

type Lookup func(name string) (string, bool)

Lookup returns the value for name and whether it was found.

type VarSet

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

VarSet searches its sources in the order they were added.

func NewVarSet

func NewVarSet(opts ...VarSetOpt) *VarSet

NewVarSet makes a VarSet from opts.

func (*VarSet) AppendSource

func (v *VarSet) AppendSource(s Lookup) *VarSet

AppendSource adds s after every existing source.

func (*VarSet) IsSet

func (v *VarSet) IsSet(name string) bool

IsSet reports whether any source has name. An empty value counts as set.

func (*VarSet) Lookup

func (v *VarSet) Lookup(name string) (string, bool)

Lookup returns the value from the first source that has name.

func (*VarSet) MustBool

func (v *VarSet) MustBool(name string) bool

MustBool returns the value for name parsed by strconv.ParseBool. Unset is false, as with a command-line flag; a value that does not parse panics.

func (*VarSet) MustString

func (v *VarSet) MustString(name string) string

MustString returns the value for name and panics when no source has it.

func (*VarSet) String

func (v *VarSet) String(name, defaultVal string) string

String returns the value for name, or defaultVal when no source has it.

type VarSetOpt

type VarSetOpt func(*VarSet)

VarSetOpt configures a VarSet when it is made.

func WithMapLookup

func WithMapLookup(m map[string]string) VarSetOpt

WithMapLookup adds m as a source.

Jump to

Keyboard shortcuts

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