Feature: Added contains_any_of to conditions

This commit is contained in:
frikky
2020-12-24 07:35:27 +01:00
parent 8a99fb6048
commit c2cf104700
7 changed files with 69 additions and 17 deletions
+16
View File
@@ -1127,6 +1127,22 @@ class AppBase:
elif check.lower() == "contains": elif check.lower() == "contains":
if destinationvalue.lower() in sourcevalue.lower(): if destinationvalue.lower() in sourcevalue.lower():
return True return True
elif check.lower() == "contains_any_of":
newvalue = [destinationvalue.lower()]
if "," in destinationvalue:
newvalue = destinationvalue.split(",")
elif ", " in destinationvalue:
newvalue = destinationvalue.split(", ")
for item in new_value:
if not item:
continue
if item.trim() in sourcevalue:
print("[INFO] Found %s in %s" % (item, sourcevalue))
return True
return False
elif check.lower() == "larger than": elif check.lower() == "larger than":
try: try:
if sourcevalue.isdigit() and destinationvalue.isdigit(): if sourcevalue.isdigit() and destinationvalue.isdigit():
+8 -6
View File
@@ -785,7 +785,7 @@ func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) {
ctx := context.Background() ctx := context.Background()
workflowExecution, err := getWorkflowExecution(ctx, actionResult.ExecutionId) workflowExecution, err := getWorkflowExecution(ctx, actionResult.ExecutionId)
if err != nil { if err != nil {
log.Printf("Failed getting execution (streamresult) %s: %s", actionResult.ExecutionId, err) //log.Printf("Failed getting execution (streamresult) %s: %s", actionResult.ExecutionId, err)
resp.WriteHeader(401) resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`))) resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`)))
return return
@@ -1004,7 +1004,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
} }
if actionResult.Status == "ABORTED" || actionResult.Status == "FAILURE" { if actionResult.Status == "ABORTED" || actionResult.Status == "FAILURE" {
log.Printf("Actionresult is %s. Should set workflowExecution and exit all running functions", actionResult.Status) log.Printf("[WARNING] Actionresult is %s. Should set workflowExecution and exit all running functions", actionResult.Status)
newResults := []ActionResult{} newResults := []ActionResult{}
childNodes := []string{} childNodes := []string{}
@@ -1016,7 +1016,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
// Finds ALL childnodes to set them to SKIPPED // Finds ALL childnodes to set them to SKIPPED
childNodes = findChildNodes(*workflowExecution, actionResult.Action.ID) childNodes = findChildNodes(*workflowExecution, actionResult.Action.ID)
// Remove duplicates // Remove duplicates
log.Printf("CHILD NODES: %d", len(childNodes)) //log.Printf("CHILD NODES: %d", len(childNodes))
for _, nodeId := range childNodes { for _, nodeId := range childNodes {
if nodeId == actionResult.Action.ID { if nodeId == actionResult.Action.ID {
continue continue
@@ -1290,7 +1290,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
} }
if _, err = tx.Commit(); err != nil { if _, err = tx.Commit(); err != nil {
if attempts >= 5 { if attempts >= 7 {
log.Printf("[ERROR] QUITTING: tx.Commit %d: %v", attempts, err) log.Printf("[ERROR] QUITTING: tx.Commit %d: %v", attempts, err)
tx.Rollback() tx.Rollback()
workflowExecution.Status = "ABORTED" workflowExecution.Status = "ABORTED"
@@ -1301,7 +1301,9 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
return return
} }
log.Printf("[WARNING] tx.Commit %d: %v", attempts, err) if attempts > 3 {
log.Printf("[WARNING] tx.Commit %d: %v", attempts, err)
}
attempts += 1 attempts += 1
runWorkflowExecutionTransaction(ctx, attempts, workflowExecutionId, actionResult, resp) runWorkflowExecutionTransaction(ctx, attempts, workflowExecutionId, actionResult, resp)
@@ -2604,7 +2606,7 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
} }
// This one doesn't really matter. // This one doesn't really matter.
log.Printf("Running POST execution with data %s", body) log.Printf("Running POST execution with body of length %d", len(string(body)))
var execution ExecutionRequest var execution ExecutionRequest
err = json.Unmarshal(body, &execution) err = json.Unmarshal(body, &execution)
if err != nil { if err != nil {
+1 -1
View File
@@ -2,7 +2,7 @@ version: '3'
services: services:
frontend: frontend:
#build: ./frontend #build: ./frontend
image: ghcr.io/frikky/shuffle-frontend:0.8.42 image: ghcr.io/frikky/shuffle-frontend:0.8.43
container_name: shuffle-frontend container_name: shuffle-frontend
hostname: shuffle-frontend hostname: shuffle-frontend
ports: ports:
+1 -1
View File
@@ -130,7 +130,7 @@ const OrgHeader = (props) => {
return ( return (
<div> <div>
<div style={{color: "white", flex: "1", display: "flex", flexDirection: "row"}}> <div style={{color: "white", flex: "1", display: "flex", flexDirection: "row"}}>
<Tooltip title="Click to edit the app's image - 174x174" placement="bottom"> <Tooltip title="Click to edit the organizations's image (174x174)" placement="bottom">
<div style={{flex: "1", margin: "10px 25px 10px 0px", border: imageData !== undefined && imageData.length > 0 ? null : "1px solid #f85a3e", cursor: "pointer", backgroundColor: imageData !== undefined && imageData.length > 0 ? null : theme.palette.inputColor, maxWidth: 174, maxHeight: 174}} onClick={() => {upload.click()}}> <div style={{flex: "1", margin: "10px 25px 10px 0px", border: imageData !== undefined && imageData.length > 0 ? null : "1px solid #f85a3e", cursor: "pointer", backgroundColor: imageData !== undefined && imageData.length > 0 ? null : theme.palette.inputColor, maxWidth: 174, maxHeight: 174}} onClick={() => {upload.click()}}>
<input hidden type="file" ref={(ref) => upload = ref} onChange={editHeaderImage} /> <input hidden type="file" ref={(ref) => upload = ref} onChange={editHeaderImage} />
{imageInfo} {imageInfo}
+5
View File
@@ -4366,6 +4366,11 @@ const AngularWorkflow = (props) => {
setConditionValue(conditionValue) setConditionValue(conditionValue)
setVariableAnchorEl(null) setVariableAnchorEl(null)
}} key={"contains"}>contains</MenuItem> }} key={"contains"}>contains</MenuItem>
<MenuItem style={menuItemStyle} onClick={(e) => {
conditionValue.value = "contains_any_of"
setConditionValue(conditionValue)
setVariableAnchorEl(null)
}} key={"contains_any_of"}>contains</MenuItem>
<MenuItem style={menuItemStyle} onClick={(e) => { <MenuItem style={menuItemStyle} onClick={(e) => {
conditionValue.value = "matches regex" conditionValue.value = "matches regex"
setConditionValue(conditionValue) setConditionValue(conditionValue)
+1 -1
View File
@@ -106,7 +106,7 @@ func getThisContainerId() {
// cgroup error. Hardcoding this. // cgroup error. Hardcoding this.
// https://github.com/moby/moby/issues/7015 // https://github.com/moby/moby/issues/7015
log.Printf("Checking if %s is in %s", ".scope", string(out)) //log.Printf("Checking if %s is in %s", ".scope", string(out))
if strings.Contains(string(out), ".scope") { if strings.Contains(string(out), ".scope") {
containerId = "shuffle-orborus" containerId = "shuffle-orborus"
//docker-76c537e9a4b7c7233011f5d70e6b7f2d600b6413ac58a96519b8dca7a3f7117a.scope //docker-76c537e9a4b7c7233011f5d70e6b7f2d600b6413ac58a96519b8dca7a3f7117a.scope
+37 -8
View File
@@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
//"io" "io"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@@ -37,7 +37,7 @@ func getThisContainerId() string {
if err == nil { if err == nil {
id = strings.TrimSpace(string(out)) id = strings.TrimSpace(string(out))
log.Printf("Checking if %s is in %s", ".scope", string(out)) //log.Printf("Checking if %s is in %s", ".scope", string(out))
if strings.Contains(string(out), ".scope") { if strings.Contains(string(out), ".scope") {
id = fallbackName id = fallbackName
} }
@@ -1370,7 +1370,12 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
log.Printf("Skipping FULL_EXECUTION because size is larger than %d", maxSize) log.Printf("Skipping FULL_EXECUTION because size is larger than %d", maxSize)
} }
// Try original -> Go to lowercase // Uses a few ways of getting / checking if an app is available
// 1. Try original
// 2. Go to lowercase
// 3. Add remote repo location
// 4. Actually download last repo
err = deployApp(dockercli, image, identifier, env) err = deployApp(dockercli, image, identifier, env)
if err != nil { if err != nil {
// Trying to replace with lowercase to deploy again. This seems to work with Dockerhub well. // Trying to replace with lowercase to deploy again. This seems to work with Dockerhub well.
@@ -1389,13 +1394,37 @@ func handleExecution(client *http.Client, req *http.Request, workflowExecution W
err = deployApp(dockercli, image, identifier, env) err = deployApp(dockercli, image, identifier, env)
if err != nil { if err != nil {
log.Printf("[WARNING] Failed deploying image THRICE. Attempting to download the latter as last resort.")
log.Printf("[ERROR] Failed deploying image THRICE. Aborting if the image doesn't exist") reader, err := dockercli.ImagePull(context.Background(), image, pullOptions)
if strings.Contains(err.Error(), "No such image") { if err != nil {
//log.Printf("[WARNING] Failed deploying %s from image %s: %s", identifier, image, err) log.Printf("[ERROR] Failed getting %s. The couldn't be find locally, AND is missing.", image)
log.Printf("[ERROR] Image doesn't exist. Shutting down")
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID) shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
} }
buildBuf := new(strings.Builder)
_, err = io.Copy(buildBuf, reader)
if err != nil {
log.Printf("[ERROR] Error in IO copy: %s", err)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
} else {
if strings.Contains(buildBuf.String(), "errorDetail") {
log.Printf("[ERROR] Docker build:\n%s\nERROR ABOVE: Trying to pull tags from: %s", buildBuf.String(), image)
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
log.Printf("[INFO] Successfully downloaded %s", image)
}
err = deployApp(dockercli, image, identifier, env)
if err != nil {
log.Printf("[ERROR] Failed deploying image for the FOURTH time. Aborting if the image doesn't exist")
if strings.Contains(err.Error(), "No such image") {
//log.Printf("[WARNING] Failed deploying %s from image %s: %s", identifier, image, err)
log.Printf("[ERROR] Image doesn't exist. Shutting down")
shutdown(workflowExecution.ExecutionId, workflowExecution.Workflow.ID)
}
}
} }
} }
} }