server

package
v0.12.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectName = "kcp"
	MaskString  = "******"
)

Variables

View Source
var (
	ErrDBHostNotSpecified = errors.New("--db-host must be specified")
	ErrDBNameNotSpecified = errors.New("--db-name must be specified")
	ErrDBUserNotSpecified = errors.New("--db-user must be specified")
	ErrDBPortNotSpecified = errors.New("--db-port must be specified")
)

Functions

func NewCmdServer

func NewCmdServer() *cobra.Command

Types

type DatabaseAccessOptions

type DatabaseAccessOptions struct {
	DBName     string `json:"dbName,omitempty" yaml:"dbName,omitempty"`
	DBUser     string `json:"dbUser,omitempty" yaml:"dbUser,omitempty"`
	DBPassword string `json:"dbPassword,omitempty" yaml:"dbPassword,omitempty"`
	DBHost     string `json:"dbHost,omitempty" yaml:"dbHost,omitempty"`
	DBPort     int    `json:"dbPort,omitempty" yaml:"dbPort,omitempty"`
}

DatabaseAccessOptions holds the database access layer configurations.

func NewDatabaseAccessOptions

func NewDatabaseAccessOptions() *DatabaseAccessOptions

NewDatabaseAccessOptions returns a DatabaseAccessOptions struct with the default values

func (*DatabaseAccessOptions) AddFlags

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

AddFlags adds flags related to DB to a specified FlagSet

func (*DatabaseAccessOptions) ApplyTo

func (o *DatabaseAccessOptions) ApplyTo(db **gorm.DB) error

ApplyTo uses the run options to generate and open a db session.

func (*DatabaseAccessOptions) InstallDB

func (o *DatabaseAccessOptions) InstallDB() (*gorm.DB, error)

InstallDB uses the run options to generate and open a db session.

func (*DatabaseAccessOptions) Validate

func (o *DatabaseAccessOptions) Validate() error

Validate checks validation of DatabaseAccessOptions

type DatabaseOptions

type DatabaseOptions struct {
	DatabaseAccessOptions `json:",inline" yaml:",inline"`
	// AutoMigrate will attempt to automatically migrate all tables
	AutoMigrate bool   `json:"autoMigrate,omitempty" yaml:"autoMigrate,omitempty"`
	MigrateFile string `json:"migrateFile,omitempty" yaml:"migrateFile,omitempty"`
}

DatabaseOptions is a Database options struct

func NewDatabaseOptions

func NewDatabaseOptions() *DatabaseOptions

NewDatabaseOptions returns a DatabaseOptions instance with the default values

func (*DatabaseOptions) AddFlags

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

AddFlags adds flags for a specific Option to the specified FlagSet

func (*DatabaseOptions) ApplyTo

func (o *DatabaseOptions) ApplyTo(config *server.Config)

ApplyTo apply database options to the server config

func (DatabaseOptions) MarshalJSON

func (o DatabaseOptions) MarshalJSON() ([]byte, error)

MarshalJSON is custom marshalling function for masking sensitive field values

func (*DatabaseOptions) Validate

func (o *DatabaseOptions) Validate() error

Validate checks DatabaseOptions and return a slice of found error(s)

type Options

type Options interface {
	// Validate checks Options and return a slice of found error(s)
	Validate() error
	// AddFlags adds flags for a specific Option to the specified FlagSet
	AddFlags(fs *pflag.FlagSet)
}

type ServerOptions

type ServerOptions struct {
	Mode     string
	Database DatabaseOptions
}

func NewServerOptions

func NewServerOptions() *ServerOptions

func (*ServerOptions) AddServerFlags

func (o *ServerOptions) AddServerFlags(cmd *cobra.Command)

func (*ServerOptions) Complete

func (o *ServerOptions) Complete(args []string)

func (*ServerOptions) Config

func (o *ServerOptions) Config() (*server.Config, error)

func (*ServerOptions) Run

func (o *ServerOptions) Run() error

func (*ServerOptions) Validate

func (o *ServerOptions) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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