Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultGrpcDialOptions(cfg *CommonGRPCDownstreamData) ([]grpc.DialOption, error)
- func DefaultHTTPClient(cfg *CommonDownstreamData) (*http.Client, error)
- func ExtractGrpcServerOptions(cfg *CommonServerConfig) ([]grpc.ServerOption, error)
- func GetTrustedCAs(cfg *TLSConfig) (*x509.CertPool, error)
- func LoadConfig(file string, defaultConfig *DefaultConfig, customConfig interface{}) error
- func MakeTLSConfig(cfg *TLSConfig) (*tls.Config, error)
- func NewCallback(config *GenCodeConfig, downstreamTimeOut time.Duration, ...) common.Callback
- func NewCallbackV2(config *GenCodeConfig, downstreamTimeOut time.Duration, ...) common.Callback
- func OurIdentityCertificates(cfg *TLSConfig) ([]tls.Certificate, 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 AdminConfig
- type AuthenticationConfig
- type CertKeyPair
- type CommonDownstreamData
- type CommonGRPCDownstreamData
- type CommonHTTPServerConfig
- type CommonServerConfig
- type DefaultConfig
- type DevelopmentConfig
- type Dialer
- type GenCodeConfig
- type LibraryConfig
- type LogConfig
- type SecretKey
- type SecretKeyConfig
- type ServerIdentityConfig
- type TLSConfig
- type Transport
- type TrustedCertPoolConfig
- type UpstreamConfig
Constants ¶
const ( DIRMODE = "directory" FILEMODE = "file" SYSMODE = "system" )
Cert path modes.
const (
PEM = "pem"
)
Cert encoding types.
const (
SecretKeyEncodingBase64 = "base64"
)
Variables ¶
var CertPoolEncodingTypes = map[string]func(cfg *TrustedCertPoolConfig) (pool *x509.CertPool, err error){ PEM: buildPoolFromPEM, }
var SecretKeyReader = map[string]func(cfg *SecretKeyConfig) ([]byte, error){ SecretKeyEncodingBase64: readBase64Value, }
var SecretKeyValidators = map[string]func(cfg *SecretKeyConfig) error{ SecretKeyEncodingBase64: validateBase64Value, }
Functions ¶
func DefaultGrpcDialOptions ¶ added in v0.98.0
func DefaultGrpcDialOptions(cfg *CommonGRPCDownstreamData) ([]grpc.DialOption, error)
DefaultGRPDialOptions creates []grpc.DialOption from the given config. If cfg is nil then NewDefaultCommonGRPCDownstreamData will be used to define the dial options.
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 LoadConfig ¶ added in v0.13.0
func LoadConfig(file string, defaultConfig *DefaultConfig, customConfig interface{}) error
LoadConfig reads and validates a configuration loaded from file. file: the path to the yaml-encoded config file defaultConfig: a pointer to the default config struct to populate customConfig: a pointer to the custom config struct to populate.
func NewCallback ¶ added in v0.85.0
func NewCallback( config *GenCodeConfig, downstreamTimeOut time.Duration, mapError func(ctx context.Context, err error) *common.HTTPError, ) common.Callback
NewCallback is deprecated, prefer NewCallbackV2.
func NewCallbackV2 ¶ added in v0.152.0
func OurIdentityCertificates ¶
func OurIdentityCertificates(cfg *TLSConfig) ([]tls.Certificate, error)
func TLSCiphers ¶
func TLSClientAuth ¶
func TLSClientAuth(cfg *TLSConfig) (*tls.ClientAuthType, error)
func TLSVersions ¶
Types ¶
type AdminConfig ¶ added in v0.130.0
type AdminConfig struct { ContextTimeout time.Duration `yaml:"contextTimeout" mapstructure:"contextTimeout" validate:"nonnil"` HTTP CommonHTTPServerConfig `yaml:"http" mapstructure:"http"` }
type AuthenticationConfig ¶ added in v0.103.0
type AuthenticationConfig struct {
JWTAuth *jwtauth.Config `yaml:"jwtauth" mapstructure:"jwtauth"`
}
AuthenticationConfig struct.
type CertKeyPair ¶
type CommonDownstreamData ¶
type CommonDownstreamData struct { ServiceURL string `yaml:"serviceURL" mapstructure:"serviceURL"` ClientTransport Transport `yaml:"clientTransport" mapstructure:"clientTransport"` ClientTimeout time.Duration `yaml:"clientTimeout" mapstructure:"clientTimeout" validate:"timeout=1ms:60s"` Headers map[string][]string `yaml:"headers" mapstructure:"headers"` }
CommonDownstreamData collects all the client http configuration.
func DefaultCommonDownstreamData ¶
func DefaultCommonDownstreamData() *CommonDownstreamData
func (*CommonDownstreamData) Validate ¶
func (g *CommonDownstreamData) Validate() error
type CommonGRPCDownstreamData ¶ added in v0.56.0
type CommonGRPCDownstreamData struct { ServiceAddress string `yaml:"serviceAddress" mapstructure:"serviceAddress"` TLS *TLSConfig `yaml:"tls" mapstructure:"tls"` WithBlock bool `yaml:"withBlock" mapstructure:"withBlock"` }
CommonGRPCDownstreamData collects all the client gRPC configuration.
func NewDefaultCommonGRPCDownstreamData ¶ added in v0.56.0
func NewDefaultCommonGRPCDownstreamData() *CommonGRPCDownstreamData
type CommonHTTPServerConfig ¶
type CommonHTTPServerConfig struct { Common CommonServerConfig `yaml:"common" mapstructure:"common"` BasePath string `yaml:"basePath" mapstructure:"basePath" validate:"startswith=/"` ReadTimeout time.Duration `yaml:"readTimeout" mapstructure:"readTimeout" validate:"nonnil"` WriteTimeout time.Duration `yaml:"writeTimeout" mapstructure:"writeTimeout" validate:"nonnil"` }
func (*CommonHTTPServerConfig) Validate ¶
func (c *CommonHTTPServerConfig) Validate() error
type CommonServerConfig ¶
type DefaultConfig ¶
type DefaultConfig struct { Library LibraryConfig `yaml:"library" mapstructure:"library"` // config used for setting up the sysl-go admin server Admin *AdminConfig `yaml:"admin" mapstructure:"admin"` GenCode GenCodeConfig `yaml:"genCode" mapstructure:"genCode"` // development config can be used to set some config options only appropriate for dev/test environments. Development *DevelopmentConfig `yaml:"development" mapstructure:"development"` }
type DevelopmentConfig ¶ added in v0.103.0
type DevelopmentConfig struct { // disableAllAuthorizationRules can be used to disable all authorization rule logic // guarding calls to endpoints or RPC methods, and instead unconditionally grant access. // This option is insecure and should not be enabled in production. DisableAllAuthorizationRules bool `yaml:"disableAllAuthorizationRules" mapstructure:"disableAllAuthorizationRules"` }
DevelopmentConfig struct.
type Dialer ¶
type Dialer struct { Timeout time.Duration `yaml:"timeout" mapstructure:"timeout"` KeepAlive time.Duration `yaml:"keepAlive" mapstructure:"keepAlive"` DualStack bool `yaml:"dualStack" mapstructure:"dualStack"` }
Dialer is part of the Transport struct.
type GenCodeConfig ¶
type GenCodeConfig struct { Upstream UpstreamConfig `yaml:"upstream" mapstructure:"upstream"` Downstream interface{} `yaml:"downstream" mapstructure:"downstream"` }
GenCodeConfig struct.
type LibraryConfig ¶
type LibraryConfig struct { Log LogConfig `yaml:"log" mapstructure:"log"` Profiling bool `yaml:"profiling" mapstructure:"profiling"` Health bool `yaml:"health" mapstructure:"health"` Authentication *AuthenticationConfig `yaml:"authentication" mapstructure:"authentication"` }
LibraryConfig struct.
func (*LibraryConfig) Validate ¶
func (c *LibraryConfig) Validate() error
type LogConfig ¶
type LogConfig struct { Format string `yaml:"format" mapstructure:"format" validate:"nonnil,oneof=color json text"` Level logrus.Level `yaml:"level" mapstructure:"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" mapstructure:"encoding" json:"encoding"` Alias *string `yaml:"alias,omitempty" mapstructure:"alias,omitempty" json:"alias,omitempty"` KeyStore *string `yaml:"keyStore,omitempty" mapstructure:"keyStore,omitempty" json:"keyStore,omitempty"` KeyStorePassword *common.SensitiveString `yaml:"keyStorePassword,omitempty" mapstructure:"keyStorePassword,omitempty" json:"keyStorePassword,omitempty"` Value *common.SensitiveString `yaml:"value,omitempty" mapstructure:"value,omitempty" json:"value,omitempty"` }
func (*SecretKeyConfig) Validate ¶
func (s *SecretKeyConfig) Validate() error
type ServerIdentityConfig ¶
type ServerIdentityConfig struct {
CertKeyPair *CertKeyPair `yaml:"certKeyPair" mapstructure:"certKeyPair"`
}
type TLSConfig ¶
type TLSConfig struct { MinVersion *string `yaml:"min" mapstructure:"min"` MaxVersion *string `yaml:"max" mapstructure:"max"` ClientAuth *string `yaml:"clientAuth" mapstructure:"clientAuth"` Ciphers []string `yaml:"ciphers" mapstructure:"ciphers"` ServerIdentity *ServerIdentityConfig `yaml:"serverIdentity" mapstructure:"serverIdentity"` TrustedCertPool *TrustedCertPoolConfig `yaml:"trustedCertPool" mapstructure:"trustedCertPool"` InsecureSkipVerify bool `yaml:"insecureSkipVerify" mapstructure:"insecureSkipVerify"` SelfSigned bool `yaml:"selfSigned" mapstructure:"selfSigned"` }
type Transport ¶
type Transport struct { Dialer Dialer `yaml:"dialer" mapstructure:"dialer"` MaxIdleConns int `yaml:"maxIdleConns" mapstructure:"maxIdleConns"` IdleConnTimeout time.Duration `yaml:"idleConnTimeout" mapstructure:"idleConnTimeout"` TLSHandshakeTimeout time.Duration `yaml:"tLSHandshakeTimeout" mapstructure:"tLSHandshakeTimeout"` ExpectContinueTimeout time.Duration `yaml:"expectContinueTimeout" mapstructure:"expectContinueTimeout"` ClientTLS *TLSConfig `yaml:"tls" mapstructure:"tls"` ProxyURL string `yaml:"proxyURL" mapstructure:"proxyURL"` UseProxy bool `yaml:"useProxy" mapstructure:"useProxy"` }
Transport is used to initialise DefaultHTTPTransport.
type TrustedCertPoolConfig ¶
type TrustedCertPoolConfig struct { Mode *string `yaml:"mode" mapstructure:"mode"` Encoding *string `yaml:"encoding" mapstructure:"encoding"` Path *string `yaml:"path" mapstructure:"path"` Password *common.SensitiveString `yaml:"password" mapstructure:"password"` }
type UpstreamConfig ¶
type UpstreamConfig struct { ContextTimeout time.Duration `yaml:"contextTimeout" mapstructure:"contextTimeout" validate:"nonnil"` HTTP CommonHTTPServerConfig `yaml:"http" mapstructure:"http"` GRPC CommonServerConfig `yaml:"grpc" mapstructure:"grpc"` }
UpstreamConfig struct.
func (*UpstreamConfig) Validate ¶ added in v0.85.0
func (c *UpstreamConfig) Validate() error