summaryrefslogtreecommitdiff
path: root/config
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go31
-rw-r--r--config/config.local.yaml26
-rw-r--r--config/config.prod.yaml26
-rw-r--r--config/config.stage.yaml26
-rw-r--r--config/config.yaml17
5 files changed, 24 insertions, 102 deletions
diff --git a/config/config.go b/config/config.go
index 7438fe1..67c0c4d 100644
--- a/config/config.go
+++ b/config/config.go
@@ -9,15 +9,13 @@ import (
)
type Config struct {
- LogLevel slog.Level `json:"LogLevel" yaml:"logLevel" validate:"required"`
- BlogPages BlogPagesConfig `json:"BlogPages" yaml:"blogPages" validate:"required"`
- LocalePath string `json:"LocalePath" yaml:"localePath" validate:"required,filepath"`
- AvailableLanguages []AvailableLanguageConfig `json:"AvailableLanguages" yaml:"availableLanguages" validate:"required"`
- Auth AuthConfig `json:"Auth" yaml:"auth" validate:"required"`
+ LogLevel slog.Level `json:"LogLevel" yaml:"logLevel" validate:"required"`
+ BlogPages BlogPagesConfig `json:"BlogPages" yaml:"blogPages" validate:"required"`
}
type BlogPagesConfig struct {
- Storage StorageConfig `json:"Storage" yaml:"storage" validate:"required"`
+ Storage StorageConfig `json:"Storage" yaml:"storage" validate:"required"`
+ AvailableLanguages []AvailableLanguageConfig `json:"AvailableLanguages" yaml:"availableLanguages" validate:"required"`
}
type StorageConfig struct {
@@ -34,24 +32,9 @@ type B2Config struct {
}
type AvailableLanguageConfig struct {
- Name string `json:"Name" yaml:"name" validate:"required"`
- Alt string `json:"Alt" yaml:"alt"`
- Flag string `json:"Flag" yaml:"flag" validate:"url"`
- LocFile string `json:"LocFile" yaml:"locFile" validate:"required,filepath"`
-}
-
-type AuthConfig struct {
- Salt string `json:"Salt" yaml:"salt" validate:"required"`
- Db DbConfig `json:"Db" yaml:"db" validate:"required"`
-}
-
-type DbConfig struct {
- Type string `json:"Type" yaml:"type" validate:"required,oneof=sqlite3"`
- Cfg Sqlite3Config `json:"Config" yaml:"config"`
-}
-
-type Sqlite3Config struct {
- DSN string `json:"DSN" yaml:"dsn" validate:"required"`
+ Name string `json:"Name" yaml:"name" validate:"required"`
+ Alt string `json:"Alt" yaml:"alt"`
+ Flag string `json:"Flag" yaml:"flag" validate:"url"`
}
func LoadConfig(path string, config *Config) error {
diff --git a/config/config.local.yaml b/config/config.local.yaml
deleted file mode 100644
index 0b48e47..0000000
--- a/config/config.local.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-logLevel: debug
-blogPages:
- storage:
- type: b2
- config:
- bucketName: sayana-pages
- region: eu-central-003
- prefix: 'stage-'
- keyID: '${B2_KEY_ID}'
- applicationKey: '${B2_APPLICATION_KEY}'
-localePath: ./locale/
-availableLanguages:
- - name: ru
- alt: Русский
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/ru.svg
- locFile: localization.ru.yaml
- - name: en
- alt: English
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/gb.svg
- locFile: localization.en.yaml
-auth:
- db:
- type: sqlite3
- config:
- dsn: 'file:/tmp/auth.db?cache=shared&mode=rwc'
- salt: '123'
diff --git a/config/config.prod.yaml b/config/config.prod.yaml
deleted file mode 100644
index e1294c0..0000000
--- a/config/config.prod.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-logLevel: info
-blogPages:
- storage:
- type: b2
- config:
- bucketName: sayana-pages
- region: eu-central-003
- prefix: 'prod-'
- keyID: '${B2_KEY_ID}'
- applicationKey: '${B2_APPLICATION_KEY}'
-localePath: ./locale/
-availableLanguages:
- - name: ru
- alt: Русский
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/ru.svg
- locFile: localization.ru.yaml
- - name: en
- alt: English
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/gb.svg
- locFile: localization.en.yaml
-auth:
- db:
- type: sqlite3
- config:
- dsn: 'file:/data/auth.db?cache=private&mode=rwc&_locking_mode=EXCLUSIVE&_mutex=no&_auto_vacuum=2'
- salt: '${AUTH_SALT}'
diff --git a/config/config.stage.yaml b/config/config.stage.yaml
deleted file mode 100644
index 30233c1..0000000
--- a/config/config.stage.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-logLevel: debug
-blogPages:
- storage:
- type: b2
- config:
- bucketName: sayana-pages
- region: eu-central-003
- prefix: 'stage-'
- keyID: '${B2_KEY_ID}'
- applicationKey: '${B2_APPLICATION_KEY}'
-localePath: ./locale/
-availableLanguages:
- - name: ru
- alt: Русский
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/ru.svg
- locFile: localization.ru.yaml
- - name: en
- alt: English
- flag: https://f003.backblazeb2.com/file/sayana-static/flags/gb.svg
- locFile: localization.en.yaml
-auth:
- db:
- type: sqlite3
- config:
- dsn: 'file:/data/auth.db?cache=private&mode=rwc&_locking_mode=EXCLUSIVE&_mutex=no&_auto_vacuum=2'
- salt: '${AUTH_SALT}'
diff --git a/config/config.yaml b/config/config.yaml
new file mode 100644
index 0000000..908bfe2
--- /dev/null
+++ b/config/config.yaml
@@ -0,0 +1,17 @@
+logLevel: debug
+blogPages:
+ storage:
+ type: b2
+ config:
+ bucketName: sayana-pages
+ region: eu-central-003
+ prefix: ''
+ keyID: '${B2_KEY_ID}'
+ applicationKey: '${B2_APPLICATION_KEY}'
+ availableLanguages:
+ - name: ru
+ alt: Русский
+ flag: https://f003.backblazeb2.com/file/sayana-static/flags/ru.svg
+ - name: en
+ alt: English
+ flag: https://f003.backblazeb2.com/file/sayana-static/flags/gb.svg