mirror of https://github.com/agola-io/agola
services/config: fix db config validation
* Configstore validation was using Runservice db config * Add missing Notification service db validation * Add missing service names in validation errors * Fix tests
This commit is contained in:
parent
87c2733ecd
commit
a045986f85
|
|
@ -566,7 +566,7 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
return errors.Errorf("gateway runserviceURL is empty")
|
||||
}
|
||||
if err := validateCookieSigning(&c.Gateway.CookieSigning); err != nil {
|
||||
return errors.Wrap(err, "cookie signing configuration error")
|
||||
return errors.Wrap(err, "gateway cookie signing configuration error")
|
||||
}
|
||||
if err := validateWeb(&c.Gateway.Web); err != nil {
|
||||
return errors.Wrapf(err, "gateway web configuration error")
|
||||
|
|
@ -578,8 +578,8 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
|
||||
// Configstore
|
||||
if isComponentEnabled(componentsNames, "configstore") {
|
||||
if err := validateDB(&c.Runservice.DB); err != nil {
|
||||
return errors.Wrapf(err, "db configuration error")
|
||||
if err := validateDB(&c.Configstore.DB); err != nil {
|
||||
return errors.Wrapf(err, "configstore db configuration error")
|
||||
}
|
||||
if c.Configstore.DataDir == "" {
|
||||
return errors.Errorf("configstore dataDir is empty")
|
||||
|
|
@ -592,7 +592,7 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
// Runservice
|
||||
if isComponentEnabled(componentsNames, "runservice") {
|
||||
if err := validateDB(&c.Runservice.DB); err != nil {
|
||||
return errors.Wrapf(err, "db configuration error")
|
||||
return errors.Wrapf(err, "runservice db configuration error")
|
||||
}
|
||||
if c.Runservice.DataDir == "" {
|
||||
return errors.Errorf("runservice dataDir is empty")
|
||||
|
|
@ -608,7 +608,7 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
return errors.Errorf("executor dataDir is empty")
|
||||
}
|
||||
if c.Executor.ToolboxPath == "" {
|
||||
return errors.Errorf("git server toolboxPath is empty")
|
||||
return errors.Errorf("executor toolboxPath is empty")
|
||||
}
|
||||
if c.Executor.RunserviceURL == "" {
|
||||
return errors.Errorf("executor runserviceURL is empty")
|
||||
|
|
@ -637,6 +637,9 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
|
||||
// Notification
|
||||
if isComponentEnabled(componentsNames, "notification") {
|
||||
if err := validateDB(&c.Notification.DB); err != nil {
|
||||
return errors.Wrapf(err, "notification db configuration error")
|
||||
}
|
||||
if c.Notification.WebExposedURL == "" {
|
||||
return errors.Errorf("notification webExposedURL is empty")
|
||||
}
|
||||
|
|
@ -651,7 +654,7 @@ func Validate(c *Config, componentsNames []string) error {
|
|||
// Git server
|
||||
if isComponentEnabled(componentsNames, "gitserver") {
|
||||
if c.Gitserver.DataDir == "" {
|
||||
return errors.Errorf("git server dataDir is empty")
|
||||
return errors.Errorf("gitserver dataDir is empty")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ notification:
|
|||
webExposedURL: "http://localhost:8000"
|
||||
runserviceURL: "http://localhost:4000"
|
||||
configstoreURL: "http://localhost:4002"
|
||||
db:
|
||||
type: sqlite3
|
||||
connString: /data/agola/notification/db
|
||||
|
||||
configstore:
|
||||
dataDir: /data/agola/configstore
|
||||
|
|
@ -120,6 +123,7 @@ gitserver:
|
|||
WebExposedURL: "http://localhost:8000",
|
||||
RunserviceURL: "http://localhost:4000",
|
||||
ConfigstoreURL: "http://localhost:4002",
|
||||
DB: DB{Type: "sqlite3", ConnString: "/data/agola/notification/db"},
|
||||
RunWebhookExpireInterval: 7 * 24 * time.Hour,
|
||||
CommitStatusExpireInterval: 7 * 24 * time.Hour,
|
||||
},
|
||||
|
|
@ -183,6 +187,9 @@ notification:
|
|||
webExposedURL: "http://localhost:8000"
|
||||
runserviceURL: "http://localhost:4000"
|
||||
configstoreURL: "http://localhost:4002"
|
||||
db:
|
||||
type: sqlite3
|
||||
connString: /data/agola/notification/db
|
||||
|
||||
configstore:
|
||||
dataDir: /data/agola/configstore
|
||||
|
|
@ -230,6 +237,7 @@ gitserver:
|
|||
WebExposedURL: "http://localhost:8000",
|
||||
RunserviceURL: "http://localhost:4000",
|
||||
ConfigstoreURL: "http://localhost:4002",
|
||||
DB: DB{Type: "sqlite3", ConnString: "/data/agola/notification/db"},
|
||||
RunWebhookExpireInterval: 7 * 24 * time.Hour,
|
||||
CommitStatusExpireInterval: 7 * 24 * time.Hour,
|
||||
},
|
||||
|
|
@ -289,6 +297,9 @@ notification:
|
|||
webExposedURL: "http://localhost:8000"
|
||||
runserviceURL: "http://localhost:4000"
|
||||
configstoreURL: "http://localhost:4002"
|
||||
db:
|
||||
type: sqlite3
|
||||
connString: /data/agola/notification/db
|
||||
|
||||
configstore:
|
||||
dataDir:
|
||||
|
|
@ -318,6 +329,7 @@ gitserver:
|
|||
WebExposedURL: "http://localhost:8000",
|
||||
RunserviceURL: "http://localhost:4000",
|
||||
ConfigstoreURL: "http://localhost:4002",
|
||||
DB: DB{Type: "sqlite3", ConnString: "/data/agola/notification/db"},
|
||||
RunWebhookExpireInterval: 7 * 24 * time.Hour,
|
||||
CommitStatusExpireInterval: 7 * 24 * time.Hour,
|
||||
},
|
||||
|
|
@ -334,8 +346,8 @@ gitserver:
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "test config for gateway, scheduler, notification and gitserver without dataDir",
|
||||
services: []string{"gateway", "scheduler", "notification", "gitserver"},
|
||||
name: "test config for gitserver without dataDir",
|
||||
services: []string{"gitserver"},
|
||||
in: `
|
||||
gateway:
|
||||
apiExposedURL: "http://localhost:8000"
|
||||
|
|
@ -360,6 +372,9 @@ notification:
|
|||
webExposedURL: "http://localhost:8000"
|
||||
runserviceURL: "http://localhost:4000"
|
||||
configstoreURL: "http://localhost:4002"
|
||||
db:
|
||||
type: sqlite3
|
||||
connString: /data/agola/notification/db
|
||||
|
||||
configstore:
|
||||
dataDir:
|
||||
|
|
@ -370,7 +385,7 @@ runservice:
|
|||
gitserver:
|
||||
dataDir:
|
||||
`,
|
||||
err: errors.Errorf("git server dataDir is empty"),
|
||||
err: errors.Errorf("gitserver dataDir is empty"),
|
||||
},
|
||||
|
||||
{
|
||||
|
|
@ -396,6 +411,9 @@ gateway:
|
|||
scheduler:
|
||||
|
||||
notification:
|
||||
db:
|
||||
type: sqlite3
|
||||
connString: /data/agola/notification/db
|
||||
|
||||
configstore:
|
||||
dataDir: /data/agola/configstore
|
||||
|
|
@ -459,6 +477,7 @@ gitserver:
|
|||
WebExposedURL: "http://localhost:8000",
|
||||
RunserviceURL: "http://localhost:4000",
|
||||
ConfigstoreURL: "http://localhost:4002",
|
||||
DB: DB{Type: "sqlite3", ConnString: "/data/agola/notification/db"},
|
||||
RunWebhookExpireInterval: 7 * 24 * time.Hour,
|
||||
CommitStatusExpireInterval: 7 * 24 * time.Hour,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue