Skip to content

Commit 4b8abba

Browse files
committed
fix: SGDistributedLogs set version without patch number in generated SGCluster
1 parent d7f2786 commit 4b8abba

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

stackgres-k8s/src/operator/src/main/java/io/stackgres/operator/conciliation/factory/distributedlogs/DistributedLogsCluster.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.List;
1414
import java.util.Map;
1515
import java.util.Optional;
16+
import java.util.Set;
17+
import java.util.stream.Collectors;
1618
import java.util.stream.Stream;
1719

1820
import io.fabric8.kubernetes.api.model.ConfigMapVolumeSourceBuilder;
@@ -109,9 +111,14 @@ public static StackGresCluster getCluster(
109111
previousCluster
110112
.map(StackGresCluster::getMetadata)
111113
.map(ObjectMeta::getAnnotations)
112-
.orElseGet(() -> Map.of(
113-
StackGresContext.VERSION_KEY,
114-
StackGresVersion.getStackGresVersion(distributedLogs).getVersion())))
114+
.orElseGet(() -> Optional.of(distributedLogs)
115+
.map(StackGresDistributedLogs::getMetadata)
116+
.map(ObjectMeta::getAnnotations)
117+
.map(Map::entrySet)
118+
.stream()
119+
.flatMap(Set::stream)
120+
.filter(annotation -> annotation.getKey().equals(StackGresContext.VERSION_KEY))
121+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))))
115122
.withLabels(labelFactory.genericLabels(distributedLogs))
116123
.withNamespace(namespace)
117124
.withName(name)

stackgres-k8s/src/operator/src/main/java/io/stackgres/operator/conciliation/factory/distributedlogs/v14/DistributedLogsCluster.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.List;
1414
import java.util.Map;
1515
import java.util.Optional;
16+
import java.util.Set;
17+
import java.util.stream.Collectors;
1618
import java.util.stream.Stream;
1719

1820
import io.fabric8.kubernetes.api.model.ConfigMapVolumeSourceBuilder;
@@ -108,9 +110,14 @@ public static StackGresCluster getCluster(
108110
previousCluster
109111
.map(StackGresCluster::getMetadata)
110112
.map(ObjectMeta::getAnnotations)
111-
.orElseGet(() -> Map.of(
112-
StackGresContext.VERSION_KEY,
113-
StackGresVersion.getStackGresVersion(distributedLogs).getVersion())))
113+
.orElseGet(() -> Optional.of(distributedLogs)
114+
.map(StackGresDistributedLogs::getMetadata)
115+
.map(ObjectMeta::getAnnotations)
116+
.map(Map::entrySet)
117+
.stream()
118+
.flatMap(Set::stream)
119+
.filter(annotation -> annotation.getKey().equals(StackGresContext.VERSION_KEY))
120+
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))))
114121
.withLabels(labelFactory.genericLabels(distributedLogs))
115122
.withNamespace(namespace)
116123
.withName(name)

0 commit comments

Comments
 (0)