Skip to content

Commit 554147a

Browse files
committed
cr
1 parent 42be322 commit 554147a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ class RouteSpecificationFactory(
333333
.getTagsForDependency(group.proxySettings.outgoing)
334334
.map {
335335
RouteSpecification(
336-
clusterName = it.first,
337-
routeDomains = listOf(it.first) + getServiceWithCustomDomain(it.first),
338-
settings = it.second.settings
336+
clusterName = it.clusterName,
337+
routeDomains = listOf(it.clusterName) + getServiceWithCustomDomain(it.clusterName),
338+
settings = it.settings
339339
)
340340
}.distinctBy { it.clusterName }
341341

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/GlobalSnapshot.kt

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot
33
import io.envoyproxy.controlplane.cache.SnapshotResources
44
import io.envoyproxy.envoy.config.cluster.v3.Cluster
55
import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment
6+
import pl.allegro.tech.servicemesh.envoycontrol.groups.DependencySettings
67
import pl.allegro.tech.servicemesh.envoycontrol.groups.Outgoing
7-
import pl.allegro.tech.servicemesh.envoycontrol.groups.TagDependency
88

99
typealias ClusterName = String
1010

@@ -18,16 +18,21 @@ data class GlobalSnapshot(
1818
) {
1919
fun getTagsForDependency(
2020
outgoing: Outgoing
21-
): List<Pair<ClusterName, TagDependency>> {
21+
): List<TagDependencySettings> {
2222
val serviceDependencies = outgoing.getServiceDependencies().map { it.service }.toSet()
2323
return outgoing.getTagDependencies().flatMap { tagDependency ->
2424
tags.filterKeys { !serviceDependencies.contains(it) }
2525
.filterValues { it.contains(tagDependency.tag) }
26-
.map { it.key to tagDependency }
26+
.map { TagDependencySettings(it.key, tagDependency.settings) }
2727
}
2828
}
2929
}
3030

31+
data class TagDependencySettings(
32+
val clusterName: ClusterName,
33+
val settings: DependencySettings
34+
)
35+
3136
@Suppress("LongParameterList")
3237
fun globalSnapshot(
3338
clusters: Iterable<Cluster> = emptyList(),

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ class EnvoyClustersFactory(
191191
globalSnapshot.clusters
192192
}
193193

194-
val serviceSettings = group.proxySettings.outgoing.getServiceDependencies()
195-
.associateBy({ it.service }, { it.settings })
194+
val serviceSettings =
195+
group.proxySettings.outgoing.getServiceDependencies()
196+
.associate { it.service to it.settings }
196197

197198
val serviceFromTagSettings = globalSnapshot
198199
.getTagsForDependency(group.proxySettings.outgoing)
199-
.map { it.first to it.second.settings }
200-
.distinctBy { it.first }
201-
.associateBy({ it.first }, { it.second })
200+
.distinctBy { it.clusterName }
201+
.associate { it.clusterName to it.settings }
202202

203203
val clustersForGroup = when (group) {
204204
is ServicesGroup -> serviceSettings.mapNotNull {

0 commit comments

Comments
 (0)