GET /api/project/<project-name> endpoint.

This commit is contained in:
Jonathan Bernard 2017-11-20 20:18:17 -06:00
parent f222d859e6
commit 7aa0a69215
3 changed files with 37 additions and 5 deletions

View File

@ -204,8 +204,7 @@ proc parseRunRequest*(reqJson: JsonNode): RunRequest =
proc `%`*(s: BuildStatus): JsonNode =
result = %* {
"state": s.state,
"details": s.details
}
"details": s.details }
proc `%`*(p: ProjectDef): JsonNode =
result = %* {
@ -217,6 +216,26 @@ proc `%`*(p: ProjectDef): JsonNode =
result["envVars"] = newJObject()
for k, v in p.envVars: result["envVars"][k] = %v
proc `%`*(s: Step): JsonNode =
result = %* {
"name": s.name,
"stepCmd": s.stepCmd,
"workingDir": s.workingDir,
"artifacts": s.artifacts,
"cmdInput": s.cmdInput,
"depends": s.depends,
"expectedEnv": s.expectedEnv,
"dontSkip": s.dontSkip }
proc `%`*(p: ProjectConfig): JsonNode =
result = %* {
"name": p.name,
"versionCmd": p.versionCmd }
result["steps"] = newJObject()
for name, step in p.steps:
result["steps"][name] = %step
proc `%`*(req: RunRequest): JsonNode =
result = %* {
"projectName": req.projectName,

View File

@ -245,9 +245,9 @@ proc start*(cfg: StrawBossConfig): void =
var respObj = newJObject()
respObj["definition"] = %projDef
#if projConf.isSome():
# let pc: ProjectConfig = projConf.get()
# respObj["configuration"] = %pc
if projConf.isSome():
let pc: ProjectConfig = projConf.get()
respObj["configuration"] = %pc
resp($respObj, JSON)

View File

@ -124,6 +124,19 @@ suite "load and save configuration objects":
let cfgStr = $cfg
check cfg == parseStrawBossConfig(parseJson(cfgStr))
test "%step":
let step = Step(
name: "build", stepCmd: "true", workingDir: "dirA",
artifacts: @[], depends: @["compile"], cmdInput: @[],
expectedEnv: @["CWD", "TERM"], dontSkip: true)
let stepJS = %step
for k in @["name", "stepCmd", "workingDir", "artifacts", "cmdInput",
"depends", "expectedEnv", "dontSkip"]:
check stepJS.hasKey(k)
test "loadBuildStatus":
let st = loadBuildStatus("src/test/json/test-status.json")