modernized all the ghn workflows

This commit is contained in:
Marco Lettere 2023-10-13 11:24:19 +02:00
parent ab1010c417
commit 900fa993ba
7 changed files with 78 additions and 63 deletions

View File

@ -16,16 +16,16 @@ workflows:
# - create_system_service # - create_system_service
# - delete_system_service # - delete_system_service
# - add_all_system_services_to_vre # - add_all_system_services_to_vre
- create_workspace_client # - create_workspace_client
- 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_context
# - ghn_client_add_to_contexts - ghn_client_add_to_contexts
# - ghn_client_create - ghn_client_create
# - ghn_client_delete - ghn_client_delete
# - ghn_client_remove_from_contexts - ghn_client_remove_from_contexts
# - ghn_client_remove_from_context - ghn_client_remove_from_context
# - jupyterhub_add_serveroptions_to_context # - jupyterhub_add_serveroptions_to_context
# - record_context_to_is # - record_context_to_is
# - create_vre_folder_for_context # - create_vre_folder_for_context

View File

@ -8,15 +8,16 @@
"inputParameters" : ["client_id", "context"], "inputParameters" : ["client_id", "context"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"ctx" : "${workflow.input.context}", "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_context : $.ctx.replaceAll('/', '%2F')}" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){if(e($.id) || e($.ctx)) throw('Client ID and Context must not be empty'); else return { encoded_context : $.ctx.replaceAll('/', '%2F')}} f()"
} }
}, },
{ {
@ -57,12 +58,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "extract_ghn_client", "taskReferenceName": "extract_ghn_client",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"client" : "${lookup_client.output.body}", "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}" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v.length === 0)}; function f(){if(e($.client)) throw('GHN client not found'); else return { client : $.client[0], id : $.client[0].id}} f()"
} }
}, },
{ {
@ -95,12 +97,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "extract_context", "taskReferenceName": "extract_context",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"client" : "${lookup_context.output.body}", "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 }" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v.length === 0)}; function f(){if(e($.client)) throw('Context not found'); else return { client : $.client[0], id: $.client[0].id }} f()"
} }
}, },
{ {

View File

@ -8,24 +8,26 @@
"inputParameters" : ["client_id", "context_list"], "inputParameters" : ["client_id", "context_list"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "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 { }" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){if(e($.id)) throw('Client ID must not be empty'); return { }} f()"
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts", "taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"context_list" : "${workflow.input.context_list}", "context_list" : "${workflow.input.context_list}",
"client_id" : "${workflow.input.client_id}", "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};" "evaluatorType" : "javascript",
"expression": "inputs={},tasks=[];function f(){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};} f()"
} }
}, },
{ {

View File

@ -8,9 +8,9 @@
"inputParameters" : ["client_id", "client_secret", "description", "context_list"], "inputParameters" : ["client_id", "client_secret", "description", "context_list"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"root_vo": "{{ root_vo }}", "root_vo": "{{ root_vo }}",
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
@ -19,7 +19,8 @@
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"secret" : "${workflow.input.client_secret}", "secret" : "${workflow.input.client_secret}",
"description" : "${workflow.input.description}", "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'} }" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){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'}}} f()"
} }
}, },
{ {
@ -60,12 +61,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "extract_client_id", "taskReferenceName": "extract_client_id",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"client_location" : "${create_client.output.headers.location}", "client_location" : "${create_client.output.headers.location}",
"scriptExpression": "var client_id = $.client_location.split('/').pop(); return {'client_resource_id' : client_id}" "evaluatorType" : "javascript",
"expression": "var client_id = $.client_location.split('/').pop(); function f(){return {'client_resource_id' : client_id}} f()"
} }
}, },
{ {
@ -147,13 +149,14 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts", "taskReferenceName": "build_tasks_to_add_ghn_client_to_all_contexts",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"context_list" : "${workflow.input.context_list}", "context_list" : "${workflow.input.context_list}",
"client_id" : "${workflow.input.client_id}", "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};" "evaluatorType" : "javascript",
"expression": "inputs={},tasks=[];function f(){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};} f()"
} }
}, },
{ {

View File

@ -8,14 +8,15 @@
"inputParameters" : ["client_id"], "inputParameters" : ["client_id"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"scriptExpression" : "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.id)) throw('Client ID must not be empty');" "evaluatorType" : "javascript",
"expression" : "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){if(e($.id)) throw('Client ID must not be empty');} f()"
} }
}, },
{ {
@ -50,12 +51,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "check", "taskReferenceName": "check",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"list" : "${lookup_client.output.body}", "evaluatorType" : "javascript",
"scriptExpression" : "if($.list.length === 0 || $.list.length > 1) throw('No client found with client_id or ambiguous query returned multiple clients.')" "list" : "${lookup_client.output.body}",
"expression" : "if($.list.length === 0 || $.list.length > 1) throw('No client found with client_id or ambiguous query returned multiple clients.')"
} }
}, },
{ {

View File

@ -8,15 +8,16 @@
"inputParameters" : ["client_id", "context"], "inputParameters" : ["client_id", "context"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"ctx" : "${workflow.input.context}", "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_context : $.ctx.replaceAll('/', '%2F')}" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){if(e($.id) || e($.ctx)) throw('Client ID and Context must not be empty'); else return { encoded_context : $.ctx.replaceAll('/', '%2F')}} f()"
} }
}, },
{ {
@ -57,12 +58,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "extract_ghn_client", "taskReferenceName": "extract_ghn_client",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"client" : "${lookup_client.output.body}", "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}" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v.length === 0)}; function f(){if(e($.client)) throw('GHN client not found'); else return { client : $.client[0], id : $.client[0].id}} f()"
} }
}, },
{ {
@ -95,12 +97,13 @@
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "extract_context", "taskReferenceName": "extract_context",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"client" : "${lookup_context.output.body}", "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 }" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v.length === 0)}; function f(){if(e($.client)) throw('Context not found'); else return { client : $.client[0], id: $.client[0].id }} f()"
} }
}, },
{ {

View File

@ -8,24 +8,26 @@
"inputParameters" : ["client_id", "context_list"], "inputParameters" : ["client_id", "context_list"],
"tasks" : [ "tasks" : [
{ {
"name": "LAMBDA_TASK", "name": "INLINE_TASK",
"taskReferenceName": "init", "taskReferenceName": "init",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}",
"id" : "${workflow.input.client_id}", "id" : "${workflow.input.client_id}",
"keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", "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 { }" "evaluatorType" : "javascript",
"expression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; function f(){if(e($.id)) throw('Client ID must not be empty'); return { }} f()"
} }
}, },
{ {
"name": "LAMBDA_TASK", "name": "INLINE",
"taskReferenceName": "build_tasks_to_remove_ghn_client_from_all_contexts", "taskReferenceName": "build_tasks_to_remove_ghn_client_from_all_contexts",
"type": "LAMBDA", "type": "INLINE",
"inputParameters": { "inputParameters": {
"context_list" : "${workflow.input.context_list}", "context_list" : "${workflow.input.context_list}",
"client_id" : "${workflow.input.client_id}", "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:'remove_ghn_client_from_context_'+i, subWorkflowParam:{ name:'ghn_client_remove_from_context'}}),inputs['remove_ghn_client_from_context_'+i]={client_id : $.client_id, context: c};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};" "evaluatorType" : "javascript",
"expression": "inputs={},tasks=[]; function f(){for(var i=0;i<$.context_list.length;i++)c=$.context_list[i],tasks.push({name:'sub_workflow_task',type:'SUB_WORKFLOW',taskReferenceName:'remove_ghn_client_from_context_'+i, subWorkflowParam:{ name:'ghn_client_remove_from_context'}}),inputs['remove_ghn_client_from_context_'+i]={client_id : $.client_id, context: c};return {tasks:Java.to(tasks,'java.util.Map[]'),inputs:inputs};} f()"
} }
}, },
{ {