diff --git a/admin_store.go b/admin_store.go index f869465..cb0d60e 100644 --- a/admin_store.go +++ b/admin_store.go @@ -68,6 +68,10 @@ func cloneHook(src hook.Hook) hook.Hook { if src.HTTPMethods != nil { dst.HTTPMethods = append([]string(nil), src.HTTPMethods...) } + if src.MaxConcurrency != nil { + value := *src.MaxConcurrency + dst.MaxConcurrency = &value + } return dst } @@ -250,6 +254,7 @@ func normalizeAdminHook(current hook.Hook) hook.Hook { current.ID = strings.TrimSpace(current.ID) current.ExecuteCommand = strings.TrimSpace(current.ExecuteCommand) current.CommandWorkingDirectory = strings.TrimSpace(current.CommandWorkingDirectory) + current.CommandTimeout = strings.TrimSpace(current.CommandTimeout) current.ResponseMessage = strings.TrimSpace(current.ResponseMessage) if len(current.HTTPMethods) != 0 { @@ -275,6 +280,9 @@ func upsertHookInFile(path, currentID string, updated hook.Hook) error { if updated.ID == "" { return errors.New("hook id is required") } + if err := updated.ValidateExecutionSettings(); err != nil { + return err + } loadedHooksMu.Lock() defer loadedHooksMu.Unlock() diff --git a/adminui/assets/app.js b/adminui/assets/app.js index de7010d..5b4012b 100644 --- a/adminui/assets/app.js +++ b/adminui/assets/app.js @@ -62,11 +62,13 @@ hookId: byId("hookId"), executeCommand: byId("executeCommand"), commandWorkingDirectory: byId("commandWorkingDirectory"), + commandTimeout: byId("commandTimeout"), httpMethods: byId("httpMethods"), responseMessage: byId("responseMessage"), incomingPayloadContentType: byId("incomingPayloadContentType"), successHttpResponseCode: byId("successHttpResponseCode"), triggerRuleMismatchHttpResponseCode: byId("triggerRuleMismatchHttpResponseCode"), + maxConcurrency: byId("maxConcurrency"), captureCommandOutput: byId("captureCommandOutput"), captureCommandOutputOnError: byId("captureCommandOutputOnError"), triggerSignatureSoftFailures: byId("triggerSignatureSoftFailures"), @@ -183,6 +185,7 @@ id: "", "execute-command": "", "command-working-directory": "", + "command-timeout": "", "response-message": "", "http-methods": ["POST"] }); @@ -743,11 +746,13 @@ setFormValue(els.hookId, hook.id); setFormValue(els.executeCommand, hook["execute-command"]); setFormValue(els.commandWorkingDirectory, hook["command-working-directory"]); + setFormValue(els.commandTimeout, hook["command-timeout"]); setFormValue(els.httpMethods, normalizeArray(hook["http-methods"]).join(", ")); setFormValue(els.responseMessage, hook["response-message"]); setFormValue(els.incomingPayloadContentType, hook["incoming-payload-content-type"]); setFormValue(els.successHttpResponseCode, hook["success-http-response-code"] || ""); setFormValue(els.triggerRuleMismatchHttpResponseCode, hook["trigger-rule-mismatch-http-response-code"] || ""); + setFormValue(els.maxConcurrency, hook["max-concurrency"] === 0 ? "0" : (hook["max-concurrency"] || "")); els.captureCommandOutput.checked = !!hook["include-command-output-in-response"]; els.captureCommandOutputOnError.checked = !!hook["include-command-output-in-response-on-error"]; @@ -988,6 +993,11 @@ hook["command-working-directory"] = workingDirectory; } + var commandTimeout = inputValue(els.commandTimeout); + if (commandTimeout) { + hook["command-timeout"] = commandTimeout; + } + var methods = splitCSV(els.httpMethods.value); if (methods.length) { hook["http-methods"] = methods; @@ -1013,6 +1023,11 @@ hook["trigger-rule-mismatch-http-response-code"] = mismatchCode; } + var maxConcurrency = parseOptionalInt(els.maxConcurrency.value, "Max Concurrency", errors); + if (maxConcurrency !== null) { + hook["max-concurrency"] = maxConcurrency; + } + if (els.captureCommandOutput.checked) { hook["include-command-output-in-response"] = true; } @@ -1172,11 +1187,13 @@ els.hookId, els.executeCommand, els.commandWorkingDirectory, + els.commandTimeout, els.httpMethods, els.responseMessage, els.incomingPayloadContentType, els.successHttpResponseCode, - els.triggerRuleMismatchHttpResponseCode + els.triggerRuleMismatchHttpResponseCode, + els.maxConcurrency ].forEach(function (input) { input.addEventListener("input", updatePreview); }); diff --git a/adminui/index.html b/adminui/index.html index 4f888ed..f4e684e 100644 --- a/adminui/index.html +++ b/adminui/index.html @@ -88,6 +88,10 @@ +
+ + +
@@ -117,6 +121,10 @@
+
+ + +