WIP Moving back towards using named runs.
* Rename artifactsRepo -> buildDataDir to be more explicit about the fact that it holds more than just the artifacts. * Revert removal of run ids. * Move Worker definition into core as part of making the core responsible for accepting run requests. * Make the core module more responsible for internal details of data structure and storage. External callers should not need to construct paths to artifacts, versions, etc. but should be able to call method in the core module to do this work for them. * The working directory no longer contains anything but the checked-out code. All StrawBoss-specific data is stored by StrawBoss elsewhere. * Add a regular maintenance cycle to the server module.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import cliutils, logging, json, os, nre, sequtils, strtabs, tables, times
|
||||
import cliutils, logging, json, os, nre, sequtils, strtabs, tables, times, uuids
|
||||
|
||||
from langutils import sameContents
|
||||
from typeinfo import toAny
|
||||
@ -7,7 +7,7 @@ from typeinfo import toAny
|
||||
#
|
||||
type
|
||||
BuildStatus* = object
|
||||
state*, details*: string
|
||||
runId*, state*, details*: string
|
||||
|
||||
Step* = object
|
||||
name*, stepCmd*, workingDir*: string
|
||||
@ -24,6 +24,7 @@ type
|
||||
envVars*: StringTableRef
|
||||
|
||||
RunRequest* = object
|
||||
id*: UUID
|
||||
projectName*, stepName*, buildRef*, workspaceDir*: string
|
||||
forceRebuild*: bool
|
||||
|
||||
@ -34,7 +35,7 @@ type
|
||||
UserRef* = ref User
|
||||
|
||||
StrawBossConfig* = object
|
||||
artifactsRepo*: string
|
||||
buildDataDir*: string
|
||||
authSecret*: string
|
||||
filePath*: string
|
||||
debug*: bool
|
||||
@ -60,7 +61,7 @@ proc `==`*(a, b: ProjectDef): bool =
|
||||
|
||||
proc `==`*(a, b: StrawBossConfig): bool =
|
||||
result =
|
||||
a.artifactsRepo == b.artifactsRepo and
|
||||
a.buildDataDir == b.buildDataDir and
|
||||
a.authSecret == b.authSecret and
|
||||
a.pwdCost == b.pwdCost and
|
||||
sameContents(a.users, b.users) and
|
||||
@ -68,6 +69,7 @@ proc `==`*(a, b: StrawBossConfig): bool =
|
||||
|
||||
proc `==`*(a, b: RunRequest): bool =
|
||||
result =
|
||||
a.id == b.id and
|
||||
a.projectName == b.projectName and
|
||||
a.stepName == b.stepName and
|
||||
a.buildRef == b.buildRef and
|
||||
@ -130,7 +132,7 @@ proc parseStrawBossConfig*(jsonCfg: JsonNode): StrawBossConfig =
|
||||
hashedPwd: uJson.getOrFail("hashedPwd", "user record").getStr))
|
||||
|
||||
result = StrawBossConfig(
|
||||
artifactsRepo: jsonCfg.getIfExists("artifactsRepo").getStr("artifacts"),
|
||||
buildDataDir: jsonCfg.getIfExists("buildDataDir").getStr("build-data"),
|
||||
authSecret: jsonCfg.getOrFail("authSecret", "strawboss config").getStr,
|
||||
debug: jsonCfg.getIfExists("debug").getBVal(false),
|
||||
pwdCost: int8(jsonCfg.getOrFail("pwdCost", "strawboss config").getNum),
|
||||
@ -189,11 +191,13 @@ proc loadBuildStatus*(statusFile: string): BuildStatus =
|
||||
let jsonObj = parseFile(statusFile)
|
||||
|
||||
result = BuildStatus(
|
||||
runId: jsonObj.getOrFail("runId", "run ID").getStr,
|
||||
state: jsonObj.getOrFail("state", "build status").getStr,
|
||||
details: jsonObj.getIfExists("details").getStr("") )
|
||||
|
||||
proc parseRunRequest*(reqJson: JsonNode): RunRequest =
|
||||
result = RunRequest(
|
||||
id: parseUUID(reqJson.getOrFail("id", "RunRequest").getStr),
|
||||
projectName: reqJson.getOrFail("projectName", "RunRequest").getStr,
|
||||
stepName: reqJson.getOrFail("stepName", "RunRequest").getStr,
|
||||
buildRef: reqJson.getOrFail("buildRef", "RunRequest").getStr,
|
||||
@ -203,6 +207,7 @@ proc parseRunRequest*(reqJson: JsonNode): RunRequest =
|
||||
# TODO: can we use the marshal module for this?
|
||||
proc `%`*(s: BuildStatus): JsonNode =
|
||||
result = %* {
|
||||
"runId": s.runId,
|
||||
"state": s.state,
|
||||
"details": s.details }
|
||||
|
||||
@ -238,6 +243,7 @@ proc `%`*(p: ProjectConfig): JsonNode =
|
||||
|
||||
proc `%`*(req: RunRequest): JsonNode =
|
||||
result = %* {
|
||||
"id": $(req.id),
|
||||
"projectName": req.projectName,
|
||||
"stepName": req.stepName,
|
||||
"buildRef": req.buildRef,
|
||||
@ -251,7 +257,7 @@ proc `%`*(user: User): JsonNode =
|
||||
|
||||
proc `%`*(cfg: StrawBossConfig): JsonNode =
|
||||
result = %* {
|
||||
"artifactsRepo": cfg.artifactsRepo,
|
||||
"buildDataDir": cfg.buildDataDir,
|
||||
"authSecret": cfg.authSecret,
|
||||
"debug": cfg.debug,
|
||||
"projects": %cfg.projects,
|
||||
|
Reference in New Issue
Block a user