-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CTOOLS-294: add oneOf fix for workflow
- Loading branch information
1 parent
1d5ba75
commit e2cd97d
Showing
7 changed files
with
156 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC2089 | ||
|
||
set -eETuo pipefail | ||
|
||
failure() { | ||
local lineno="$1" | ||
local msg="$2" | ||
echo "Failed at $lineno: $msg" | ||
} | ||
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR | ||
|
||
file=$1 | ||
find=$2 | ||
replace=$3 | ||
|
||
# need the GNU version of sed on a mac | ||
if [[ $(uname) == Darwin ]]; then | ||
if gsed --version > /dev/null; then | ||
shopt -s expand_aliases | ||
alias sed=gsed | ||
else | ||
echo "GNU sed required for this script, please add it. See https://formulae.brew.sh/formula/gnu-sed" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# check file exists | ||
if ! [[ -f $file ]]; then | ||
echo "expected file '$file' does not exist - unable to carry out fix for one of" | ||
exit 1 | ||
fi | ||
|
||
# 1. fix if statement | ||
if_statement_text_to_replace="if value not in ($find):" | ||
|
||
# check that the expected text exists in the file | ||
if ! grep -q "$if_statement_text_to_replace" "$file"; then | ||
echo "did not find expected text '$if_statement_text_to_replace' in file '$file' - unable to carry out fix for one of" | ||
exit 1 | ||
fi | ||
# make the replacement | ||
if ! sed -i "s/$if_statement_text_to_replace/if not value == $replace:/" "$file"; then | ||
echo "error updating file '$file' for one of fix" | ||
exit 1 | ||
fi | ||
|
||
# 2. fix if statement error message | ||
error_msg_text_to_replace="raise ValueError(\"must be one of enum values ($find)\")" | ||
|
||
# check that the expected text exists in the file | ||
if ! grep -q "$error_msg_text_to_replace" "$file"; then | ||
echo "did not find expected text '$error_msg_text_to_replace' in file '$file' - unable to carry out fix for one of" | ||
exit 1 | ||
fi | ||
# make the replacement | ||
if ! sed -i "s/$error_msg_text_to_replace/raise ValueError(\"must be one of enum values ($replace)\")/" "$file"; then | ||
echo "error updating file '$file' for one of fix" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -eETuo pipefail | ||
|
||
failure() { | ||
local lineno="$1" | ||
local msg="$2" | ||
echo "Failed at $lineno: $msg" | ||
} | ||
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR | ||
|
||
justfile_dir=$1 | ||
package_name=$2 | ||
application=$3 | ||
|
||
while read -r item; do | ||
# echo "item='$item'" | ||
file="$(echo "$item" | jq -r '.file')" | ||
find="$(echo "$item" | jq -r '.find')" | ||
replace="$(echo "$item" | jq -r '.replace')" | ||
bash "$justfile_dir/generate/fix-file-for-one-of.sh" "$justfile_dir/generate/.output/sdk/$package_name/models/$file.py" "$find" "$replace" | ||
done <<< "$(jq -rc '.items[]' "$justfile_dir/generate/$application-one-of-fix-list.json")" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"file": "amazon_sqs_notification_type", | ||
"find": "'AmazonSqs', 'AmazonSqsPrincipalAuth', 'AzureServiceBus', 'Email', 'Sms', 'Webhook'", | ||
"replace": "'AmazonSqs'" | ||
}, | ||
{ | ||
"file": "amazon_sqs_notification_type_response", | ||
"find": "'AmazonSqs', 'AmazonSqsPrincipalAuth', 'AzureServiceBus', 'Email', 'Sms', 'Webhook'", | ||
"replace": "'AmazonSqs'" | ||
}, | ||
{ | ||
"file": "amazon_sqs_principal_auth_notification_type", | ||
"find": "'AmazonSqsPrincipalAuth'", | ||
"replace": "'AmazonSqsPrincipalAuth'" | ||
}, | ||
{ | ||
"file": "amazon_sqs_principal_auth_notification_type_response", | ||
"find": "'AmazonSqsPrincipalAuth'", | ||
"replace": "'AmazonSqsPrincipalAuth'" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"file": "create_child_tasks_action", | ||
"find": "'CreateChildTasks', 'RunWorker', 'TriggerParentTask'", | ||
"replace": "'CreateChildTasks'" | ||
}, | ||
{ | ||
"file": "create_child_tasks_action_response", | ||
"find": "'CreateChildTasks', 'RunWorker', 'TriggerParentTask'", | ||
"replace": "'CreateChildTasks'" | ||
}, | ||
{ | ||
"file": "fail", | ||
"find": "'Fail', 'HealthCheck', 'LuminesceView', 'SchedulerJob', 'Sleep'", | ||
"replace": "'Fail'" | ||
}, | ||
{ | ||
"file": "fail_response", | ||
"find": "'Fail', 'HealthCheck', 'LuminesceView', 'SchedulerJob', 'Sleep'", | ||
"replace": "'Fail'" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters