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

This commit is contained in:
Danny Bessems 2023-07-14 15:25:42 +02:00
parent 0af8f2ac5e
commit 2725f36017

View File

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