Documentation ¶
Index ¶
Constants ¶
const ( KiB = 1 << (10 * iota) MiB GiB TiB )
Define unit constant.
Variables ¶
This section is empty.
Functions ¶
func CreateListener ¶
CreateListener create net listener by given address and returns it and port.
func ValidateAddress ¶
ValidateAddress takes an address as a string and validates it. If the input address is not in a valid :port or IP:port format, it returns an error. It also checks if the host part of the address is a valid IP address and if the port number is valid.
Types ¶
type HTTPOptions ¶
type HTTPOptions struct { // Network with server network. Network string `json:"network" mapstructure:"network"` // Address with server address. Addr string `json:"addr" mapstructure:"addr"` // Timeout with server timeout. Used by http client side. Timeout time.Duration `json:"timeout" mapstructure:"timeout"` }
HTTPOptions contains configuration items related to HTTP server startup.
func NewHTTPOptions ¶
func NewHTTPOptions() *HTTPOptions
NewHTTPOptions creates a HTTPOptions object with default parameters.
func (*HTTPOptions) AddFlags ¶
func (o *HTTPOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to HTTPS server for a specific APIServer to the specified FlagSet.
func (*HTTPOptions) Complete ¶
func (s *HTTPOptions) Complete() error
Complete fills in any fields not set that are required to have valid data.
func (*HTTPOptions) Validate ¶
func (o *HTTPOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type HealthOptions ¶
type HealthOptions struct { // Enable debugging by exposing profiling information. HTTPProfile bool `json:"enable-http-profiler" mapstructure:"enable-http-profiler"` HealthCheckPath string `json:"check-path" mapstructure:"check-path"` HealthCheckAddress string `json:"check-address" mapstructure:"check-address"` }
HealthOptions defines options for redis cluster.
func NewHealthOptions ¶
func NewHealthOptions() *HealthOptions
NewHealthOptions create a `zero` value instance.
func (*HealthOptions) AddFlags ¶
func (o *HealthOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*HealthOptions) ServeHealthCheck ¶
func (o *HealthOptions) ServeHealthCheck()
func (*HealthOptions) Validate ¶
func (o *HealthOptions) Validate() []error
Validate verifies flags passed to HealthOptions.
type IOptions ¶
type IOptions interface { // Validate validates all the required options. It can also used to complete options if needed. Validate() []error // AddFlags adds flags related to given flagset. AddFlags(fs *pflag.FlagSet, prefixes ...string) }
IOptions defines methods to implement a generic options.
type JWTOptions ¶
type JWTOptions struct { Key string `json:"key" mapstructure:"key"` Expired time.Duration `json:"expired" mapstructure:"expired"` MaxRefresh time.Duration `json:"max-refresh" mapstructure:"max-refresh"` SigningMethod string `json:"signing-method" mapstructure:"signing-method"` }
JWTOptions contains configuration items related to API server features.
func NewJWTOptions ¶
func NewJWTOptions() *JWTOptions
NewJWTOptions creates a JWTOptions object with default parameters.
func (*JWTOptions) AddFlags ¶
func (s *JWTOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to features for a specific api server to the specified FlagSet.
func (*JWTOptions) Validate ¶
func (s *JWTOptions) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type LogsOptions ¶
type LogsOptions struct { // Format Flag specifies the structure of log messages. // default value of format is `text` Format string `json:"format,omitempty" mapstructure:"format"` // Maximum number of nanoseconds (i.e. 1s = 1000000000) between log // flushes. Ignored if the selected logging backend writes log // messages without buffering. FlushFrequency time.Duration `json:"flush-frequency" mapstructure:"flush-frequency"` // Verbosity is the threshold that determines which log messages are // logged. Default is zero which logs only the most important // messages. Higher values enable additional messages. Error messages // are always logged. Verbosity logsapi.VerbosityLevel `json:"verbosity" mapstructure:"verbosity"` // VModule overrides the verbosity threshold for individual files. // Only supported for "text" log format. VModule logsapi.VModuleConfiguration `json:"vmodule,omitempty" mapstructure:"vmodule"` // [Alpha] Options holds additional parameters that are specific // to the different logging formats. Only the options for the selected // format get used, but all of them get validated. // Only available when the LoggingAlphaOptions feature gate is enabled. Options logsapi.FormatOptions `json:"-,omitempty" mapstructure:"-"` }
LogsOptions contains configuration items related to log.
func NewLogsOptions ¶
func NewLogsOptions() *LogsOptions
NewLogsOptions creates an Options object with default parameters.
func (*LogsOptions) AddFlags ¶
func (o *LogsOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds command line flags for the configuration.
func (*LogsOptions) Native ¶
func (o *LogsOptions) Native() *logsapi.LoggingConfiguration
func (*LogsOptions) Validate ¶
func (o *LogsOptions) Validate() []error
Validate verifies flags passed to LogsOptions.
type MySQLOptions ¶
type MySQLOptions struct { Host string `json:"host,omitempty" mapstructure:"host"` Username string `json:"username,omitempty" mapstructure:"username"` Password string `json:"-" mapstructure:"password"` Database string `json:"database" mapstructure:"database"` MaxIdleConnections int `json:"max-idle-connections,omitempty" mapstructure:"max-idle-connections,omitempty"` MaxOpenConnections int `json:"max-open-connections,omitempty" mapstructure:"max-open-connections"` MaxConnectionLifeTime time.Duration `json:"max-connection-life-time,omitempty" mapstructure:"max-connection-life-time"` LogLevel int `json:"log-level" mapstructure:"log-level"` }
MySQLOptions defines options for mysql database.
func NewMySQLOptions ¶
func NewMySQLOptions() *MySQLOptions
NewMySQLOptions create a `zero` value instance.
func (*MySQLOptions) AddFlags ¶
func (o *MySQLOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.
func (*MySQLOptions) NewDB ¶
func (o *MySQLOptions) NewDB() (*gorm.DB, error)
NewDB create mysql store with the given config.
func (*MySQLOptions) Validate ¶
func (o *MySQLOptions) Validate() []error
Validate verifies flags passed to MySQLOptions.
type RedisOptions ¶
type RedisOptions struct { Addr string `json:"addr" mapstructure:"addr"` Username string `json:"username" mapstructure:"username"` Password string `json:"password" mapstructure:"password"` Database int `json:"database" mapstructure:"database"` MaxRetries int `json:"max-retries" mapstructure:"max-retries"` MinIdleConns int `json:"min-idle-conns" mapstructure:"min-idle-conns"` DialTimeout time.Duration `json:"dial-timeout" mapstructure:"dial-timeout"` ReadTimeout time.Duration `json:"read-timeout" mapstructure:"read-timeout"` WriteTimeout time.Duration `json:"write-timeout" mapstructure:"write-timeout"` PoolTimeout time.Duration `json:"pool-time" mapstructure:"pool-time"` PoolSize int `json:"pool-size" mapstructure:"pool-size"` // tracing switch EnableTrace bool `json:"enable-trace" mapstructure:"enable-trace"` }
RedisOptions defines options for redis cluster.
func NewRedisOptions ¶
func NewRedisOptions() *RedisOptions
NewRedisOptions create a `zero` value instance.
func (*RedisOptions) AddFlags ¶
func (o *RedisOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*RedisOptions) NewClient ¶
func (o *RedisOptions) NewClient() (*redis.Client, error)
func (*RedisOptions) Validate ¶
func (o *RedisOptions) Validate() []error
Validate verifies flags passed to RedisOptions.
type TLSOptions ¶
type TLSOptions struct { // UseTLS specifies whether should be encrypted with TLS if possible. UseTLS bool `json:"use-tls" mapstructure:"use-tls"` InsecureSkipVerify bool `json:"insecure-skip-verify" mapstructure:"insecure-skip-verify"` CaCert string `json:"ca-cert" mapstructure:"ca-cert"` Cert string `json:"cert" mapstructure:"cert"` Key string `json:"key" mapstructure:"key"` }
TLSOptions is the TLS cert info for serving secure traffic.
func (*TLSOptions) AddFlags ¶
func (o *TLSOptions) AddFlags(fs *pflag.FlagSet, prefixes ...string)
AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.
func (*TLSOptions) MustTLSConfig ¶
func (o *TLSOptions) MustTLSConfig() *tls.Config
func (*TLSOptions) Validate ¶
func (o *TLSOptions) Validate() []error
Validate verifies flags passed to TLSOptions.