moved hardcoded classes to config, renamed status to packages to better reflect their content

This commit is contained in:
2021-07-22 23:41:24 +02:00
parent c6b3d02cb1
commit 9515072dc8
3 changed files with 24 additions and 9 deletions

View File

@@ -28,5 +28,15 @@ build:
worker: 4 worker: 4
makej: 8 makej: 8
status:
class:
skipped: "secondary"
queued: "warning"
latest: "primary"
failed: "danger"
signing: "success"
building: "info"
unknown: "dark"
logging: logging:
level: DEBUG level: DEBUG

23
main.go
View File

@@ -97,6 +97,11 @@ type Conf struct {
Logging struct { Logging struct {
Level string Level string
} }
Status struct {
Class struct {
Skipped, Queued, Latest, Failed, Signing, Building, Unknown string
}
}
} }
func check(e error) { func check(e error) {
@@ -612,19 +617,19 @@ func isPkgFailed(pkg *BuildPackage) bool {
func statusId2string(status int) (string, string) { func statusId2string(status int) (string, string) {
switch status { switch status {
case SKIPPED: case SKIPPED:
return "SKIPPED", "table-secondary" return "SKIPPED", "table-" + conf.Status.Class.Skipped
case QUEUED: case QUEUED:
return "QUEUED", "table-warning" return "QUEUED", "table-" + conf.Status.Class.Queued
case LATEST: case LATEST:
return "LATEST", "table-primary" return "LATEST", "table-" + conf.Status.Class.Latest
case FAILED: case FAILED:
return "FAILED", "table-danger" return "FAILED", "table-" + conf.Status.Class.Failed
case BUILD: case BUILD:
return "SIGNING", "table-success" return "SIGNING", "table-" + conf.Status.Class.Signing
case BUILDING: case BUILDING:
return "BUILDING", "table-info" return "BUILDING", "table-" + conf.Status.Class.Building
default: default:
return "UNKNOWN", "table-dark" return "UNKNOWN", "table-" + conf.Status.Class.Unknown
} }
} }
@@ -713,10 +718,10 @@ func (b *BuildManager) htmlWorker() {
gen.Generated = time.Now().UTC() gen.Generated = time.Now().UTC()
statusTpl, err := template.ParseFiles("tpl/status.html") statusTpl, err := template.ParseFiles("tpl/packages.html")
check(err) check(err)
f, err := os.OpenFile(filepath.Join(conf.Basedir.Repo, "status.html"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) f, err := os.OpenFile(filepath.Join(conf.Basedir.Repo, "packages.html"), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
check(statusTpl.Execute(f, gen)) check(statusTpl.Execute(f, gen))
check(f.Close()) check(f.Close())