options

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

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

This section is empty.

Types

type AppOptions

type AppOptions struct {
	Generic  *GenericOptions  `json:"generic,omitempty" yaml:"generic,omitempty"`
	Logging  *LoggingOptions  `json:"logging,omitempty" yaml:"logging,omitempty"`
	Network  *NetworkOptions  `json:"network,omitempty" yaml:"network,omitempty"`
	Database *DatabaseOptions `json:"database,omitempty" yaml:"database,omitempty"`
}

AppOptions runs a App server.

func NewAppOptions

func NewAppOptions() *AppOptions

NewAppOptions creates a new AppOptions object with default parameters

func (*AppOptions) Complete

func (o *AppOptions) Complete(args []string) error

func (*AppOptions) Config

func (o *AppOptions) Config() *server.Config

func (*AppOptions) Flags

func (o *AppOptions) Flags() (fss flag.NamedFlagSets)

Flags returns flags for a specific APIServer by section name

func (*AppOptions) LoadConfigFromFile

func (o *AppOptions) LoadConfigFromFile(configFile string) error

func (*AppOptions) Run

func (o *AppOptions) Run() (err error)

func (*AppOptions) Validate

func (o *AppOptions) Validate() (err error)

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

type DatabaseOptions

type DatabaseOptions 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"`
	// 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) InstallDB

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

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

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 GenericOptions

type GenericOptions struct {
	ConfigFile  string `json:"configFile" yaml:"configFile"`
	DumpVersion bool   `json:"dumpVersion" yaml:"dumpVersion"`
	DumpEnvs    bool   `json:"dumpEnvs" yaml:"dumpEnvs"`
}

GenericOptions is a generic options struct

func NewGenericOptions

func NewGenericOptions() *GenericOptions

NewGenericOptions returns a GenericOptions instance with the default values

func (*GenericOptions) AddFlags

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

AddFlags adds flags for a specific Option to the specified FlagSet

func (*GenericOptions) ApplyTo

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

ApplyTo apply generic options to the server config

func (*GenericOptions) Validate

func (o *GenericOptions) Validate() error

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

type LoggingOptions

type LoggingOptions struct {
	LogLevel            string `json:"logLevel,omitempty" yaml:"logLevel,omitempty"`
	DisableText         bool   `json:"disableText,omitempty" yaml:"disableText,omitempty"`
	TextPretty          bool   `json:"textPretty,omitempty" yaml:"textPretty,omitempty"`
	JSONPretty          bool   `json:"jsonPretty,omitempty" yaml:"jsonPretty,omitempty"`
	ReportCaller        bool   `json:"reportCaller,omitempty" yaml:"reportCaller,omitempty"`
	DumpCurrentConfig   bool   `json:"dumpCurrentConfig,omitempty" yaml:"dumpCurrentConfig,omitempty"`
	EnableLoggingToFile bool   `json:"enableLoggingToFile,omitempty" yaml:"enableLoggingToFile,omitempty"`
	LoggingDirectory    string `json:"loggingDirectory,omitempty" yaml:"loggingDirectory,omitempty"`
}

LoggingOptions provides the logging configuration.

func NewLoggingOptions

func NewLoggingOptions() *LoggingOptions

NewLoggingOptions returns a LoggingOptions instance with the default values

func (*LoggingOptions) AddFlags

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

AddFlags adds flags for a specific Option to the specified FlagSet

func (*LoggingOptions) ApplyTo

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

ApplyTo apply logging options to the server config

func (*LoggingOptions) InitLogging

func (o *LoggingOptions) InitLogging(projectName string) error

helper function configures the logging.

func (*LoggingOptions) Validate

func (o *LoggingOptions) Validate() error

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

type NetworkOptions

type NetworkOptions struct {
	Port                  int           `json:"port,omitempty" yaml:"port,omitempty"`
	CorsAllowedOriginList []string      `json:"corsAllowedOriginList,omitempty" yaml:"corsAllowedOriginList,omitempty"`
	RequestTimeout        time.Duration `json:"requestTimeout,omitempty" yaml:"requestTimeout,omitempty"`
}

NetworkOptions is a Network options struct

func NewNetworkOptions

func NewNetworkOptions() *NetworkOptions

NewNetworkOptions returns a NetworkOptions instance with the default values

func (*NetworkOptions) AddFlags

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

AddFlags adds flags for a specific Option to the specified FlagSet

func (*NetworkOptions) Validate

func (o *NetworkOptions) Validate() error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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