added first ghn workflows
This commit is contained in:
parent
87af670d4f
commit
210482df25
|
@ -10,7 +10,7 @@ workflows:
|
||||||
# - user-group-role_deleted
|
# - user-group-role_deleted
|
||||||
# - delete-user-account
|
# - delete-user-account
|
||||||
# - role_deleted
|
# - role_deleted
|
||||||
- role_created
|
# - role_created
|
||||||
# - add_role_policy_permission
|
# - add_role_policy_permission
|
||||||
# - add_all_member_roles
|
# - add_all_member_roles
|
||||||
# - create_system_service
|
# - create_system_service
|
||||||
|
@ -20,6 +20,10 @@ workflows:
|
||||||
# - add_workspace_client_to_context
|
# - add_workspace_client_to_context
|
||||||
# - enable_workspace_clients_for_context
|
# - enable_workspace_clients_for_context
|
||||||
# - add_workspace_client_to_contexts
|
# - add_workspace_client_to_contexts
|
||||||
|
- ghn_client_add_to_context
|
||||||
|
- ghn_client_add_to_contexts
|
||||||
|
- ghn_client_create
|
||||||
|
|
||||||
keycloak_host: "https://accounts.dev.d4science.org/auth"
|
keycloak_host: "https://accounts.dev.d4science.org/auth"
|
||||||
keycloak: "{{ keycloak_host }}/realms"
|
keycloak: "{{ keycloak_host }}/realms"
|
||||||
keycloak_realm: "d4science"
|
keycloak_realm: "d4science"
|
||||||
|
|
|
@ -0,0 +1,157 @@
|
||||||
|
{
|
||||||
|
"ownerApp" : "Orchestrator",
|
||||||
|
"name" : "ghn_client_add_to_context",
|
||||||
|
"createBy" : "Marco Lettere",
|
||||||
|
"description": "A GHN client is made Member of a context and it's workspace folder is linked to context's shared folder",
|
||||||
|
"version" : 1,
|
||||||
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
||||||
|
"inputParameters" : ["client_id", "context"],
|
||||||
|
"tasks" : [
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "init",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"root_vo": "{{ root_vo }}",
|
||||||
|
"storagehub" : "{{ storagehub }}",
|
||||||
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
|
"id" : "${workflow.input.client_id}",
|
||||||
|
"ctx" : "${workflow.input.context}",
|
||||||
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id) || e($.ctx)) throw('Client ID and Context must not be empty'); else return { encoded_root_vo : encodeURI($.root_vo), encoded_context : $.ctx.replaceAll('/', '%2F')}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "authorize",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "{{ keycloak }}/master/protocol/openid-connect/token",
|
||||||
|
"method" : "POST",
|
||||||
|
"headers" : {
|
||||||
|
"Accept" : "application/json"
|
||||||
|
},
|
||||||
|
"body" : {
|
||||||
|
"client_id" : "orchestrator",
|
||||||
|
"client_secret" : "{{ keycloak_auth_master }}",
|
||||||
|
"grant_type" : "client_credentials"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "fork_join",
|
||||||
|
"taskReferenceName" : "fork1",
|
||||||
|
"type" : "FORK_JOIN",
|
||||||
|
"forkTasks" : [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "lookup_client",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients",
|
||||||
|
"params" : { "clientId" : "${workflow.input.client_id}"},
|
||||||
|
"method" : "GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "extract_ghn_client",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"client" : "${lookup_client.output.body}",
|
||||||
|
"scriptExpression": "function e(v){ return (v.length === 0)}; if(e($.client)) throw('GHN client not found'); else return { client : $.client[0], id : $.client[0].id}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "get_service_account_user",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients/${extract_ghn_client.output.result.id}/service-account-user",
|
||||||
|
"method" : "GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "lookup_context",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients",
|
||||||
|
"params" : { "clientId" : "${init.output.result.encoded_context}"},
|
||||||
|
"method" : "GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "extract_context",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"client" : "${lookup_context.output.body}",
|
||||||
|
"scriptExpression": "function e(v){ return (v.length === 0)}; if(e($.client)) throw('Context not found'); else return { client : $.client[0], id: $.client[0].id }"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"taskReferenceName": "retrieve_member_role",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients/${extract_context.output.result.id}/roles/Member",
|
||||||
|
"method" :"GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jq_1",
|
||||||
|
"taskReferenceName": "roles_to_assign",
|
||||||
|
"type": "JSON_JQ_TRANSFORM",
|
||||||
|
"inputParameters": {
|
||||||
|
"role": "${retrieve_member_role.output.body}",
|
||||||
|
"queryExpression" : ".role"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "join",
|
||||||
|
"taskReferenceName": "join1",
|
||||||
|
"type": "JOIN",
|
||||||
|
"joinOn": [
|
||||||
|
"get_service_account_user"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"taskReferenceName": "assign_member_role",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/users/${get_ghn_account_user.output.body.id}/role-mappings/clients/${retrieve_member_role.output.body.containerId}",
|
||||||
|
"method" :"POST",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Content-Type" : "application/json",
|
||||||
|
"Accept":"application/json"
|
||||||
|
},
|
||||||
|
"body" : "${roles_to_assign.output.resultList}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
{
|
||||||
|
"ownerApp" : "Orchestrator",
|
||||||
|
"name" : "ghn_client_add_to_contexts",
|
||||||
|
"createBy" : "Marco Lettere",
|
||||||
|
"description": "A client for a GHN is made Member of all the contexts passed as input by calling the ghn_client_add_to_context sub-workflow",
|
||||||
|
"version" : 1,
|
||||||
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
||||||
|
"inputParameters" : ["client_id", "context_list"],
|
||||||
|
"tasks" : [
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "init",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"root_vo": "{{ root_vo }}",
|
||||||
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
|
"id" : "${workflow.input.client_id}",
|
||||||
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id)) throw('Client ID must not be empty'); return { }"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"context_list" : "${workflow.input.context_list}",
|
||||||
|
"client_id" : "${workflow.input.client_id}",
|
||||||
|
"scriptExpression": "inputs={},tasks=[];for(var i=0;i<$.context_list.length;i++)c=$.context_list[i],tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'add_ghn_client_to_context_'+i, subWorkflowParam:{ name:'ghn_client_add_to_context'}}),inputs['add_ghn_client_to_context_'+i]={client_id : $.client_id, context: c};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "fork_dynamic",
|
||||||
|
"type" : "FORK_JOIN_DYNAMIC",
|
||||||
|
"taskReferenceName" : "parallel_build_tasks_to_add_ghn_client_to_all_contexts",
|
||||||
|
"inputParameters" : {
|
||||||
|
"tasks" : "${build_tasks_to_add_ghn_client_to_all_contexts.output.result.tasks}",
|
||||||
|
"inputs" : "${build_tasks_to_add_ghn_client_to_all_contexts.output.result.inputs}"
|
||||||
|
},
|
||||||
|
"dynamicForkTasksParam": "tasks",
|
||||||
|
"dynamicForkTasksInputParamName": "inputs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "join",
|
||||||
|
"type" : "JOIN",
|
||||||
|
"taskReferenceName" : "join_build_tasks_to_add_ghn_client_to_all_contexts"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,177 @@
|
||||||
|
{
|
||||||
|
"ownerApp" : "Orchestrator",
|
||||||
|
"name" : "ghn_create_client",
|
||||||
|
"createBy" : "Marco Lettere",
|
||||||
|
"description": "Create a client on IAM to represent SmartGears based GHNodes",
|
||||||
|
"version" : 1,
|
||||||
|
"ownerEmail" : "marco.lettere@nubisware.com",
|
||||||
|
"inputParameters" : ["client_id", "client_secret", "description", "context_list"],
|
||||||
|
"tasks" : [
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "init",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"root_vo": "{{ root_vo }}",
|
||||||
|
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
|
||||||
|
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
|
||||||
|
"storagehub" : "{{ storagehub }}",
|
||||||
|
"id" : "${workflow.input.client_id}",
|
||||||
|
"secret" : "${workflow.input.client_secret}",
|
||||||
|
"description" : "${workflow.input.description}",
|
||||||
|
"scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id)) throw('Client ID must not be empty'); return { encoded_root_vo : encodeURI($.root_vo), client : { clientId : $.id, description : ($.description ? $.description : $.id), secret : ($.secret ? $.secret : Java.type('java.util.UUID').randomUUID().toString()), rootUrl : '', enabled : true, serviceAccountsEnabled : true, standardFlowEnabled : true, authorizationServicesEnabled : false, publicClient : false, fullScopeAllowed : true, protocol : 'openid-connect'} }"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "authorize",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak}/protocol/openid-connect/token",
|
||||||
|
"method" : "POST",
|
||||||
|
"headers" : {
|
||||||
|
"Accept" : "application/json"
|
||||||
|
},
|
||||||
|
"body" : {
|
||||||
|
"client_id" : "orchestrator",
|
||||||
|
"client_secret" : "{{ keycloak_auth }}",
|
||||||
|
"grant_type" : "client_credentials"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "fork_join",
|
||||||
|
"taskReferenceName" : "fork1",
|
||||||
|
"type" : "FORK_JOIN",
|
||||||
|
"forkTasks" : [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "create_client",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients",
|
||||||
|
"body" : "${init.output.result.client}",
|
||||||
|
"method" : "POST",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Content-Type" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "extract_client_id",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"client_location" : "${create_client.output.headers.location}",
|
||||||
|
"scriptExpression": "var client_id = $.client_location.split('/').pop(); return {'client_resource_id' : client_id}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "get_service_account_user",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients/${extract_client_id.output.result.client_resource_id}/service-account-user",
|
||||||
|
"method" : "GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "get_rootvo",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients?clientId=${init.output.result.encoded_root_vo}",
|
||||||
|
"method" : "GET",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"taskReferenceName" : "get_rootvo_member_role",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/clients/${get_rootvo.output.body[0].id}/roles/Member",
|
||||||
|
"method" : "GET",
|
||||||
|
"expect" : [200, 404],
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Accept" : "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "join",
|
||||||
|
"taskReferenceName": "join1",
|
||||||
|
"type": "JOIN",
|
||||||
|
"joinOn": [
|
||||||
|
"get_service_account_user",
|
||||||
|
"get_rootvo_member_role"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jq_1",
|
||||||
|
"taskReferenceName": "to_array",
|
||||||
|
"type": "JSON_JQ_TRANSFORM",
|
||||||
|
"inputParameters": {
|
||||||
|
"role": "${get_rootvo_member_role.output.body}",
|
||||||
|
"queryExpression" : ".role"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "pyrest",
|
||||||
|
"type" : "SIMPLE",
|
||||||
|
"taskReferenceName": "assign_member_role",
|
||||||
|
"inputParameters" : {
|
||||||
|
"url" : "${init.input.keycloak_admin}/users/${get_service_account_user.output.body.id}/role-mappings/clients/${get_rootvo_member_role.output.body.containerId}",
|
||||||
|
"method" :"POST",
|
||||||
|
"headers" : {
|
||||||
|
"Authorization" : "Bearer ${authorize.output.body.access_token}",
|
||||||
|
"Content-Type" : "application/json",
|
||||||
|
"Accept":"application/json"
|
||||||
|
},
|
||||||
|
"body" : "${to_array.output.resultList}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAMBDA_TASK",
|
||||||
|
"taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts",
|
||||||
|
"type": "LAMBDA",
|
||||||
|
"inputParameters": {
|
||||||
|
"context_list" : "${workflow.input.context_list}",
|
||||||
|
"client_id" : "${workflow.input.client_id}",
|
||||||
|
"scriptExpression": "inputs={},tasks=[];for(var i=0;i<$.context_list.length;i++)c=$.context_list[i],tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'add_ghn_client_to_context_'+i, subWorkflowParam:{ name:'ghn_client_add_to_context'}}),inputs['add_ghn_client_to_context_'+i]={client_id : $.client_id, context: c};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "fork_dynamic",
|
||||||
|
"type" : "FORK_JOIN_DYNAMIC",
|
||||||
|
"taskReferenceName" : "parallel_build_tasks_to_add_ghn_client_to_all_contexts",
|
||||||
|
"inputParameters" : {
|
||||||
|
"tasks" : "${build_tasks_to_add_ghn_client_to_all_contexts.output.result.tasks}",
|
||||||
|
"inputs" : "${build_tasks_to_add_ghn_client_to_all_contexts.output.result.inputs}"
|
||||||
|
},
|
||||||
|
"dynamicForkTasksParam": "tasks",
|
||||||
|
"dynamicForkTasksInputParamName": "inputs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "join",
|
||||||
|
"type" : "JOIN",
|
||||||
|
"taskReferenceName" : "join_build_tasks_to_add_ghn_client_to_all_contexts"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue