mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-07 16:44:25 +01:00
9287e2f9e2
This will allow importing storage.Config without importing every SQL drivers in the known universe
29 lines
731 B
Go
29 lines
731 B
Go
package storage
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrSQLStorageRequiresFile = errors.New("sql storage requires a non-empty file to be defined")
|
|
)
|
|
|
|
// Config is the configuration for storage
|
|
type Config struct {
|
|
// File is the path of the file to use for persistence
|
|
// If blank, persistence is disabled
|
|
//
|
|
// XXX: Rename to path for v4.0.0
|
|
File string `yaml:"file"`
|
|
|
|
// Type of store
|
|
// If blank, uses the default in-memory store
|
|
Type Type `yaml:"type"`
|
|
}
|
|
|
|
// ValidateAndSetDefaults validates the configuration and sets the default values (if applicable)
|
|
func (c *Config) ValidateAndSetDefaults() error {
|
|
if (c.Type == TypePostgres || c.Type == TypeSQLite) && len(c.File) == 0 {
|
|
return ErrSQLStorageRequiresFile
|
|
}
|
|
return nil
|
|
}
|