config

package
v0.92.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 23 Imported by: 4

Documentation

Index

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 DefaultGRPCClient added in v0.56.0

func DefaultGRPCClient(cfg *CommonGRPCDownstreamData) (*grpc.ClientConn, error)

DefaultGRPCClient returns a new *grpc.ClientConn with sensible defaults, in particular it has a timeout set!

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 GetTrustedCAs

func GetTrustedCAs(cfg *TLSConfig) (*x509.CertPool, 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 MakeTLSConfig

func MakeTLSConfig(cfg *TLSConfig) (*tls.Config, error)

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

func OurIdentityCertificates

func OurIdentityCertificates(cfg *TLSConfig) ([]tls.Certificate, error)

func TLSCiphers

func TLSCiphers(cfg *TLSConfig) (ciphers []uint16, err error)

func TLSClientAuth

func TLSClientAuth(cfg *TLSConfig) (*tls.ClientAuthType, error)

func TLSVersions

func TLSVersions(cfg *TLSConfig) (min, max uint16, err error)

Types

type CertKeyPair

type CertKeyPair struct {
	CertPath *string `yaml:"certPath"`
	KeyPath  *string `yaml:"keyPath"`
}

type CommonDownstreamData

type CommonDownstreamData struct {
	ServiceURL      string              `yaml:"serviceURL"`
	ClientTransport Transport           `yaml:"clientTransport"`
	ClientTimeout   time.Duration       `yaml:"clientTimeout" validate:"timeout=1ms:60s"`
	Headers         map[string][]string `yaml:"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"`
	TLS            *TLSConfig `yaml:"tls"`
	WithBlock      bool       `yaml:"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"`
	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 CommonServerConfig struct {
	HostName string     `yaml:"hostName"`
	Port     int        `yaml:"port" validate:"min=0,max=65534"`
	TLS      *TLSConfig `yaml:"tls"`
}

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

type LibraryConfig struct {
	Log       LogConfig `yaml:"log"`
	Profiling bool      `yaml:"profiling"`
}

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"`
	SelfSigned         bool                   `yaml:"selfSigned"`
}

func (*TLSConfig) Validate

func (t *TLSConfig) Validate() error

type Transport

type Transport struct {
	Dialer                Dialer        `yaml:"dialer"`
	MaxIdleConns          int           `yaml:"maxIdleConns"`
	IdleConnTimeout       time.Duration `yaml:"idleConnTimeout"`
	TLSHandshakeTimeout   time.Duration `yaml:"tLSHandshakeTimeout"`
	ExpectContinueTimeout time.Duration `yaml:"expectContinueTimeout"`
	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.

func (*UpstreamConfig) Validate added in v0.85.0

func (c *UpstreamConfig) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL