fix: Refactor update script for bash interpreter
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
0af8f2ac5e
commit
2725f36017
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user