From 79bb7c86251db6685a44ec8081eaa01906504e9d Mon Sep 17 00:00:00 2001 From: chrischristiansen-glitch Date: Sat, 23 May 2026 07:57:49 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20cost-audit.sh=20=E2=80=94=20Artifact=20R?= =?UTF-8?q?egistry=20sizeBytes=20float-safe=20via=20awk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/cost-audit.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cost-audit.sh b/scripts/cost-audit.sh index 833245f..f708e6c 100644 --- a/scripts/cost-audit.sh +++ b/scripts/cost-audit.sh @@ -46,7 +46,6 @@ if [[ -z "$CR" ]]; then printf " ${OK} No services deployed\n" else while IFS=$'\t' read -r NAME URL; do - # Check min-instances annotation MIN=$(gcloud run services describe "$NAME" \ --project="${PROJECT_ID}" --region="${REGION}" \ --format="value(spec.template.metadata.annotations.'autoscaling.knative.dev/minScale')" \ @@ -176,8 +175,9 @@ if [[ -z "$REPOS" ]]; then printf " ${OK} No Artifact Registry repos\n" else while IFS=$'\t' read -r NAME FMT SIZE; do - SIZE_MB=$(( ${SIZE:-0} / 1048576 )) - printf " ${OK} %-28s fmt:%-8s size:${SIZE_MB}MB\n" "$NAME" "$FMT" + # sizeBytes kan være float (f.eks. 345900.5) — bruk awk for sikker MB-konvertering + SIZE_MB=$(awk -v s="${SIZE:-0}" 'BEGIN { printf "%.1f", s / 1048576 }') + printf " ${OK} %-28s fmt:%-8s size:${SIZE_MB} MB\n" "$NAME" "$FMT" done <<< "$REPOS" fi echo ""