configs

package
v0.90.74 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const SqliteFilename = "statping.db"

Variables

This section is empty.

Functions

func Connect

func Connect(configs *DbConfig, retry bool) error

Connect will attempt to connect to the sqlite, postgres, or mysql database

func ConnectConfigs

func ConnectConfigs(configs *DbConfig, retry bool) error

ConnectConfigs will connect to the database and save the config.yml file

func CreateAdminUser

func CreateAdminUser() error

CreateAdminUser will create the default admin user "admin", "admin", or use the environment variables ADMIN_USER, ADMIN_PASSWORD, and ADMIN_EMAIL if set.

func Save added in v0.90.67

func Save() error

func TriggerSamples

func TriggerSamples() error

Types

type DbConfig

type DbConfig struct {
	DbConn            string `yaml:"connection,omitempty" json:"connection"`
	DbHost            string `yaml:"host,omitempty" json:"-"`
	DbUser            string `yaml:"user,omitempty" json:"-"`
	DbPass            string `yaml:"password,omitempty" json:"-"`
	DbData            string `yaml:"database,omitempty" json:"-"`
	DbPort            int    `yaml:"port,omitempty" json:"-"`
	ApiSecret         string `yaml:"api_secret,omitempty" json:"-"`
	Language          string `yaml:"language,omitempty" json:"language"`
	AllowReports      bool   `yaml:"allow_reports,omitempty" json:"allow_reports"`
	Project           string `yaml:"-" json:"-"`
	Description       string `yaml:"-" json:"-"`
	Domain            string `yaml:"-" json:"-"`
	Username          string `yaml:"-" json:"-"`
	Password          string `yaml:"-" json:"-"`
	Email             string `yaml:"-" json:"-"`
	Error             error  `yaml:"-" json:"-"`
	Location          string `yaml:"location,omitempty" json:"-"`
	SqlFile           string `yaml:"sqlfile,omitempty" json:"-"`
	LetsEncryptHost   string `yaml:"letsencrypt_host,omitempty" json:"letsencrypt_host"`
	LetsEncryptEmail  string `yaml:"letsencrypt_email,omitempty" json:"letsencrypt_email"`
	LetsEncryptEnable bool   `yaml:"letsencrypt_enable,omitempty" json:"letsencrypt_enable"`
	LocalIP           string `yaml:"-" json:"-"`

	DisableHTTP bool   `yaml:"disable_http" json:"disable_http"`
	DemoMode    bool   `yaml:"demo_mode" json:"demo_mode"`
	DisableLogs bool   `yaml:"disable_logs" json:"disable_logs"`
	UseAssets   bool   `yaml:"use_assets" json:"use_assets"`
	BasePath    string `yaml:"base_path,omitempty" json:"base_path"`

	AdminUser     string `yaml:"admin_user,omitempty" json:"admin_user"`
	AdminPassword string `yaml:"admin_password,omitempty" json:"admin_password"`
	AdminEmail    string `yaml:"admin_email,omitempty" json:"admin_email"`

	MaxOpenConnections int `yaml:"db_open_connections,omitempty" json:"db_open_connections"`
	MaxIdleConnections int `yaml:"db_idle_connections,omitempty" json:"db_idle_connections"`
	MaxLifeConnections int `yaml:"db_max_life_connections,omitempty" json:"db_max_life_connections"`

	SampleData    bool `yaml:"sample_data" json:"sample_data"`
	UseCDN        bool `yaml:"use_cdn" json:"use_cdn"`
	DisableColors bool `yaml:"disable_colors" json:"disable_colors"`

	PostgresSSLMode string `yaml:"postgres_ssl,omitempty" json:"postgres_ssl"`

	Db database.Database `yaml:"-" json:"-"`
}

DbConfig struct is used for the Db connection and creates the 'config.yml' file

func LoadConfigForm

func LoadConfigForm(r *http.Request) (*DbConfig, error)

func LoadConfigs

func LoadConfigs(cfgFile string) (*DbConfig, error)

func (*DbConfig) BackupAssets added in v0.90.14

func (d *DbConfig) BackupAssets() error

BackupAssets is a temporary function (to version 0.90.*) to backup your customized theme to a new folder called 'assets_backup'.

func (*DbConfig) Clean added in v0.90.69

func (d *DbConfig) Clean() *DbConfig

Clean hides all sensitive database information for API requests

func (*DbConfig) Close

func (d *DbConfig) Close()

func (*DbConfig) ConnectionString added in v0.90.28

func (d *DbConfig) ConnectionString() string

func (*DbConfig) CreateDatabase

func (d *DbConfig) CreateDatabase() error

CreateDatabase will CREATE TABLES for each of the Statping elements

func (*DbConfig) DatabaseChanges

func (d *DbConfig) DatabaseChanges() error

func (*DbConfig) DropDatabase

func (d *DbConfig) DropDatabase() error

DropDatabase will DROP each table Statping created

func (*DbConfig) Merge added in v0.90.69

func (d *DbConfig) Merge(newCfg *DbConfig) *DbConfig

Merge will merge the database connection info into the input

func (*DbConfig) MigrateDatabase

func (d *DbConfig) MigrateDatabase() error

MigrateDatabase will migrate the database structure to current version. This function will NOT remove previous records, tables or columns from the database. If this function has an issue, it will ROLLBACK to the previous state.

func (*DbConfig) ResetCore added in v0.90.58

func (d *DbConfig) ResetCore() error

func (*DbConfig) Save

func (d *DbConfig) Save(directory string) error

Save will initially create the config.yml file

func (*DbConfig) ToYAML added in v0.90.69

func (d *DbConfig) ToYAML() []byte

func (*DbConfig) Update

func (d *DbConfig) Update() error

Migrate function

type Sampler

type Sampler interface {
	Samples() []database.DbObject
}

type SamplerFunc

type SamplerFunc func() error

Jump to

Keyboard shortcuts

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