added check to discourage execution requests with empty ccpimage when container based infra

This commit is contained in:
dcore94 2024-10-15 13:01:12 +02:00
parent 74c2819de8
commit 224206adf7
1 changed files with 14 additions and 0 deletions

View File

@ -31,6 +31,7 @@ class CCPExecutionForm extends HTMLElement {
"err_load_method": "Error while loading method", "err_load_method": "Error while loading method",
"err_no_runtimes": "This method has no compatible runtimes available", "err_no_runtimes": "This method has no compatible runtimes available",
"err_execute": "Error while sending execution request", "err_execute": "Error while sending execution request",
"container_based_warning_confirm" : "The compatible architectures appear to be container based but no ccpimage input has been specified. This could cause errors that can be unpredictable on some infrastructures. Do you want to proceed anyway?"
} }
} }
@ -244,6 +245,19 @@ class CCPExecutionForm extends HTMLElement {
this.lockRender() this.lockRender()
const url = this.#serviceurl + "/processes/" + this.#method + "/execution" const url = this.#serviceurl + "/processes/" + this.#method + "/execution"
const req = this.buildRequest() const req = this.buildRequest()
// Perform preliminary check on the possibility of infra being container based and ccpimage missing
if(!req.inputs["ccpimage"]){
const reg = /docker|lxd/i
const containerbased =
this.#data.links.filter(l=>l.rel === "compatibleWith").
reduce((acc, l)=>{ return acc && (l.title.match(reg) || l.href.match(reg) ? true : false)}, true)
if(containerbased && !window.confirm(this.getLabel("container_based_warning_confirm"))){
this.unlockRender()
return;
}
}
this.#boot.secureFetch( this.#boot.secureFetch(
url, { method: "POST", body: JSON.stringify(req), headers: { "Content-Type": "application/json" } } url, { method: "POST", body: JSON.stringify(req), headers: { "Content-Type": "application/json" } }
).then(reply => { ).then(reply => {