1
0
mirror of https://github.com/google/nomulus synced 2026-01-03 11:45:39 +00:00

Correctly delete all stopped versions except for the most recent 3 (#1511)

The gcloud command does some weird stuff with sorting when custom format
is used. Here we instead rely on linux sort and head command to sort the
versions list.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1511)
<!-- Reviewable:end -->
This commit is contained in:
Lai Jiang
2022-02-03 16:04:58 -05:00
committed by GitHub
parent e2bd72a74e
commit fa9b784c5c

View File

@@ -52,8 +52,8 @@ steps:
do
for version in $(gcloud app versions list \
--filter="SERVICE:$service AND SERVING_STATUS:STOPPED" \
--sort-by=LAST_DEPLOYED --format="value(VERSION.ID)" \
--project=$project_id | head -n -3)
--format="value(VERSION.ID,LAST_DEPLOYED)" \
--project=$project_id | sort -k 2 | head -n -3)
do
gcloud app versions delete $version --service=$service \
--project=$project_id --quiet;