Documentation
¶
Index ¶
Constants ¶
const ( MaskString = "******" DefaultAdminUsername = "admin" DefaultDBPort = 5432 DefaultPort = 3000 )
Variables ¶
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") )
var ( DBHostEnv = os.Getenv("DB_HOST") DBPortEnv = os.Getenv("DB_PORT") DBUserEnv = os.Getenv("DB_USER") DBPassEnv = os.Getenv("DB_PASS") DBNameEnv = os.Getenv("DB_NAME") PortEnv = os.Getenv("PORT") LogFilePathEnv = os.Getenv("LOG_FILE_PATH") AutoMigrateEnv = os.Getenv("AUTO_MIGRATE") MigrateFileEnv = os.Getenv("MIGRATE_FILE") AdminUsernameEnv = os.Getenv("ADMIN_USERNAME") AdminPasswordEnv = os.Getenv("ADMIN_PASSWORD") GithubTokenEnv = os.Getenv("GITHUB_TOKEN") )
Functions ¶
func InitUserAdminIfNotExist ¶
func NewCmdServer ¶
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 (*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 ServerOptions ¶
type ServerOptions struct {
Port int
Database DatabaseOptions
LogFilePath string
GithubToken string
}
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) Run ¶
func (o *ServerOptions) Run() error
func (*ServerOptions) Validate ¶
func (o *ServerOptions) Validate() error