options

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 14 Imported by: 0

Documentation

Overview

Package options is the public flags and options used by a generic api server. It takes a minimal set of dependencies and does not reference implementations, in order to ensure it may be reused by multiple components (such as CLI commands that wish to generate or validate config).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateListener

func CreateListener(addr string) (net.Listener, int, error)

CreateListener create net listener by given address and returns it and port.

Types

type CertKey

type CertKey struct {
	// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
	CertFile string `json:"cert-file"        mapstructure:"cert-file"`
	// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
	KeyFile string `json:"private-key-file" mapstructure:"private-key-file"`
}

CertKey contains configuration items related to certificate.

type ClientCertAuthenticationOptions

type ClientCertAuthenticationOptions struct {
	// ClientCA is the certificate bundle for all the signers that you'll recognize for incoming client certificates
	ClientCA string `json:"client-ca-file" mapstructure:"client-ca-file"`
}

ClientCertAuthenticationOptions provides different options for client cert auth.

func NewClientCertAuthenticationOptions

func NewClientCertAuthenticationOptions() *ClientCertAuthenticationOptions

NewClientCertAuthenticationOptions creates a ClientCertAuthenticationOptions object with default parameters.

func (*ClientCertAuthenticationOptions) AddFlags

AddFlags adds flags related to ClientCertAuthenticationOptions for a specific server to the specified FlagSet.

func (*ClientCertAuthenticationOptions) Validate

func (o *ClientCertAuthenticationOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type EtcdOptions

type EtcdOptions struct {
	Endpoints            []string `json:"endpoints"               mapstructure:"endpoints"`
	Timeout              int      `json:"timeout"                 mapstructure:"timeout"`
	RequestTimeout       int      `json:"request-timeout"         mapstructure:"request-timeout"`
	LeaseExpire          int      `json:"lease-expire"            mapstructure:"lease-expire"`
	Username             string   `json:"username"                mapstructure:"username"`
	Password             string   `json:"password"                mapstructure:"password"`
	UseTLS               bool     `json:"use-tls"                 mapstructure:"use-tls"`
	CaCert               string   `json:"ca-cert"                 mapstructure:"ca-cert"`
	Cert                 string   `json:"cert"                    mapstructure:"cert"`
	Key                  string   `json:"key"                     mapstructure:"key"`
	HealthBeatPathPrefix string   `json:"health_beat_path_prefix" mapstructure:"health_beat_path_prefix"`
	HealthBeatIFaceName  string   `json:"health_beat_iface_name"  mapstructure:"health_beat_iface_name"`
	Namespace            string   `json:"namespace"               mapstructure:"namespace"`
}

EtcdOptions defines options for etcd cluster.

func NewEtcdOptions

func NewEtcdOptions() *EtcdOptions

NewEtcdOptions create a `zero` value instance.

func (*EtcdOptions) AddFlags

func (o *EtcdOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*EtcdOptions) GetEtcdTLSConfig

func (o *EtcdOptions) GetEtcdTLSConfig() (*tls.Config, error)

GetEtcdTLSConfig returns etcd tls config.

func (*EtcdOptions) Validate

func (o *EtcdOptions) Validate() []error

Validate verifies flags passed to RedisOptions.

type FeatureOptions

type FeatureOptions struct {
	EnableProfiling bool `json:"profiling"      mapstructure:"profiling"`
	EnableMetrics   bool `json:"enable-metrics" mapstructure:"enable-metrics"`
}

FeatureOptions contains configuration items related to API server features.

func NewFeatureOptions

func NewFeatureOptions() *FeatureOptions

NewFeatureOptions creates a FeatureOptions object with default parameters.

func (*FeatureOptions) AddFlags

func (o *FeatureOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*FeatureOptions) ApplyTo

func (o *FeatureOptions) ApplyTo(c *server.Config) error

ApplyTo applies the run options to the method receiver and returns self.

func (*FeatureOptions) Validate

func (o *FeatureOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type GRPCOptions

type GRPCOptions struct {
	BindAddress string `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int    `json:"bind-port"    mapstructure:"bind-port"`
	MaxMsgSize  int    `json:"max-msg-size" mapstructure:"max-msg-size"`
}

GRPCOptions are for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func NewGRPCOptions

func NewGRPCOptions() *GRPCOptions

NewGRPCOptions is for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func (*GRPCOptions) AddFlags

func (s *GRPCOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*GRPCOptions) Validate

func (s *GRPCOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type GeneratableKeyCert

type GeneratableKeyCert struct {
	// CertKey allows setting an explicit cert/key file to use.
	CertKey CertKey `json:"cert-key" mapstructure:"cert-key"`

	// CertDirectory specifies a directory to write generated certificates to if CertFile/KeyFile aren't explicitly set.
	// PairName is used to determine the filenames within CertDirectory.
	// If CertDirectory and PairName are not set, an in-memory certificate will be generated.
	CertDirectory string `json:"cert-dir"  mapstructure:"cert-dir"`
	// PairName is the name which will be used with CertDirectory to make a cert and key filenames.
	// It becomes CertDirectory/PairName.crt and CertDirectory/PairName.key
	PairName string `json:"pair-name" mapstructure:"pair-name"`
}

GeneratableKeyCert contains configuration items related to certificate.

type InsecureServingOptions

type InsecureServingOptions struct {
	BindAddress string `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int    `json:"bind-port"    mapstructure:"bind-port"`
}

InsecureServingOptions are for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func NewInsecureServingOptions

func NewInsecureServingOptions() *InsecureServingOptions

NewInsecureServingOptions is for creating an unauthenticated, unauthorized, insecure port. No one should be using these anymore.

func (*InsecureServingOptions) AddFlags

func (s *InsecureServingOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*InsecureServingOptions) ApplyTo

func (s *InsecureServingOptions) ApplyTo(c *server.Config) error

ApplyTo applies the run options to the method receiver and returns self.

func (*InsecureServingOptions) Validate

func (s *InsecureServingOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type JwtOptions

type JwtOptions struct {
	Realm      string        `json:"realm"       mapstructure:"realm"`
	Key        string        `json:"key"         mapstructure:"key"`
	Timeout    time.Duration `json:"timeout"     mapstructure:"timeout"`
	MaxRefresh time.Duration `json:"max-refresh" mapstructure:"max-refresh"`
}

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)

AddFlags adds flags related to features for a specific api server to the specified FlagSet.

func (*JwtOptions) ApplyTo

func (s *JwtOptions) ApplyTo(c *server.Config) error

ApplyTo applies the run options to the method receiver and returns self.

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 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"`
	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)

AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.

func (*MySQLOptions) NewClient

func (o *MySQLOptions) NewClient() (*gorm.DB, error)

NewClient 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 {
	Host                  string   `json:"host"                     mapstructure:"host"                     description:"Redis service host address"`
	Port                  int      `json:"port"`
	Addrs                 []string `json:"addrs"                    mapstructure:"addrs"`
	Username              string   `json:"username"                 mapstructure:"username"`
	Password              string   `json:"password"                 mapstructure:"password"`
	Database              int      `json:"database"                 mapstructure:"database"`
	MasterName            string   `json:"master-name"              mapstructure:"master-name"`
	MaxIdle               int      `json:"optimisation-max-idle"    mapstructure:"optimisation-max-idle"`
	MaxActive             int      `json:"optimisation-max-active"  mapstructure:"optimisation-max-active"`
	Timeout               int      `json:"timeout"                  mapstructure:"timeout"`
	EnableCluster         bool     `json:"enable-cluster"           mapstructure:"enable-cluster"`
	UseSSL                bool     `json:"use-ssl"                  mapstructure:"use-ssl"`
	SSLInsecureSkipVerify bool     `json:"ssl-insecure-skip-verify" mapstructure:"ssl-insecure-skip-verify"`
}

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)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*RedisOptions) Validate

func (o *RedisOptions) Validate() []error

Validate verifies flags passed to RedisOptions.

type SecureServingOptions

type SecureServingOptions struct {
	BindAddress string `json:"bind-address" mapstructure:"bind-address"`
	// BindPort is ignored when Listener is set, will serve HTTPS even with 0.
	BindPort int `json:"bind-port"    mapstructure:"bind-port"`
	// Required set to true means that BindPort cannot be zero.
	Required bool
	// ServerCert is the TLS cert info for serving secure traffic
	ServerCert GeneratableKeyCert `json:"tls"          mapstructure:"tls"`
}

SecureServingOptions contains configuration items related to HTTPS server startup.

func NewSecureServingOptions

func NewSecureServingOptions() *SecureServingOptions

NewSecureServingOptions creates a SecureServingOptions object with default parameters.

func (*SecureServingOptions) AddFlags

func (s *SecureServingOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to HTTPS server for a specific APIServer to the specified FlagSet.

func (*SecureServingOptions) ApplyTo

func (s *SecureServingOptions) ApplyTo(c *server.Config) error

ApplyTo applies the run options to the method receiver and returns self.

func (*SecureServingOptions) Complete

func (s *SecureServingOptions) Complete() error

Complete fills in any fields not set that are required to have valid data.

func (*SecureServingOptions) Validate

func (s *SecureServingOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type ServerRunOptions

type ServerRunOptions struct {
	Mode        string   `json:"mode"        mapstructure:"mode"`
	Healthz     bool     `json:"healthz"     mapstructure:"healthz"`
	Middlewares []string `json:"middlewares" mapstructure:"middlewares"`
}

ServerRunOptions contains the options while running a generic api server.

func NewServerRunOptions

func NewServerRunOptions() *ServerRunOptions

NewServerRunOptions creates a new ServerRunOptions object with default parameters.

func (*ServerRunOptions) AddFlags

func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags for a specific APIServer to the specified FlagSet.

func (*ServerRunOptions) ApplyTo

func (s *ServerRunOptions) ApplyTo(c *server.Config) error

ApplyTo applies the run options to the method receiver and returns self.

func (*ServerRunOptions) Validate

func (s *ServerRunOptions) Validate() []error

Validate checks validation of ServerRunOptions.

Jump to

Keyboard shortcuts

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