Fix envvar config for storage
Some checks failed
/ docker-build-only (push) Failing after 35s
/ go-test (push) Failing after 1m3s

This commit is contained in:
Melora Hugues 2024-10-20 17:31:00 +02:00
parent f0011e183d
commit 67ce0aec79
5 changed files with 6 additions and 5 deletions

2
.envrc
View file

@ -8,7 +8,7 @@ export POLYCULECONNECT_SERVER_PORT="5000"
# POLYCULECONNECT_SERVER_SOCK_PATH = ""
export POLYCULECONNECT_STORAGE_TYPE="sqlite"
export POLYCULECONNECT_STORAGE_FILEPATH="./build/polyculeconnect.db"
export POLYCULECONNECT_STORAGE_PATH="./build/polyculeconnect.db"
# POLYCULECONNECT_STORAGE_HOST = "127.0.0.1"
# POLYCULECONNECT_STORAGE_PORT = "5432"
# POLYCULECONNECT_STORAGE_DB = "polyculeconnect"

View file

@ -24,7 +24,7 @@ var connectCmd = &cobra.Command{
},
}
func connectSQLite(conf *config.StorageConfig) error {
func connectSQLite(conf config.StorageConfig) error {
path, err := exec.LookPath("sqlite3")
if err != nil {
if errors.Is(err, exec.ErrNotFound) {

View file

@ -129,7 +129,7 @@ type AppConfig struct {
Port int `envconfig:"SERVER_PORT"`
SockPath string `envconfig:"SERVER_SOCK"`
StorageType string `envconfig:"STORAGE_TYPE"`
StorageConfig *StorageConfig
StorageConfig StorageConfig
Issuer string
StaticDir string
}
@ -142,7 +142,7 @@ func defaultConfig() AppConfig {
Port: defaultServerPort,
SockPath: defaultServerSocket,
StorageType: string(defaultStorageType),
StorageConfig: &StorageConfig{
StorageConfig: StorageConfig{
File: defaultStorageFile,
Host: defaultStorageHost,
Port: defaultServerPort,
@ -212,11 +212,12 @@ func New(filepath string) (*AppConfig, error) {
if err := envconfig.Process(envConfigPrefix, &conf); err != nil {
return nil, err
}
if err := envconfig.Process(envConfigPrefix, conf.StorageConfig); err != nil {
if err := envconfig.Process(envConfigPrefix, &conf.StorageConfig); err != nil {
return nil, err
}
if err := envconfig.Process(envConfigPrefix, &conf.StorageConfig.SSL); err != nil {
return nil, err
}
return &conf, nil
}

Binary file not shown.

Binary file not shown.