github.com/govau/cf-common@v0.0.7/env/opts.go (about)

     1  package env
     2  
     3  import "os"
     4  
     5  // VarSetOpt is a type which defines VarSet options.
     6  type VarSetOpt func(v *VarSet)
     7  
     8  // WithOSLookup configures the VarSet to use the OS env as a lookup source.
     9  func WithOSLookup() VarSetOpt {
    10  	return func(v *VarSet) {
    11  		v.AppendSource(os.LookupEnv)
    12  	}
    13  }
    14  
    15  // WithMapLookup configures the VarSet to use the given map as a lookup source.
    16  func WithMapLookup(m map[string]string) VarSetOpt {
    17  	return func(v *VarSet) {
    18  		v.AppendSource(func(k string) (string, bool) {
    19  			v, ok := m[k]
    20  			return v, ok
    21  		})
    22  	}
    23  }