First share

This commit is contained in:
dcore94 2022-09-30 15:00:58 +02:00
commit 3a283e54e1
6 changed files with 214 additions and 0 deletions

0
README.md Normal file
View File

1
delete-workflow.sh Executable file
View File

@ -0,0 +1 @@
curl -X DELETE "http://localhost:8080/api/metadata/workflow/$1"

1
list-workflows.sh Executable file
View File

@ -0,0 +1 @@
curl "http://localhost:8080/api/metadata/workflow"

47
stack-playground.yaml Normal file
View File

@ -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:

1
upload-workflow.sh Executable file
View File

@ -0,0 +1 @@
curl -X POST "http://localhost:8080/api/metadata/workflow" -d "@workflows/$1.json" -H "Content-Type: application/json"

View File

@ -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": {}
}