Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultHTTPClient(cfg *CommonDownstreamData) (*http.Client, error)
- func ExtractGrpcServerOptions(cfg *CommonServerConfig) ([]grpc.ServerOption, error)
- func GetTrustedCAs(cfg *TLSConfig) (*x509.CertPool, error)
- func MakeTLSConfig(cfg *TLSConfig) (*tls.Config, error)
- func OurIdentityCertificates(cfg *TLSConfig) ([]tls.Certificate, error)
- func ReadConfig(cfgFile string, defaultConfig *DefaultConfig, customConfig interface{}) error
- func TLSCiphers(cfg *TLSConfig) (ciphers []uint16, err error)
- func TLSClientAuth(cfg *TLSConfig) (*tls.ClientAuthType, error)
- func TLSVersions(cfg *TLSConfig) (min, max uint16, err error)
- type CertKeyPair
- type CommonDownstreamData
- type CommonHTTPServerConfig
- type CommonServerConfig
- type DefaultConfig
- type Dialer
- type GenCodeConfig
- type LibraryConfig
- type LogConfig
- type SecretKey
- type SecretKeyConfig
- type ServerIdentityConfig
- type SplunkConfig
- type TLSConfig
- type Transport
- type TrustedCertPoolConfig
- type UpstreamConfig
Constants ¶
View Source
const ( DIRMODE = "directory" FILEMODE = "file" SYSMODE = "system" )
Cert path modes
View Source
const (
PEM = "pem"
)
Cert encoding types
View Source
const (
SecretKeyEncodingBase64 = "base64"
)
Variables ¶
View Source
var CertPoolEncodingTypes = map[string]func(cfg *TrustedCertPoolConfig) (pool *x509.CertPool, err error){ PEM: buildPoolFromPEM, }
View Source
var SecretKeyReader = map[string]func(cfg *SecretKeyConfig) ([]byte, error){ SecretKeyEncodingBase64: readBase64Value, }
View Source
var SecretKeyValidators = map[string]func(cfg *SecretKeyConfig) error{ SecretKeyEncodingBase64: validateBase64Value, }
Functions ¶
func DefaultHTTPClient ¶
func DefaultHTTPClient(cfg *CommonDownstreamData) (*http.Client, error)
DefaultHTTPClient returns a new *http.Client with sensible defaults, in particular it has a timeout set!
func ExtractGrpcServerOptions ¶
func ExtractGrpcServerOptions(cfg *CommonServerConfig) ([]grpc.ServerOption, error)
func OurIdentityCertificates ¶
func OurIdentityCertificates(cfg *TLSConfig) ([]tls.Certificate, error)
func ReadConfig ¶
func ReadConfig(cfgFile string, defaultConfig *DefaultConfig, customConfig interface{}) error
ReadConfig reads from a single config file and populates both custom, library and genCode config structs cfgFile: path to config file config: a pointer to the custom config struct
func TLSCiphers ¶
func TLSClientAuth ¶
func TLSClientAuth(cfg *TLSConfig) (*tls.ClientAuthType, error)
func TLSVersions ¶
Types ¶
type CertKeyPair ¶
type CommonDownstreamData ¶
type CommonDownstreamData struct { ServiceURL string `yaml:"serviceURL"` ClientTransport Transport `yaml:"clientTransport"` ClientTimeout time.Duration `yaml:"clientTimeout" validate:"timeout=1ms:60s"` }
CommonDownstreamData collects all the client http configuration
func DefaultCommonDownstreamData ¶
func DefaultCommonDownstreamData() *CommonDownstreamData
func (*CommonDownstreamData) Validate ¶
func (g *CommonDownstreamData) Validate() error
type CommonHTTPServerConfig ¶
type CommonHTTPServerConfig struct { Common CommonServerConfig `yaml:"common"` BasePath string `yaml:"basePath" validate:"startswith=/"` ReadTimeout time.Duration `yaml:"readTimeout" validate:"nonnil"` WriteTimeout time.Duration `yaml:"writeTimeout" validate:"nonnil"` }
func (*CommonHTTPServerConfig) Validate ¶
func (c *CommonHTTPServerConfig) Validate() error
type CommonServerConfig ¶
type DefaultConfig ¶
type DefaultConfig struct { Library LibraryConfig `yaml:"library"` GenCode GenCodeConfig `yaml:"genCode"` }
type Dialer ¶
type Dialer struct { Timeout time.Duration `yaml:"timeout"` KeepAlive time.Duration `yaml:"keepAlive"` DualStack bool `yaml:"dualStack"` }
Dialer is part of the Transport struct
type GenCodeConfig ¶
type GenCodeConfig struct { Upstream UpstreamConfig `yaml:"upstream"` Downstream interface{} `yaml:"downstream"` }
GenCodeConfig struct
type LibraryConfig ¶
LibraryConfig struct
func (*LibraryConfig) Validate ¶
func (c *LibraryConfig) Validate() error
type LogConfig ¶
type LogConfig struct { Format string `yaml:"format" validate:"nonnil,oneof=color json text"` Splunk *SplunkConfig `yaml:"splunk"` Level logrus.Level `yaml:"level" validate:"nonnil"` ReportCaller bool `yaml:"caller" mapstructure:"caller"` }
LogConfig struct
type SecretKey ¶
type SecretKey struct {
common.SensitiveString
}
func MakeSecretKey ¶
func MakeSecretKey(cfg *SecretKeyConfig) (*SecretKey, error)
type SecretKeyConfig ¶
type SecretKeyConfig struct { Encoding *string `yaml:"encoding" json:"encoding"` Alias *string `yaml:"alias,omitempty" json:"alias,omitempty"` KeyStore *string `yaml:"keyStore,omitempty" json:"keyStore,omitempty"` KeyStorePassword *common.SensitiveString `yaml:"keyStorePassword,omitempty" json:"keyStorePassword,omitempty"` Value *common.SensitiveString `yaml:"value,omitempty" json:"value,omitempty"` }
func (*SecretKeyConfig) Validate ¶
func (s *SecretKeyConfig) Validate() error
type ServerIdentityConfig ¶
type ServerIdentityConfig struct {
CertKeyPair *CertKeyPair `yaml:"certKeyPair"`
}
type SplunkConfig ¶
type SplunkConfig struct { TokenBase64 common.SensitiveString `yaml:"tokenBase64" validate:"nonnil,base64"` Index string `yaml:"index" validate:"nonnil"` Target string `yaml:"target" validate:"nonnil,url"` Source string `yaml:"source" validate:"nonnil"` SourceType string `yaml:"sourceType" validate:"nonnil"` }
SplunkConfig struct
func (*SplunkConfig) Token ¶
func (s *SplunkConfig) Token() string
type TLSConfig ¶
type TLSConfig struct { MinVersion *string `yaml:"min"` MaxVersion *string `yaml:"max"` ClientAuth *string `yaml:"clientAuth"` Ciphers []string `yaml:"ciphers"` ServerIdentity *ServerIdentityConfig `yaml:"serverIdentity"` TrustedCertPool *TrustedCertPoolConfig `yaml:"trustedCertPool"` InsecureSkipVerify bool `yaml:"insecureSkipVerify"` }
type Transport ¶
type Transport struct { Dialer Dialer `yaml:"dialer"` MaxIdleConns int IdleConnTimeout time.Duration TLSHandshakeTimeout time.Duration ExpectContinueTimeout time.Duration ClientTLS *TLSConfig `yaml:"tls"` ProxyURL string `yaml:"proxyURL"` UseProxy bool `yaml:"useProxy"` }
Transport is used to initialise DefaultHTTPTransport
type TrustedCertPoolConfig ¶
type TrustedCertPoolConfig struct { Mode *string `yaml:"mode"` Encoding *string `yaml:"encoding"` Path *string `yaml:"path"` Password *common.SensitiveString `yaml:"password"` }
type UpstreamConfig ¶
type UpstreamConfig struct { ContextTimeout time.Duration `yaml:"contextTimeout" validate:"nonnil"` HTTP CommonHTTPServerConfig `yaml:"http"` GRPC CommonServerConfig `yaml:"grpc"` }
UpstreamConfig struct
Click to show internal directories.
Click to hide internal directories.