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":
if destinationvalue.lower() in sourcevalue.lower():
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":
try:
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()
workflowExecution, err := getWorkflowExecution(ctx, actionResult.ExecutionId)
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.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Bad authorization key or execution_id might not exist."}`)))
return
@@ -1004,7 +1004,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
}
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{}
childNodes := []string{}
@@ -1016,7 +1016,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
// Finds ALL childnodes to set them to SKIPPED
childNodes = findChildNodes(*workflowExecution, actionResult.Action.ID)
// Remove duplicates
log.Printf("CHILD NODES: %d", len(childNodes))
//log.Printf("CHILD NODES: %d", len(childNodes))
for _, nodeId := range childNodes {
if nodeId == actionResult.Action.ID {
continue
@@ -1290,7 +1290,7 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
}
if _, err = tx.Commit(); err != nil {
if attempts >= 5 {
if attempts >= 7 {
log.Printf("[ERROR] QUITTING: tx.Commit %d: %v", attempts, err)
tx.Rollback()
workflowExecution.Status = "ABORTED"
@@ -1301,7 +1301,9 @@ func runWorkflowExecutionTransaction(ctx context.Context, attempts int64, workfl
return
}
log.Printf("[WARNING] tx.Commit %d: %v", attempts, err)
if attempts > 3 {
log.Printf("[WARNING] tx.Commit %d: %v", attempts, err)
}
attempts += 1
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.
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
err = json.Unmarshal(body, &execution)
if err != nil {
+1 -1
View File
@@ -2,7 +2,7 @@ version: '3'
services:
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
hostname: shuffle-frontend
ports:
+1 -1
View File
@@ -130,7 +130,7 @@ const OrgHeader = (props) => {
return (
<div>
<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()}}>
<input hidden type="file" ref={(ref) => upload = ref} onChange={editHeaderImage} />
{imageInfo}
+5
View File
@@ -4366,6 +4366,11 @@ const AngularWorkflow = (props) => {
setConditionValue(conditionValue)
setVariableAnchorEl(null)
}} 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) => {
conditionValue.value = "matches regex"
setConditionValue(conditionValue)
+1 -1
View File
@@ -106,7 +106,7 @@ func getThisContainerId() {
// cgroup error. Hardcoding this.
// 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") {
containerId = "shuffle-orborus"
//docker-76c537e9a4b7c7233011f5d70e6b7f2d600b6413ac58a96519b8dca7a3f7117a.scope
+37 -8
View File
@@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
//"io"
"io"
"io/ioutil"
"log"
"net/http"
@@ -37,7 +37,7 @@ func getThisContainerId() string {
if err == nil {
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") {
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)
}
// 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)
if err != nil {
// 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)
if err != nil {
log.Printf("[ERROR] Failed deploying image THRICE. 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")
log.Printf("[WARNING] Failed deploying image THRICE. Attempting to download the latter as last resort.")
reader, err := dockercli.ImagePull(context.Background(), image, pullOptions)
if err != nil {
log.Printf("[ERROR] Failed getting %s. The couldn't be find locally, AND is missing.", image)
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)
}
}
}
}
}