Added appcreator autocomplete feature for GET {PATH}

This commit is contained in:
frikky
2021-01-23 17:04:52 +01:00
parent 9b1f7fdce6
commit 5dd78211d4
4 changed files with 121 additions and 60 deletions
+2 -2
View File
@@ -3306,7 +3306,7 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
if len(action.Label) == 0 {
action.Label = action.ID
}
log.Printf("LABEL: %s", action.Label)
//log.Printf("LABEL: %s", action.Label)
newActions = append(newActions, action)
// If the node is NOT found, it's supposed to be set to SKIPPED,
@@ -3360,7 +3360,7 @@ func handleExecution(id string, workflow Workflow, request *http.Request) (Workf
}
for _, trigger := range workflowExecution.Workflow.Triggers {
log.Printf("[INFO] ID: %s vs %s", trigger.ID, workflowExecution.Start)
//log.Printf("[INFO] ID: %s vs %s", trigger.ID, workflowExecution.Start)
if trigger.ID == workflowExecution.Start {
if trigger.AppName == "User Input" {
startFound = true
+19 -5
View File
@@ -1784,7 +1784,20 @@ const AppCreator = (props) => {
}}
onBlur={event => {
var parsedurl = event.target.value
if (parsedurl.startsWith("curl")) {
if (parsedurl.startsWith("PUT ") || parsedurl.startsWith("GET ") ||parsedurl.startsWith("POST ") || parsedurl.startsWith("DELETE ") ||parsedurl.startsWith("PATCH ") || parsedurl.startsWith("CONNECT ")) {
const tmp = parsedurl.split(" ")
if (tmp.length > 1) {
parsedurl = tmp[1]
setActionField("url", parsedurl)
setUrlPath(parsedurl)
setCurrentActionMethod(tmp[0].toUpperCase())
setActionField("method", tmp[0].toUpperCase())
}
setUpdate(Math.random())
} else if (parsedurl.startsWith("curl")) {
const request = parseCurl(event.target.value)
if (request !== event.target.value) {
if (request.method.toUpperCase() !== currentAction.Method) {
@@ -1819,7 +1832,8 @@ const AppCreator = (props) => {
}
}
if (parsedurl !== undefined) {
console.log("PARSED: ", parsedurl)
if (parsedurl !== undefined) {
if (parsedurl.includes("<") && parsedurl.includes(">")) {
parsedurl = parsedurl.split("<").join("{")
parsedurl = parsedurl.split(">").join("}")
@@ -1920,9 +1934,9 @@ const AppCreator = (props) => {
Cancel
</Button>
<Button color="primary" variant="outlined" style={{borderRadius: "0px"}} onClick={() => {
console.log(urlPathQueries)
console.log(urlPath)
console.log(currentAction)
//console.log(urlPathQueries)
//console.log(urlPath)
//console.log(currentAction)
const errors = getActionErrors()
addActionToView(errors)
setActionsModalOpen(false)
+1 -1
View File
@@ -1,5 +1,5 @@
NAME=shuffle-worker
VERSION=0.8.54
VERSION=0.8.56
echo "Running docker build with $NAME:$VERSION"
#CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o worker.bin .
+99 -52
View File
@@ -774,22 +774,24 @@ func shutdown(executionId, workflowId string) {
// Might not be necessary because of cleanupEnv hostconfig autoremoval
if cleanupEnv == "true" && len(containerIds) > 0 {
ctx := context.Background()
dockercli, err := dockerclient.NewEnvClient()
if err == nil {
log.Printf("[INFO] Cleaning up %d containers", len(containerIds))
removeOptions := types.ContainerRemoveOptions{
RemoveVolumes: true,
Force: true,
}
/*
ctx := context.Background()
dockercli, err := dockerclient.NewEnvClient()
if err == nil {
log.Printf("[INFO] Cleaning up %d containers", len(containerIds))
removeOptions := types.ContainerRemoveOptions{
RemoveVolumes: true,
Force: true,
}
for _, containername := range containerIds {
log.Printf("[INFO] Stopping and removing container %s", containername)
dockercli.ContainerStop(ctx, containername, nil)
dockercli.ContainerRemove(ctx, containername, removeOptions)
//removeContainers = append(removeContainers, containername)
for _, containername := range containerIds {
log.Printf("[INFO] Should stop and and remove container %s (deprecated)", containername)
//dockercli.ContainerStop(ctx, containername, nil)
//dockercli.ContainerRemove(ctx, containername, removeOptions)
//removeContainers = append(removeContainers, containername)
}
}
}
*/
} else {
log.Printf("[INFO] NOT cleaning up containers. IDS: %d, CLEANUP env: %s", len(containerIds), cleanupEnv)
}
@@ -866,9 +868,9 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
}
// Removing because log extraction should happen first
//if cleanupEnv == "true" {
// hostConfig.AutoRemove = true
//}
if cleanupEnv == "true" {
hostConfig.AutoRemove = true
}
config := &container.Config{
Image: image,
@@ -885,7 +887,7 @@ func deployApp(cli *dockerclient.Client, image string, identifier string, env []
)
if err != nil {
log.Printf("Container CREATE error: %s", err)
log.Printf("[WARNING] Container CREATE error: %s", err)
return err
}
@@ -1481,55 +1483,100 @@ func handleExecutionResult(workflowExecution WorkflowExecution) {
// 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.
// FIXME: Should try to remotely download directly if this persists.
image = fmt.Sprintf("%s:%s_%s", baseimagename, strings.ToLower(action.AppName), action.AppVersion)
if strings.Contains(image, " ") {
image = strings.ReplaceAll(image, " ", "-")
}
images := []string{
fmt.Sprintf("%s/%s:%s_%s", registryName, baseimagename, strings.ToLower(action.AppName), action.AppVersion),
image,
fmt.Sprintf("%s:%s_%s", baseimagename, strings.ToLower(action.AppName), action.AppVersion),
}
// If cleanup is set, it should run for efficiency
pullOptions := types.ImagePullOptions{}
if cleanupEnv == "true" {
err = deployApp(dockercli, images[0], identifier, env)
if err != nil {
log.Printf("[WARNING] Failed CLEANUP execution. Downloading image remotely.")
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)
}
}
}
} else {
pullOptions := types.ImagePullOptions{}
err = deployApp(dockercli, image, identifier, env)
if err != nil {
image = fmt.Sprintf("%s/%s:%s_%s", registryName, baseimagename, strings.ToLower(action.AppName), action.AppVersion)
// Trying to replace with lowercase to deploy again. This seems to work with Dockerhub well.
// FIXME: Should try to remotely download directly if this persists.
image = fmt.Sprintf("%s:%s_%s", baseimagename, strings.ToLower(action.AppName), action.AppVersion)
if strings.Contains(image, " ") {
image = strings.ReplaceAll(image, " ", "-")
}
err = deployApp(dockercli, image, identifier, env)
if err != nil {
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)
image = fmt.Sprintf("%s/%s:%s_%s", registryName, baseimagename, strings.ToLower(action.AppName), action.AppVersion)
if strings.Contains(image, " ") {
image = strings.ReplaceAll(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")
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)
}
}
}
}
}