From 7f086fe4685a22f519e83dcbb9d4aae8e097129e Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Wed, 11 May 2022 21:12:14 +0800 Subject: [PATCH] doc-update --- antidote-cis | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/antidote-cis b/antidote-cis index c45277c..3143919 100755 --- a/antidote-cis +++ b/antidote-cis @@ -1,5 +1,4 @@ #!/bin/bash -# Warning: all variable assignments in function should be changed to local variable. Don't learn from me! (I'm lazy) _self_bin_name="$0" function where_is_him () { @@ -130,12 +129,15 @@ function _select_param_and_create_json_impl () { [[ "$kv" == "$prefix"* ]] && requiredParam_val="${kv:${#prefix}}" && requiredParam_val="${requiredParam_val/\\/\\\\}" # The backslash in json must be escaped. done [[ "$requiredParam_val" = "" ]] && echo2 "Note: workflow parameter $requiredParam has an empty value." - echo -n "${result_param_string}\"$requiredParam\":\"$requiredParam_val\"," + echo -n "\"$requiredParam\":\"$requiredParam_val\"," done } function assemble_workflow_parameters () { # Use variable $cis_default_workflow_parameter, query workflow parameter list, and fill them. # The tail of array variable $cis_default_workflow_parameter has higher preference (because params from command line are appended after tail) + # + # returns incomplete json text in stdout, like this: + # "param1":"val1","param2":"val2", workflow_name="$1" params_query_response=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/JobTypeDefinition/$cis_namespace" | json2table WorkflowDefinitions/InputParameters,Name -p | grep "|$workflow_name|" | cut -d '|' -f 1` || ! echo2 "Failed to get Workflow definition for workflow $workflow_name" || return $? [[ "$params_query_response" = "[]" ]] && params="" || params=`echo "$params_query_response" | json2table Name -p | sed 's/VAL: //g' | grep -oE '[A-Za-z0-9_-]+'` || ! echo2 "Failed to get Workflow definition for workflow $workflow_name" || return $? @@ -144,16 +146,20 @@ function assemble_workflow_parameters () { } function assemble_runtime_settings () { # Use variable $cis_default_workflow_parameter, query runtime settings list, and fill them. - # TODO: Many runtime settings have default value, I'll append them into the front of cis_default_workflow_parameter in the FUTURE! + # TODO: Many runtime settings have default value, I want to load them into cis_default_workflow_parameter automatically in the FUTURE! # The tail of array variable $cis_default_workflow_parameter has higher preference (because params from command line are appended after tail) + # + # returns incomplete json text in stdout, like this: + # "param1":"val1","param2":"val2", - # runtime_settings are related to namespace, so we don't need workflow_name. (We're adding an '@' to all param name here) + # runtime_settings are only related to namespace, so we don't need workflow_name. (We're adding an '@' to all param name here) params=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/JobTypeDefinition/$cis_namespace" | json2table GlobalSettings/Name -p | sed 's/VAL: /@/g' | tr -d '|'` || ! echo2 "Failed to get runtime settings for namespace $cis_namespace" || return $? echo "$params" | _select_param_and_create_json_impl | tr -d @ } function cis_run_job () { + # returns job_id in stdout. workflow_name="$1" release_ver="$2" echo2 "Submitting request to create $workflow_name:$release_ver..." @@ -190,6 +196,7 @@ function cis_run_job () { function cis_get_job_status () { # Argument should be job_id of *root* workflow. (not child workflow!) + # Returns job summary in stdout. jobid="$1" getjobhierarchy_apires=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/$cis_namespace/GenericJob/$jobid/GetJobHierarchy"` && subworkflows_text=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus,JobType -p` || ! echo2 "API GetJobHierarchy failed" || return $? -- GitLab