Skip to content

Commit

Permalink
Reverted save code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlord committed Nov 10, 2023
1 parent 370cd49 commit 1519ca7
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fun Application.configureRouting() {
} else {
call.respondText(text = "$descriptionFile does not exist", status = HttpStatusCode.NotFound)
logger.debug("404: pipeline/${call.parameters["descriptionPath"]}/get")
}
}
}

post("/{type}/{descriptionPath}/run") {
Expand Down Expand Up @@ -182,7 +182,7 @@ fun Application.configureRouting() {
logger.debug("run: ${it.message}")
}
}

get("/{type}/{id}/outputs") {
// type: The value pipeline of script is for api consistency, it makes no real difference for this API call.
val id = call.parameters["id"]!!
Expand All @@ -200,7 +200,7 @@ fun Application.configureRouting() {
call.respond(pipeline.getLiveOutput().mapKeys { it.key.replace('/', FILE_SEPARATOR) })
}
}

get("/{type}/{id}/stop") {
val id = call.parameters["id"]!!
runningPipelines[id]?.let { pipeline ->
Expand Down Expand Up @@ -230,13 +230,11 @@ fun Application.configureRouting() {
post("/pipeline/save/{filename}") {
// TODO: Disallow on server. Env var?

val pipelineFolder = File("pipelines")
val fileName = call.parameters["filename"]!!
val filename = call.parameters["filename"]!!
val pipelineContent = call.receive<String>()

val file = File(pipelinesRoot, "$filename.json")

// TODO: Validate json integrity
val fileNameWithoutExtension = fileName.removeSuffix(".json").removeSuffix(".yml")
val file = File(pipelineFolder, "$fileNameWithoutExtension.json")
// TODO: Validate pipeline integrity

try {
Expand All @@ -246,6 +244,7 @@ fun Application.configureRouting() {
logger.warn(ex.message)
call.respondText(text = "Failed to save pipeline.", status = HttpStatusCode.BadRequest)
}

call.respond(HttpStatusCode.OK)
}
}
Expand Down

0 comments on commit 1519ca7

Please sign in to comment.