Documentation
¶
Overview ¶
Package config allows for an external config file to be read that allows for value to be overriden based on a hostname derived configuration set.
the Configuration type defines all the configurable parameters. the config file is json, its consists of 3 sections
defaults : a Configuration instance that is the base/default configurations hosts : a mapping from host name to a named configuration [e.g. node1 : "aws"] overrrides : a set of named Configuration instances that can override the some or all of the default config values
the caller can provide a specific hostname if it chooses, otherwise the config will
a) look for a named environemnt variable, if set to something, that is used b) look at the OS supplied hostname
*** THIS IS GENERATED CODE: DO NOT EDIT ***
Index ¶
- Constants
- func GetConfigAbsFilename(file, projFolder string) (string, error)
- type Authz
- func (c *Authz) GetAPIKeyMapper() string
- func (c *Authz) GetAllow() []string
- func (c *Authz) GetAllowAny() []string
- func (c *Authz) GetAllowAnyRole() []string
- func (c *Authz) GetCertMapper() string
- func (c *Authz) GetJWTMapper() string
- func (c *Authz) GetLogAllowed() bool
- func (c *Authz) GetLogDenied() bool
- type AuthzConfig
- type CORS
- func (c *CORS) GetAllowCredentials() bool
- func (c *CORS) GetAllowedHeaders() []string
- func (c *CORS) GetAllowedMethods() []string
- func (c *CORS) GetAllowedOrigins() []string
- func (c *CORS) GetDebug() bool
- func (c *CORS) GetEnabled() bool
- func (c *CORS) GetExposedHeaders() []string
- func (c *CORS) GetMaxAge() int
- func (c *CORS) GetOptionsPassthrough() bool
- type CORSConfig
- type Configuration
- type Configurations
- type CryptoProv
- type Duration
- type Factory
- type HTTPServer
- func (c *HTTPServer) GetAllowProfiling() bool
- func (c *HTTPServer) GetBindAddr() string
- func (c *HTTPServer) GetCORSCfg() *CORS
- func (c *HTTPServer) GetDisabled() bool
- func (c *HTTPServer) GetHeartbeatSecs() int
- func (c *HTTPServer) GetPackageLogger() string
- func (c *HTTPServer) GetProfilerDir() string
- func (c *HTTPServer) GetServerTLSCfg() *TLSInfo
- func (c *HTTPServer) GetServiceName() string
- func (c *HTTPServer) GetServices() []string
- func (c *HTTPServer) GetVIPName() string
- type HTTPServerConfig
- type HostSelection
- type Logger
- type LoggerConfig
- type Metrics
- type RepoLogLevel
- type TLSInfo
- type TLSInfoConfig
Constants ¶
const (
// ConfigFileName is default name for the configuration file
ConfigFileName = "demo-config.json"
)
Variables ¶
This section is empty.
Functions ¶
func GetConfigAbsFilename ¶
GetConfigAbsFilename returns absolute path for the configuration file from the relative path to projFolder
Types ¶
type Authz ¶
type Authz struct { // Allow will allow the specified roles access to this path and its children, in format: ${path}:${role},${role}. Allow []string // AllowAny will allow any authenticated request access to this path and its children. AllowAny []string // AllowAnyRole will allow any authenticated request that include a non empty role. AllowAnyRole []string // LogAllowed specifies to log allowed access. LogAllowed *bool // LogDenied specifies to log denied access. LogDenied *bool // CertMapper specifies location of the config file for certificate based identity. CertMapper string // APIKeyMapper specifies location of the config file for API-Key based identity. APIKeyMapper string // JWTMapper specifies location of the config file for JWT based identity. JWTMapper string }
Authz contains configuration for the authorization module.
func (*Authz) GetAPIKeyMapper ¶
GetAPIKeyMapper specifies location of the config file for API-Key based identity.
func (*Authz) GetAllow ¶
GetAllow will allow the specified roles access to this path and its children, in format: ${path}:${role},${role}.
func (*Authz) GetAllowAny ¶
GetAllowAny will allow any authenticated request access to this path and its children.
func (*Authz) GetAllowAnyRole ¶
GetAllowAnyRole will allow any authenticated request that include a non empty role.
func (*Authz) GetCertMapper ¶
GetCertMapper specifies location of the config file for certificate based identity.
func (*Authz) GetJWTMapper ¶
GetJWTMapper specifies location of the config file for JWT based identity.
func (*Authz) GetLogAllowed ¶
GetLogAllowed specifies to log allowed access.
func (*Authz) GetLogDenied ¶
GetLogDenied specifies to log denied access.
type AuthzConfig ¶
type AuthzConfig interface { // Allow will allow the specified roles access to this path and its children, in format: ${path}:${role},${role}. GetAllow() []string // AllowAny will allow any authenticated request access to this path and its children. GetAllowAny() []string // AllowAnyRole will allow any authenticated request that include a non empty role. GetAllowAnyRole() []string // LogAllowed specifies to log allowed access. GetLogAllowed() bool // LogDenied specifies to log denied access. GetLogDenied() bool // CertMapper specifies location of the config file for certificate based identity. GetCertMapper() string // APIKeyMapper specifies location of the config file for API-Key based identity. GetAPIKeyMapper() string // JWTMapper specifies location of the config file for JWT based identity. GetJWTMapper() string }
AuthzConfig contains configuration for the authorization module.
type CORS ¶
type CORS struct { // Enabled specifies if the CORS is enabled. Enabled *bool // MaxAge indicates how long (in seconds) the results of a preflight request can be cached. MaxAge int // AllowedOrigins is a list of origins a cross-domain request can be executed from. AllowedOrigins []string // AllowedMethods is a list of methods the client is allowed to use with cross-domain requests. AllowedMethods []string // AllowedHeaders is list of non simple headers the client is allowed to use with cross-domain requests. AllowedHeaders []string // ExposedHeaders indicates which headers are safe to expose to the API of a CORS API specification. ExposedHeaders []string // AllowCredentials indicates whether the request can include user credentials. AllowCredentials *bool // OptionsPassthrough instructs preflight to let other potential next handlers to process the OPTIONS method. OptionsPassthrough *bool // Debug flag adds additional output to debug server side CORS issues. Debug *bool }
CORS contains configuration for CORS.
func (*CORS) GetAllowCredentials ¶
GetAllowCredentials indicates whether the request can include user credentials.
func (*CORS) GetAllowedHeaders ¶
GetAllowedHeaders is list of non simple headers the client is allowed to use with cross-domain requests.
func (*CORS) GetAllowedMethods ¶
GetAllowedMethods is a list of methods the client is allowed to use with cross-domain requests.
func (*CORS) GetAllowedOrigins ¶
GetAllowedOrigins is a list of origins a cross-domain request can be executed from.
func (*CORS) GetEnabled ¶
GetEnabled specifies if the CORS is enabled.
func (*CORS) GetExposedHeaders ¶
GetExposedHeaders indicates which headers are safe to expose to the API of a CORS API specification.
func (*CORS) GetMaxAge ¶
GetMaxAge indicates how long (in seconds) the results of a preflight request can be cached.
func (*CORS) GetOptionsPassthrough ¶
GetOptionsPassthrough instructs preflight to let other potential next handlers to process the OPTIONS method.
type CORSConfig ¶
type CORSConfig interface { // Enabled specifies if the CORS is enabled. GetEnabled() bool // MaxAge indicates how long (in seconds) the results of a preflight request can be cached. GetMaxAge() int // AllowedOrigins is a list of origins a cross-domain request can be executed from. GetAllowedOrigins() []string // AllowedMethods is a list of methods the client is allowed to use with cross-domain requests. GetAllowedMethods() []string // AllowedHeaders is list of non simple headers the client is allowed to use with cross-domain requests. GetAllowedHeaders() []string // ExposedHeaders indicates which headers are safe to expose to the API of a CORS API specification. GetExposedHeaders() []string // AllowCredentials indicates whether the request can include user credentials. GetAllowCredentials() bool // OptionsPassthrough instructs preflight to let other potential next handlers to process the OPTIONS method. GetOptionsPassthrough() bool // Debug flag adds additional output to debug server side CORS issues. GetDebug() bool }
CORSConfig contains configuration for CORSConfig.
type Configuration ¶
type Configuration struct { // Datacenter specifies the Datacenter where the instance is running. Datacenter string // Environment specifies the deployment environment. Environment string // ServiceName specifies the service name to be used in logs and folders names. ServiceName string // HTTP contains the config for the Public HTTP. HTTP HTTPServer // HTTPS contains the config for the HTTPS/JSON API Service. HTTPS HTTPServer // Authz contains configuration for the API authorization layer. Authz Authz // Audit contains configuration for the audit logger. Audit Logger // CryptoProv specifies the configuration for crypto providers. CryptoProv CryptoProv // Metrics specifies the metrics pipeline configuration. Metrics Metrics // Logger contains configuration for the logger. Logger Logger // LogLevels specifies the log levels per package. LogLevels []RepoLogLevel // RootCA specifies the location of PEM-encoded certificate. RootCA string }
Configuration contains the configuration for the server.
func Load ¶
func Load(configFilename, envKeyName, hostnameOverride string) (*Configuration, error)
Load will attempt to load the configuration from the supplied filename. Overrides defined in the config file will be applied based on the hostname the hostname used is dervied from [in order]
- the hostnameOverride parameter if not ""
- the value of the Environment variable in envKeyName, if not ""
- the OS supplied hostname
func LoadConfig ¶
func LoadConfig(configFile string) (*Configuration, string, error)
LoadConfig will load the server configuration from the named config file, apply any overrides, and resolve relative directory locations.
type Configurations ¶
type Configurations struct { // Default contains the base configuration, this applies unless it override by a specifc named config Defaults Configuration // a map of hostname to named configuration Hosts map[string]string // a map of named configuration overrides Overrides map[string]Configuration }
Configurations is the entire set of configurations, these consist of
a base/default configuration a set of hostname -> named overrides named overrides -> config overrides
func LoadConfigurations ¶
func LoadConfigurations(filename string) (*Configurations, error)
LoadConfigurations decodes the json config file, or returns an error typically you'd just use Load, but this can be useful if you need to do more intricate examination of the entire set of configurations
func (*Configurations) For ¶
func (configs *Configurations) For(envKeyName, hostnameOverride string) (*Configuration, error)
For returns the Configuration for the indicated host, with all the overrides applied. the hostname used is dervied from [in order]
- the hostnameOverride parameter if not ""
- the value of the Environemnt variable in envKeyName, if not ""
- the OS supplied hostname
func (*Configurations) Selection ¶
func (configs *Configurations) Selection(envKeyName, hostnameOverride string) (HostSelection, error)
Selection returns the final resolved hostname, and if applicable, override section name for the supplied host specifiers
type CryptoProv ¶
type CryptoProv struct { // Default specifies the location of the configuration file for default provider. Default string // Providers specifies the list of locations of the configuration files. Providers []string }
CryptoProv specifies the configuration for crypto providers.
type Duration ¶
Duration represents a period of time, its the same as time.Duration but supports better marshalling from json
func (Duration) MarshalJSON ¶
MarshalJSON encodes our custom Duration value as a quoted version of its underlying value's String() output this means you get a duration with a trailing units indicator, e.g. "10m0s"
func (Duration) String ¶
String returns a string formatted version of the duration in a valueUnits format, e.g. 5m0s for 5 minutes
func (Duration) TimeDuration ¶
TimeDuration returns this duration in a time.Duration type
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON handles decoding our custom json serialization for Durations json values that are numbers are treated as seconds json values that are strings, can use the standard time.Duration units indicators e.g. this can decode val:100 as well as val:"10m"
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is used to create Configuration instance
func DefaultFactory ¶
DefaultFactory returns default configuration factory
func NewFactory ¶
NewFactory returns new configuration factory
func (*Factory) LoadConfig ¶
func (f *Factory) LoadConfig(configFile string) (*Configuration, string, error)
LoadConfig will load the server configuration from the named config file, apply any overrides, and resolve relative directory locations.
func (*Factory) LoadConfigForHostName ¶
func (f *Factory) LoadConfigForHostName(configFile, hostnameOverride string) (*Configuration, string, error)
LoadConfigForHostName will load the server configuration from the named config file for specified host name, apply any overrides, and resolve relative directory locations.
type HTTPServer ¶
type HTTPServer struct { // ServiceName specifies name of the service: HTTP|HTTPS|WebAPI. ServiceName string // Disabled specifies if the service is disabled. Disabled *bool // VIPName is the FQ name of the VIP to the cluster [this is used when building the cert requests]. VIPName string // BindAddr is the address that the HTTPS service should be exposed on BindAddr string // ServerTLS provides TLS config for server. ServerTLS TLSInfo // PackageLogger if set, specifies name of the package logger. PackageLogger string // AllowProfiling if set, will allow for per request CPU/Memory profiling triggered by the URI QueryString. AllowProfiling *bool // ProfilerDir specifies the directories where per-request profile information is written, if not set will write to a TMP dir. ProfilerDir string // Services is a list of services to enable for this HTTP Service. Services []string // HeartbeatSecs specifies heartbeat interval in seconds [30 secs is a minimum]. HeartbeatSecs int // CORS contains configuration for CORS. CORS CORS }
HTTPServer contains the configuration of the HTTPS API Service.
func (*HTTPServer) GetAllowProfiling ¶
func (c *HTTPServer) GetAllowProfiling() bool
GetAllowProfiling if set, will allow for per request CPU/Memory profiling triggered by the URI QueryString.
func (*HTTPServer) GetBindAddr ¶
func (c *HTTPServer) GetBindAddr() string
GetBindAddr is the address that the HTTPS service should be exposed on
func (*HTTPServer) GetCORSCfg ¶
func (c *HTTPServer) GetCORSCfg() *CORS
GetCORSCfg contains configuration for GetCORSCfg.
func (*HTTPServer) GetDisabled ¶
func (c *HTTPServer) GetDisabled() bool
GetDisabled specifies if the service is disabled.
func (*HTTPServer) GetHeartbeatSecs ¶
func (c *HTTPServer) GetHeartbeatSecs() int
GetHeartbeatSecs specifies heartbeat interval in seconds [30 secs is a minimum].
func (*HTTPServer) GetPackageLogger ¶
func (c *HTTPServer) GetPackageLogger() string
GetPackageLogger if set, specifies name of the package logger.
func (*HTTPServer) GetProfilerDir ¶
func (c *HTTPServer) GetProfilerDir() string
GetProfilerDir specifies the directories where per-request profile information is written, if not set will write to a TMP dir.
func (*HTTPServer) GetServerTLSCfg ¶
func (c *HTTPServer) GetServerTLSCfg() *TLSInfo
GetServerTLSCfg provides TLS config for server.
func (*HTTPServer) GetServiceName ¶
func (c *HTTPServer) GetServiceName() string
GetServiceName specifies name of the service: HTTP|HTTPS|WebAPI.
func (*HTTPServer) GetServices ¶
func (c *HTTPServer) GetServices() []string
GetServices is a list of services to enable for this HTTP Service.
func (*HTTPServer) GetVIPName ¶
func (c *HTTPServer) GetVIPName() string
GetVIPName is the FQ name of the VIP to the cluster [this is used when building the cert requests].
type HTTPServerConfig ¶
type HTTPServerConfig interface { // ServiceName specifies name of the service: HTTP|HTTPS|WebAPI. GetServiceName() string // Disabled specifies if the service is disabled. GetDisabled() bool // VIPName is the FQ name of the VIP to the cluster [this is used when building the cert requests]. GetVIPName() string // BindAddr is the address that the HTTPS service should be exposed on GetBindAddr() string // ServerTLS provides TLS config for server. GetServerTLSCfg() *TLSInfo // PackageLogger if set, specifies name of the package logger. GetPackageLogger() string // AllowProfiling if set, will allow for per request CPU/Memory profiling triggered by the URI QueryString. GetAllowProfiling() bool // ProfilerDir specifies the directories where per-request profile information is written, if not set will write to a TMP dir. GetProfilerDir() string // Services is a list of services to enable for this HTTP Service. GetServices() []string // HeartbeatSecs specifies heartbeat GetHeartbeatSecserval in seconds [30 secs is a minimum]. GetHeartbeatSecs() int // GetCORSCfg contains configuration for GetCORSCfg. GetCORSCfg() *CORS }
HTTPServerConfig contains the configuration of the HTTPS API Service.
type HostSelection ¶
type HostSelection struct { // Hostname returns the hostname from the configuration that was used // this may return a fully qualified hostname, when just a name was specified Hostname string // Override contains the name of the override section, if there was one found // [based on the Hostname] Override string }
HostSelection describes the hostname & override set that were used
type Logger ¶
type Logger struct { // Directory contains where to store the log files. Directory string // MaxAgeDays controls how old files are before deletion. MaxAgeDays int // MaxSizeMb contols how large a single log file can be before its rotated. MaxSizeMb int }
Logger contains information about the configuration of a logger/log rotation.
func (*Logger) GetDirectory ¶
GetDirectory contains where to store the log files.
func (*Logger) GetMaxAgeDays ¶
GetMaxAgeDays controls how old files are before deletion.
func (*Logger) GetMaxSizeMb ¶
GetMaxSizeMb contols how large a single log file can be before its rotated.
type LoggerConfig ¶
type LoggerConfig interface { // Directory contains where to store the log files. GetDirectory() string // MaxAgeDays controls how old files are before deletion. GetMaxAgeDays() int // MaxSizeMb contols how large a single log file can be before its rotated. GetMaxSizeMb() int }
LoggerConfig contains information about the configuration of a logger/log rotation.
type Metrics ¶
type Metrics struct { // Provider specifies the metrics provider. Provider string }
Metrics specifies the metrics pipeline configuration.
type RepoLogLevel ¶
type RepoLogLevel struct { // Repo specifies the repo name, or '*' for all repos [Global]. Repo string // Package specifies the package name. Package string // Level specifies the log level for the repo [ERROR,WARNING,NOTICE,INFO,DEBUG,TRACE]. Level string }
RepoLogLevel contains information about the log level per repo. Use * to set up global level.
type TLSInfo ¶
type TLSInfo struct { // CertFile specifies location of the cert. CertFile string // KeyFile specifies location of the key. KeyFile string // TrustedCAFile specifies location of the trusted Root file. TrustedCAFile string // ClientCertAuth controls client auth: NoClientCert|RequestClientCert|RequireAnyClientCert|VerifyClientCertIfGiven|RequireAndVerifyClientCert ClientCertAuth string }
TLSInfo contains configuration info for the TLS.
func (*TLSInfo) GetCertFile ¶
GetCertFile specifies location of the cert.
func (*TLSInfo) GetClientCertAuth ¶
GetClientCertAuth controls client auth: NoClientCert|RequestClientCert|RequireAnyClientCert|VerifyClientCertIfGiven|RequireAndVerifyClientCert
func (*TLSInfo) GetKeyFile ¶
GetKeyFile specifies location of the key.
func (*TLSInfo) GetTrustedCAFile ¶
GetTrustedCAFile specifies location of the trusted Root file.
type TLSInfoConfig ¶
type TLSInfoConfig interface { // CertFile specifies location of the cert. GetCertFile() string // KeyFile specifies location of the key. GetKeyFile() string // TrustedCAFile specifies location of the trusted Root file. GetTrustedCAFile() string // ClientCertAuth controls client auth: NoClientCert|RequestClientCert|RequireAnyClientCert|VerifyClientCertIfGiven|RequireAndVerifyClientCert GetClientCertAuth() string }
TLSInfoConfig contains configuration info for the TLS.