Skip to content

Commit

Permalink
gha -add check for Get in Delete func for typed resources (#17882)
Browse files Browse the repository at this point in the history
  • Loading branch information
catriona-m authored Aug 8, 2022
1 parent 10a2ed5 commit 095faad
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/issue-comment-created.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
jobs:
issue_comment_triage:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions-ecosystem/action-remove-labels@v1
with:
Expand All @@ -23,7 +25,7 @@ jobs:
github_token: "${{ secrets.GITHUB_TOKEN }}"
labels: waiting-response
- uses: actions-ecosystem/[email protected]
if: ${{ endsWith(github.event.comment.body, '/wr') }}
if: github.event.issue.pull_request && endsWith(github.event.comment.body, '/wr')
with:
labels: waiting-response
github_token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pull-request-reviewed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
add-waiting-response:
if: github.event.review.state != 'approved' && github.actor != github.event.pull_request.user.login
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions-ecosystem/[email protected]
with:
Expand Down
29 changes: 20 additions & 9 deletions scripts/run-gradually-deprecated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,28 @@ function runGraduallyDeprecatedFunctions {
fi

# check for d.Get inside Delete
deleteFuncName=$(grep -o "Delete: .*," "$f" -m1 | grep -o " .*Delete")
deleteFuncName=$(grep -o "Delete: .*," "$f" -m1 | grep -o " .*Delete"| tr -d " ")
if [ "$deleteFuncName" != "" ];
then
deleteMethod=$(cat -n $f | sed -n -e "/func$deleteFuncName.*$/,/[[:digit:]]*\treturn nil/{ /func$deleteFuncName$/d; /[[:digit:]]*\treturn nil/d; p; }")
foundGet=$(echo "$deleteMethod" | grep "d\.Get(.*)" -m1)
if [ "$foundGet" != "" ];
then
echo "$f $foundGet"
echo "Please do not use 'd.Get' within the Delete function as this does not work as expected in Delete"
exit 1
fi
deleteMethod=$(cat -n $f | sed -n -e "/func $deleteFuncName.*$/,/[[:digit:]]*\treturn nil/{ /func $deleteFuncName$/d; /[[:digit:]]*\treturn nil/d; p; }")
foundGet=$(echo "$deleteMethod" | grep "d\.Get(.*)" -m1)
if [ "$foundGet" != "" ];
then
echo "$f $foundGet"
echo "Please do not use 'd.Get' within the Delete function as this does not work as expected in Delete"
exit 1
fi
else
# check for Get in typed resource
deleteFuncName=" Delete() sdk.ResourceFunc "
deleteMethod=$(cat -n $f | sed -n -e "/$deleteFuncName.*$/,/[[:digit:]]*\t\t\treturn nil/{ /$deleteFuncName.*$/d; /[[:digit:]]*\t\t\treturn nil/d; p; }")
foundGet=$(echo "$deleteMethod" | grep "metadata.ResourceData.Get" -m1)
if [ "$foundGet" != "" ];
then
echo "$f $foundGet"
echo "Please do not use 'metadata.ResourceData.Get' within the Delete function as this does not work as expected in Delete"
exit 1
fi
fi
done
}
Expand Down

0 comments on commit 095faad

Please sign in to comment.