fix: Refactor update script for bash interpreter
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Danny Bessems 2023-07-14 15:25:42 +02:00
parent 0af8f2ac5e
commit 2725f36017
1 changed files with 6 additions and 6 deletions

View File

@ -55,7 +55,7 @@ data:
</body>
</html>
update.sh: |
#!/bin/sh
#!/bin/bash
while getopts u: flag
do
@ -75,18 +75,18 @@ data:
do
echo '['$(date "+%Y-%m-%d %H:%M:%S")']' $(curl -ks https://$URL/components | jq length) 'known releases in database'
echo -n $(helm list --all-namespaces --output json | jq -c '.[]') | while IFS= read -r release;
do
APP_NAME=$(echo $release | jq -r '.name')
for entry in $(helm list --all-namespaces --output json | jq -r '.[] | @base64'); do
RELEASE=$(echo $entry | base64 -d)
APP_NAME=$(echo $RELEASE | jq -r '.name')
APP_ID=$(curl -ks https://$URL/components?name=$APP_NAME | jq -r '.[0].id')
# Release is not yet in database
[ "$APP_ID" == null ] && {
curl -ks -X POST https://$URL/components -H 'Content-Type: application/json' --data "$release"
curl -ks -X POST https://$URL/components -H 'Content-Type: application/json' --data "$RELEASE" -o /dev/null
}
# Release is already in database
[ "$APP_ID" != null ] && {
curl -ks -X PATCH https://$URL/components/$APP_ID -H 'Content-Type: application/json' --data "$release"
curl -ks -X PATCH https://$URL/components/$APP_ID -H 'Content-Type: application/json' --data "$RELEASE" -o /dev/null
}
done