Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checking for deprecation resources #266

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:
KUBE_RELEASE=$(curl -L -H "Accept: aplication/vnd.github+json" https://api.github.com/repos/kubernetes/kubernetes/releases/latest)
echo "kube-latest=$(echo ${KUBE_RELEASE} | jq -r '.tag_name')" >> "$GITHUB_ENV"

- name: start minikube
id: minikube
uses: medyagh/setup-minikube@latest
with:
cpus: 2
memory: 6500m
kubernetes-version: ${{ env.kube-latest }}

- name: Setup pluto
run: |
wget https://github.com/FairwindsOps/pluto/releases/download/v${PLUTO_VER}/pluto_${PLUTO_VER}_linux_amd64.tar.gz
Expand Down Expand Up @@ -78,25 +86,40 @@ jobs:
--target-versions k8s=${{ env.kube-latest }} \
-ojson)

DEPRECATED=$(echo ${RESULT_JSON} | jq -r '.items[] | select ( .deprecated==true and .removed==false ).name' | paste -sd, || true)
REMOVED=$(echo ${RESULT_JSON} | jq -r '.items[] | select ( .removed==true ).name' | paste -sd, || true)
DEPRECATED_API=$(echo ${RESULT_JSON} | jq -r '.items[] | select ( .deprecated==true and .removed==false ).name' | paste -sd, || true)
REMOVED_API=$(echo ${RESULT_JSON} | jq -r '.items[] | select ( .removed==true ).name' | paste -sd, || true)

helm template -f values.yaml . ${KEYS} \
| pluto detect - --ignore-deprecations \
--ignore-removals \
--target-versions k8s=${{ env.kube-latest }} \
-omarkdown

if [ "${REMOVED}" != "" ]; then
#############################################
## Check deprecated recources in manifests ##
#############################################

helm template -f ./values.yaml . ${KEYS} > deprecate-check.yaml
kubectl --dry-run=server --warnings-as-errors apply -f ./deprecate-check.yaml >out.log 2>&1 || true
DEPRECATED_REC=$(awk '/Warning/{print}' out.log)

if [ "${DEPRECATED_REC}" != "" ]; then
echo "::error title=Warning message from k8s api detected,line=1,col=5,endColumn=7::"${DEPRECATED_REC}""
EXIT_CODE=1
fi

if [ "${REMOVED_API}" != "" ]; then
echo "::error title=Removed api detected!,line=1,col=5,endColumn=7::\
Api for this resources: ${REMOVED} will be removed. Target version: ${{ env.kube-latest }} \
Api for this resources: ${REMOVED_API} will be removed. Target version: ${{ env.kube-latest }} \
Please check log and get more information"
exit 1
EXIT_CODE=1
fi

if [ "${DEPRECATED}" != "" ]; then
if [ "${DEPRECATED_API}" != "" ]; then
echo "::warning title=Deprecated api detected,line=1,col=5,endColumn=7::\
Api for this recources: ${DEPRECATED} will be deprecated. Target version: ${{ env.kube-latest }} \
Api for this recources: ${DEPRECATED_API} will be deprecated. Target version: ${{ env.kube-latest }} \
Please check log and get move information"
exit 0
EXIT_CODE=1
fi

exit ${EXIT_CODE}