Skip to content

Commit a74aaa1

Browse files
committed
feat(config): set to default directory when logRoot/repoRoot/... is empty or omitted
1 parent 8288444 commit a74aaa1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

config/artifact.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ func UnmarshalArtifact(filename string) *Artifact {
5252
if err := yaml.Unmarshal(data, cfg); err != nil {
5353
log.Fatalf("Failed to parse YAML: %v", err)
5454
}
55+
if cfg.LogRoot == "" {
56+
cfg.LogRoot = filepath.Join(utils.ProjectRoot(), "logs")
57+
log.Println("\033[33mWARNING: logRoot is empty, set to default value:", cfg.LogRoot, "\033[0m")
58+
}
59+
if cfg.RepoRoot == "" {
60+
cfg.RepoRoot = filepath.Join(utils.ProjectRoot(), "repos")
61+
log.Println("\033[33mWARNING: repoRoot is empty, set to default value:", cfg.RepoRoot, "\033[0m")
62+
}
63+
if cfg.DBRoot == "" {
64+
cfg.DBRoot = filepath.Join(utils.ProjectRoot(), "codeql-db")
65+
log.Println("\033[33mWARNING: dbRoot is empty, set to default value:", cfg.DBRoot, "\033[0m")
66+
}
67+
if cfg.ResultRoot == "" {
68+
cfg.ResultRoot = filepath.Join(utils.ProjectRoot(), "codeqlResult")
69+
log.Println("\033[33mWARNING: resultRoot is empty, set to default value:", cfg.ResultRoot, "\033[0m")
70+
}
71+
if cfg.QueryRoot == "" {
72+
cfg.QueryRoot = filepath.Join(utils.ProjectRoot(), "qlsrc")
73+
log.Println("\033[33mWARNING: queryRoot is empty, set to default value:", cfg.QueryRoot, "\033[0m")
74+
}
5575
return cfg
5676
}
5777

0 commit comments

Comments
 (0)