Documentation ¶
Overview ¶
Package envcfg provides a common way to load configuration variables from the system environment or from based on initial configuration values stored on disk or in a base64 encoded environment variable.
Index ¶
- Constants
- type CertificateProvider
- type Envcfg
- func (ec *Envcfg) AutocertDNSManager(email string, provisioner autocertdns.Provisioner) *autocertdns.Manager
- func (ec *Envcfg) AutocertManager() *autocert.Manager
- func (ec *Envcfg) CertPath() string
- func (ec *Envcfg) CertProvider() CertificateProvider
- func (ec *Envcfg) Env() string
- func (ec *Envcfg) GetBool(key string) bool
- func (ec *Envcfg) GetFloat(key string, bitSize int) float64
- func (ec *Envcfg) GetInt(key string) int
- func (ec *Envcfg) GetInt64(key string, base, bitSize int) int64
- func (ec *Envcfg) GetKey(key string) string
- func (ec *Envcfg) GetString(key string) string
- func (ec *Envcfg) GetUint64(key string, base, bitSize int) uint64
- func (ec *Envcfg) Host() string
- func (ec *Envcfg) Port() int
- func (ec *Envcfg) TLS(certProvider CertificateProvider) *tls.Config
- type Filter
- type Option
Constants ¶
const ( // DefaultVarName is the default environment variable name to load the // initial configuration data from. DefaultVarName = "APP_CONFIG" // DefaultConfigFile is the default file path to load the initial // configuration data from. DefaultConfigFile = "env/config" // DefaultEnvKey is the default runtime environment key. DefaultEnvKey = "runtime.environment" // DefaultHostKey is the default server hostname key. DefaultHostKey = "server.host" // DefaultPortKey is the default server port key. DefaultPortKey = "server.port" // DefaultCertPathKey is the default server certificate path key. DefaultCertPathKey = "server.certs" // DefaultCertProviderKey is the default server certificate provider key. DefaultCertProviderKey = "server.certProvider" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertificateProvider ¶
type CertificateProvider interface {
GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
}
CertificateProvider is the common interface for certificate providers.
type Envcfg ¶
Envcfg handles loading configuration variables from system environment variables or from an initial configuration file.
func (*Envcfg) AutocertDNSManager ¶
func (ec *Envcfg) AutocertDNSManager(email string, provisioner autocertdns.Provisioner) *autocertdns.Manager
AutocertDNSManager returns an autocertdns.Manager.
func (*Envcfg) AutocertManager ¶
AutocertManager returns an autocert.Manager.
func (*Envcfg) CertProvider ¶
func (ec *Envcfg) CertProvider() CertificateProvider
CertProvider returns the configured certificate provider.
func (*Envcfg) GetBool ¶
GetBool retrieves the value for key from the environment, or the supplied configuration data, returning it as a bool.
func (*Envcfg) GetFloat ¶
GetFloat retrieves the value for key from the environment, or the supplied configuration data, returning it as a float64. Uses bitSize as the precision.
func (*Envcfg) GetInt ¶
GetInt retrieves the value for key from the environment, or the supplied configuration data, returning it as a int. Expects numbers to be base 10 and no larger than 32 bits.
func (*Envcfg) GetInt64 ¶
GetInt64 retrieves the value for key from the environment, or the supplied configuration data, returning it as a int64. Uses base and bitSize to parse.
func (*Envcfg) GetKey ¶
GetKey retrieves the value for the key from the environment, or from the initial supplied configuration data.
When the initial value read from the config file or the supplied app environment variable is in the form of "$NAME||<default>" or "$NAME||<default>||<encoding>". Then the value will be read from from the system environment variable $NAME. If that value is empty, then the <default> value will be returned instead. If the third, optional parameter is supplied then the environment variable value (or the default value) will be decoded using the appropriate method.
Current supported <encoding> parameters:
base64 -- value should be base64 decoded file -- value should be read from disk
func (*Envcfg) GetString ¶
GetString retrieves the value for key from the environment or the supplied configuration data, returning it as a string.
NOTE: alias for GetKey.
func (*Envcfg) GetUint64 ¶
GetUint64 retrieves the value for key from the environment, or the supplied configuration data, returning it as a uint64. Uses base and bitSize to parse.
type Option ¶
type Option func(*Envcfg)
Option is an Envcfg option.
func CertPathKey ¶
CertPathKey is an option that sets the server certificate path key.
func ConfigFile ¶
ConfigFile is an option that sets the file path to read data from.