Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

Commit e73a526

Browse files
authored
Merge pull request #88 from vultisig/harmonize-config
Harmonize configs: refactor database config nesting
2 parents 8d05209 + 0be5cfc commit e73a526

8 files changed

Lines changed: 21 additions & 18 deletions

File tree

.github/workflows/migration-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ jobs:
5252
"server": {
5353
"host": "localhost",
5454
"port": 8080,
55-
"jwt_secret": "test-secret",
56-
"database": {
57-
"dsn": "postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable"
58-
}
55+
"jwt_secret": "test-secret"
56+
},
57+
"database": {
58+
"dsn": "postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable"
5959
},
6060
"redis": {
6161
"host": "localhost",

api/server_config.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package api
22

33
// ServerConfig holds the configuration parameters for the server.
4-
//
4+
//
55
// Fields:
66
// - Host: The hostname or IP address where the server will run.
77
// - Port: The port number on which the server will listen for incoming requests.
88
// - EncryptionSecret: A secret key used for encrypting sensitive data.
9-
// - Database: Configuration for the database connection, including:
10-
// - DSN: The Data Source Name (DSN) for connecting to the database.
119
type ServerConfig struct {
1210
Host string `mapstructure:"host" json:"host,omitempty"`
1311
Port int64 `mapstructure:"port" json:"port,omitempty"`
1412
EncryptionSecret string `mapstructure:"encryption_secret" json:"encryption_secret,omitempty"`
15-
Database struct {
16-
DSN string `mapstructure:"dsn" json:"dsn,omitempty"`
17-
} `mapstructure:"database" json:"database,omitempty"`
1813
}

cmd/dca/server/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import (
1212
)
1313

1414
type DCAServerConfig struct {
15-
Server api.ServerConfig `mapstructure:"server" json:"server"`
15+
Server api.ServerConfig `mapstructure:"server" json:"server"`
16+
Database struct {
17+
DSN string `mapstructure:"dsn" json:"dsn,omitempty"`
18+
} `mapstructure:"database" json:"database,omitempty"`
1619
BaseConfigPath string `mapstructure:"base_config_path" json:"base_config_path,omitempty"`
1720
Redis storage.RedisConfig `mapstructure:"redis" json:"redis,omitempty"`
1821
BlockStorage vault_config.BlockStorageConfig `mapstructure:"block_storage" json:"block_storage,omitempty"`

cmd/dca/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func main() {
5050
panic(err)
5151
}
5252

53-
db, err := postgres.NewPostgresBackend(cfg.Server.Database.DSN, nil)
53+
db, err := postgres.NewPostgresBackend(cfg.Database.DSN, nil)
5454
if err != nil {
5555
logger.Fatalf("Failed to connect to database: %v", err)
5656
}

cmd/payroll/server/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import (
1212
)
1313

1414
type PayrollServerConfig struct {
15-
Server api.ServerConfig `mapstructure:"server" json:"server"`
15+
Server api.ServerConfig `mapstructure:"server" json:"server"`
16+
Database struct {
17+
DSN string `mapstructure:"dsn" json:"dsn,omitempty"`
18+
} `mapstructure:"database" json:"database,omitempty"`
1619
BaseConfigPath string `mapstructure:"base_config_path" json:"base_config_path,omitempty"`
1720
Redis storage.RedisConfig `mapstructure:"redis" json:"redis,omitempty"`
1821
BlockStorage vault_config.BlockStorageConfig `mapstructure:"block_storage" json:"block_storage,omitempty"`

cmd/payroll/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func main() {
5151
panic(err)
5252
}
5353

54-
db, err := postgres.NewPostgresBackend(cfg.Server.Database.DSN, nil)
54+
db, err := postgres.NewPostgresBackend(cfg.Database.DSN, nil)
5555
if err != nil {
5656
logger.Fatalf("Failed to connect to database: %v", err)
5757
}

config-plugin.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ server:
55
port: 8081
66
verifier_url: "http://localhost:8081"
77
base_config_path: /etc/vultisig
8-
database:
9-
dsn: postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable
108
vaults_file_path: /tmp/plugin/vaults
119
mode: plugin
1210
plugin:
1311
type: dca
1412

13+
database:
14+
dsn: postgres://myuser:mypassword@localhost:5432/vultisig-plugin?sslmode=disable
15+
1516
relay:
1617
server: https://api.vultisig.com/router
1718

config-verifier.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
server:
44
host: localhost
55
port: 8080
6-
database:
7-
dsn: postgres://myuser:mypassword@localhost:5432/vultisig-verifier?sslmode=disable
86
vaults_file_path: /tmp/verifier/vaults
97
mode: verifier
108
plugin:
119
type: dca
1210

11+
database:
12+
dsn: postgres://myuser:mypassword@localhost:5432/vultisig-verifier?sslmode=disable
13+
1314
plugin:
1415
plugin_configs:
1516
dca:

0 commit comments

Comments
 (0)