Skip to content

Commit

Permalink
Fix infra swf output: must be in result object
Browse files Browse the repository at this point in the history
Signed-off-by: gabriel-farache <[email protected]>
  • Loading branch information
gabriel-farache committed Nov 5, 2024
1 parent c9c972b commit 1e86b45
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 112 deletions.
32 changes: 19 additions & 13 deletions create-ocp-project/create-ocp-project.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,33 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "Project " + .projectName + " active",
"outputs":[]
"result": {
"completedWith":"success",
"message": "Project " + .projectName + " active",
"outputs":[]
}
}'
- name: errorProjectNotActiveResult
type: expression
operation: '{
"completedWith":"error",
"message": "Project " + .projectName + " not active"
"result": {
"completedWith":"error",
"message": "Project " + .projectName + " not active"
}
}'
- name: errorAuthorizationDeniedResult
type: expression
operation: '{
"completedWith":"error",
"message": "Creation of project " + .projectName + " denied",
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .operationsProjectKey + "/issues/" + .operationsJiraCreateIssueResult.key,
"format":"link"
}]
"result": {
"completedWith":"error",
"message": "Creation of project " + .projectName + " denied",
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .operationsProjectKey + "/issues/" + .operationsJiraCreateIssueResult.key,
"format":"link"
}]
}
}'
start: "[Audit]: workflow started"
states:
Expand Down
26 changes: 14 additions & 12 deletions extendable-workflow/extendable-workflow.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "Extendable workflow completed successfully",
"outputs":[
{
"key":"Selected language",
"value": .languageInfo.language
},
{
"key":"Greeting message",
"value": .greeting
}
]
"result": {
"completedWith":"success",
"message": "Extendable workflow completed successfully",
"outputs":[
{
"key":"Selected language",
"value": .languageInfo.language
},
{
"key":"Greeting message",
"value": .greeting
}
]
}
}'
states:
- name: ChooseOnLanguage
Expand Down
26 changes: 14 additions & 12 deletions greeting/greeting.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "Greeting workflow completed successfully",
"outputs":[
{
"key":"Selected language",
"value": .language
},
{
"key":"Greeting message",
"value": .greeting
}
]
"result": {
"completedWith":"success",
"message": "Greeting workflow completed successfully",
"outputs":[
{
"key":"Selected language",
"value": .language
},
{
"key":"Greeting message",
"value": .greeting
}
]
}
}'
states:
- name: ChooseOnLanguage
Expand Down
44 changes: 25 additions & 19 deletions modify-vm-resources/modify-vm-resources.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,39 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "VM" + .vm_name + " in namespace " + .vm_namespace + " updated.",
"outputs":[
{
"key":"Console URL",
"value": $SECRET.cluster_console_url + "/k8s/ns/" + .vm_namespace + "/kubevirt.io~v1~VirtualMachine/" + .vm_name + "/console/standalone",
"format":"link"
}
]
"result": {
"completedWith":"success",
"message": "VM" + .vm_name + " in namespace " + .vm_namespace + " updated.",
"outputs":[
{
"key":"Console URL",
"value": $SECRET.cluster_console_url + "/k8s/ns/" + .vm_namespace + "/kubevirt.io~v1~VirtualMachine/" + .vm_name + "/console/standalone",
"format":"link"
}
]
}
}'
- name: errorVMNotRunningResult
type: expression
operation: '{
"completedWith":"error",
"message": "VM" + .vm_name + " in namespace " + .vm_namespace + " not ready after the update after checking" + .vmStatusRunningRetries + " times: " + .vm.status
"result": {
"completedWith":"error",
"message": "VM" + .vm_name + " in namespace " + .vm_namespace + " not ready after the update after checking" + .vmStatusRunningRetries + " times: " + .vm.status
}
}'
- name: errorAuthorizationDeniedResult
type: expression
operation: '{
"completedWith":"error",
"message": "Authorization denied to update VM " + .vm_name + " in namespace " + .vm_namespace + ". Memory: " + .vm_new_memory + ". CPU cores: " + (.vm_new_cpu_cores|tostring) + ". CPU threads: " + (.vm_new_cpu_threads|tostring) + ". CPU sockets: " + (.vm_new_cpu_sockets|tostring),
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .projectKey + "/issues/" + .jiraCreateIssueResult.key,
"format":"link"
}]
"result": {
"completedWith":"error",
"message": "Authorization denied to update VM " + .vm_name + " in namespace " + .vm_namespace + ". Memory: " + .vm_new_memory + ". CPU cores: " + (.vm_new_cpu_cores|tostring) + ". CPU threads: " + (.vm_new_cpu_threads|tostring) + ". CPU sockets: " + (.vm_new_cpu_sockets|tostring),
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .projectKey + "/issues/" + .jiraCreateIssueResult.key,
"format":"link"
}]
}
}'
start: Get VM
states:
Expand Down
56 changes: 30 additions & 26 deletions move2kube/m2k.sw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,40 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " was successful; the output is available in the branch " + .targetBranch + " of your git repository "+ .repositoryURL,
"outputs": [
{
"key":"Git repository",
"value": .repositoryURL,
"format":"link"
},
{
"key":"Git branch",
"value": .targetBranch
}
]
"result": {
"completedWith":"success",
"message": "Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " was successful; the output is available in the branch " + .targetBranch + " of your git repository "+ .repositoryURL,
"outputs": [
{
"key":"Git repository",
"value": .repositoryURL,
"format":"link"
},
{
"key":"Git branch",
"value": .targetBranch
}
]
}
}'
- name: errorResult
type: expression
operation: '{
"completedWith":"error",
"message": "Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " failed ",
"outputs":[
{
"key":"Exit message",
"value": .exitMessage
},
{
"key":"Plan retries",
"value": (.planRetries|tostring),
"format":"number"
}
]
"result": {
"completedWith":"error",
"message": "Move2Kube workflow " + $WORKFLOW.instanceId + " on workspace " + .workspaceId + " and project " + .projectId + " failed ",
"outputs":[
{
"key":"Exit message",
"value": .exitMessage
},
{
"key":"Plan retries",
"value": (.planRetries|tostring),
"format":"number"
}
]
}
}'
states:
- name: StartPlanning
Expand Down
26 changes: 15 additions & 11 deletions mtv-migration/mtv.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "MTV migration " + .migrationName + " succeeded",
"outputs":[]
"result": {
"completedWith":"success",
"message": "MTV migration " + .migrationName + " succeeded",
"outputs":[]
}
}'
- name: errorResult
type: expression
operation: '{
"completedWith":"error",
"message": "MTV migration " + .migrationName + " failed.",
"outputs":[
{
"key":"Error",
"value": .migrationErrorMessage
}
]
"result": {
"completedWith":"error",
"message": "MTV migration " + .migrationName + " failed.",
"outputs":[
{
"key":"Error",
"value": .migrationErrorMessage
}
]
}
}'
states:
- name: CreateMigration
Expand Down
44 changes: 25 additions & 19 deletions request-vm-cnv/request-vm-cnv.sw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,39 @@ functions:
- name: successResult
type: expression
operation: '{
"completedWith":"success",
"message": "VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image +" ready and running.",
"outputs":[
{
"key":"Console URL",
"value": $SECRET.cluster_console_url + "/k8s/ns/" + .vm_namespace + "/kubevirt.io~v1~VirtualMachine/" + .vm_name + "/console/standalone",
"format":"link"
}
]
"result": {
"completedWith":"success",
"message": "VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image +" ready and running.",
"outputs":[
{
"key":"Console URL",
"value": $SECRET.cluster_console_url + "/k8s/ns/" + .vm_namespace + "/kubevirt.io~v1~VirtualMachine/" + .vm_name + "/console/standalone",
"format":"link"
}
]
}
}'
- name: errorVMNotRunningResult
type: expression
operation: '{
"completedWith":"error",
"message": "VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image +" not ready after "+ .vmStatusRunningRetries + " retries: " + .vm.status
"result": {
"completedWith":"error",
"message": "VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image +" not ready after "+ .vmStatusRunningRetries + " retries: " + .vm.status
}
}'
- name: errorAuthorizationDeniedResult
type: expression
operation: '{
"completedWith":"error",
"message": "Authorization denied to create VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image,
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .projectKey + "/issues/" + .jiraCreateIssueResult.key,
"format":"link"
}]
"result": {
"completedWith":"error",
"message": "Authorization denied to create VM" + .vm_name + " in namespace "+.vm_namespace + " using image "+ .vm_image,
"outputs":[
{
"key":"Jira issue",
"value": $SECRET.jira_url + "/jira/servicedesk/projects/" + .projectKey + "/issues/" + .jiraCreateIssueResult.key,
"format":"link"
}]
}
}'
start: Open issue on JIRA
states:
Expand Down

0 comments on commit 1e86b45

Please sign in to comment.