mirror of https://github.com/agola-io/agola
Compare commits
6 Commits
e697e9163e
...
babcd6a6fa
| Author | SHA1 | Date |
|---|---|---|
|
|
babcd6a6fa | |
|
|
f61c9699cc | |
|
|
4dc98294b4 | |
|
|
a045986f85 | |
|
|
87c2733ecd | |
|
|
c77f1fe4e8 |
|
|
@ -16,6 +16,7 @@ package config
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
|
|
@ -514,6 +515,12 @@ func validateDB(db *DB) error {
|
|||
return errors.Errorf("db connection string undefined")
|
||||
}
|
||||
|
||||
if db.Type == sql.Sqlite3 {
|
||||
if !filepath.IsAbs(db.ConnString) {
|
||||
return errors.Errorf("sqlite3 db connection string must be an absolute path")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +573,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 +585,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 +599,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 +615,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 +644,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 +661,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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csapitypes.Project, error) {
|
||||
project, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
if project.GlobalVisibility == cstypes.VisibilityPublic {
|
||||
|
|
|
|||
Loading…
Reference in New Issue