commit 3a283e54e1e4b1553ea1560e0a2ce5c73d77a568 Author: dcore94 Date: Fri Sep 30 15:00:58 2022 +0200 First share diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/delete-workflow.sh b/delete-workflow.sh new file mode 100755 index 0000000..31a87c5 --- /dev/null +++ b/delete-workflow.sh @@ -0,0 +1 @@ +curl -X DELETE "http://localhost:8080/api/metadata/workflow/$1" diff --git a/list-workflows.sh b/list-workflows.sh new file mode 100755 index 0000000..bdb71f7 --- /dev/null +++ b/list-workflows.sh @@ -0,0 +1 @@ +curl "http://localhost:8080/api/metadata/workflow" diff --git a/stack-playground.yaml b/stack-playground.yaml new file mode 100644 index 0000000..f7a4406 --- /dev/null +++ b/stack-playground.yaml @@ -0,0 +1,47 @@ +version: '3.6' + +services: + + conductor-server: + image: "orkesio/orkes-conductor-community-standalone:latest" + networks: + - conductor-network + ports: + - "8080:8080" + - "5000:5000" + + workers: + environment: + CONDUCTOR_SERVER: http://conductor-server:8080/api + CONDUCTOR_HEALTH: http://conductor-server:8080/health + worker_plugins: "Shell Eval Mail HttpBridge" + smtp_pass: ${smtp_pass} + image: 'nubisware/nubisware-conductor-worker-py-d4s' + networks: + - conductor-network + deploy: + mode: replicated + replicas: 2 + restart_policy: + condition: any + delay: 5s + window: 120s + + pyrestworkers: + environment: + CONDUCTOR_SERVER: http://conductor-server:8080/api + CONDUCTOR_HEALTH: http://conductor-server:8080/health + worker_plugins: Http + image: 'nubisware/nubisware-conductor-worker-py-d4s' + networks: + - conductor-network + deploy: + mode: replicated + replicas: 2 + restart_policy: + condition: any + delay: 5s + window: 120s + +networks: + conductor-network: diff --git a/upload-workflow.sh b/upload-workflow.sh new file mode 100755 index 0000000..a8a19db --- /dev/null +++ b/upload-workflow.sh @@ -0,0 +1 @@ +curl -X POST "http://localhost:8080/api/metadata/workflow" -d "@workflows/$1.json" -H "Content-Type: application/json" diff --git a/workflows/example_workflow.json b/workflows/example_workflow.json new file mode 100644 index 0000000..12dcbfc --- /dev/null +++ b/workflows/example_workflow.json @@ -0,0 +1,164 @@ +{ + "ownerApp": null, + "createTime": 1664528925940, + "updateTime": 1664532689529, + "createdBy": null, + "updatedBy": null, + "name": "example_workflow", + "description": "Publish to Social pushes on code-repo", + "version": 1, + "tasks": [ + { + "name": "Init_Variables", + "taskReferenceName": "init_variables", + "description": null, + "inputParameters": { + "context": "%2Fgcube%2Fdevsec%2FdevVRE", + "client_id" : "conductor_playground", + "client_secret" : "o..D" + }, + "type": "SET_VARIABLE" + }, + { + "name": "fork_join", + "taskReferenceName": "parallel_execution", + "description": "Fork two parallel flos for demonstration purposes", + "inputParameters": {}, + "type": "FORK_JOIN", + "forkTasks": [ + [ + { + "name": "pyrest", + "taskReferenceName": "auth_info", + "description": null, + "inputParameters": { + "url": "https://accounts.dev.d4science.org/auth/realms/d4science/.well-known/openid-configuration", + "method": "GET", + "headers": { + "Accept": "application/json" + } + }, + "type": "SIMPLE" + }, + { + "name": "pyrest", + "taskReferenceName": "authorize", + "description": null, + "inputParameters": { + "url": "${auth_info.output.body.token_endpoint}", + "method": "POST", + "headers": { + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json" + }, + "body": { + "grant_type": "client_credentials", + "client_id": "${workflow.variables.client_id}", + "client_secret": "${workflow.variables.client_secret}" + } + }, + "type": "SIMPLE" + }, + { + "name": "pyrest", + "taskReferenceName": "token_exchange", + "description": "Exchange playground token for user token", + "inputParameters": { + "url": "${auth_info.output.body.token_endpoint}", + "headers": { + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json" + }, + "body": { + "client_id": "${workflow.variables.client_id}", + "client_secret": "${workflow.variables.client_secret}", + "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", + "requested_subject": "${workflow.input.pusher.username}", + "request_token_type": "urn:ietf:params:oauth:token-type:access_token" + }, + "method": "POST" + }, + "type": "SIMPLE" + }, + { + "name": "pyrest", + "taskReferenceName": "get_uma_ticket", + "description": "Get uma ticket for specific context", + "inputParameters": { + "url": "${auth_info.output.body.token_endpoint}", + "headers": { + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "application/json", + "Authorization": "Bearer ${token_exchange.output.body.access_token}" + }, + "body": { + "grant_type": "urn:ietf:params:oauth:grant-type:uma-ticket", + "audience": "${workflow.variables.context}" + }, + "method": "POST" + }, + "type": "SIMPLE" + } + ], + [ + { + "name": "inline_task", + "taskReferenceName": "prepare_message", + "description": null, + "inputParameters": { + "evaluatorType": "javascript", + "expression": "function e(){ return { 'text' : 'New commit from ' + $.pusher + ' on repo ' + $.repo } }; e()", + "pusher": "${workflow.input.pusher.full_name}", + "repo": "${workflow.input.repository.name}" + }, + "type": "INLINE" + } + ] + ] + }, + { + "name": "my_join", + "taskReferenceName": "my_join", + "inputParameters": {}, + "type": "JOIN", + "joinOn": [ + "get_uma_ticket", + "prepare_message" + ] + }, + { + "name": "pyrest", + "taskReferenceName": "post_social", + "description": "Post to social service", + "inputParameters": { + "url": "https://api.dev.d4science.org/rest/2/posts/write-post-user", + "headers": { + "Content-Type": "application/json", + "Accept": "application/json", + "Authorization": "Bearer ${get_uma_ticket.output.body.access_token}" + }, + "body": { + "text": "${prepare_message.output.result.text}", + "preview_description": "New commit on one CCP repository", + "preview_host": null, + "preview_url": null, + "image_url": "${workflow.input.repository.owner.avatar_url}", + "enable_notification": true + }, + "method": "POST" + }, + "type": "SIMPLE" + } + ], + "inputParameters": [], + "outputParameters": {}, + "failureWorkflow": null, + "schemaVersion": 2, + "restartable": true, + "workflowStatusListenerEnabled": false, + "ownerEmail": "m.lettere@gmail.com", + "timeoutPolicy": "ALERT_ONLY", + "timeoutSeconds": 0, + "variables": {}, + "inputTemplate": {} +}