From 8788558cf17a6fc29489ea9257b95fde9e6459f4 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 21 Sep 2023 10:58:17 +0200 Subject: [PATCH] fix: only sync version label once Closes https://git.coopcloud.tech/coop-cloud/organising/issues/492 --- pkg/compose/compose.go | 2 +- tests/integration/recipe_sync.bats | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/compose/compose.go b/pkg/compose/compose.go index 6d9a1913..3fd98191 100644 --- a/pkg/compose/compose.go +++ b/pkg/compose/compose.go @@ -122,7 +122,7 @@ func UpdateLabel(pattern, serviceName, label, recipeName string) error { discovered := false for oldLabel, value := range service.Deploy.Labels { - if strings.HasPrefix(oldLabel, "coop-cloud") { + if strings.HasPrefix(oldLabel, "coop-cloud") && strings.Contains(oldLabel, "version") { discovered = true bytes, err := ioutil.ReadFile(composeFile) diff --git a/tests/integration/recipe_sync.bats b/tests/integration/recipe_sync.bats index a4d338ee..7b29f035 100644 --- a/tests/integration/recipe_sync.bats +++ b/tests/integration/recipe_sync.bats @@ -111,3 +111,19 @@ setup(){ assert_success assert_output --partial '[new tag]' } + +@test "output label sync only once" { + run $ABRA recipe upgrade "$TEST_RECIPE" --no-input --minor + assert_success + + run git -C "$ABRA_DIR/recipes/$TEST_RECIPE" diff + assert_success + assert_output --regexp 'image: nginx:1.2.*' + + run $ABRA recipe sync "$TEST_RECIPE" --no-input --minor + assert_success + assert_line --index 0 --partial 'synced label' + refute_line --index 1 --partial 'synced label' + + _checkout_recipe +}