Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
KSmigielski committed Dec 29, 2022
1 parent 42be322 commit 554147a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ class RouteSpecificationFactory(
.getTagsForDependency(group.proxySettings.outgoing)
.map {
RouteSpecification(
clusterName = it.first,
routeDomains = listOf(it.first) + getServiceWithCustomDomain(it.first),
settings = it.second.settings
clusterName = it.clusterName,
routeDomains = listOf(it.clusterName) + getServiceWithCustomDomain(it.clusterName),
settings = it.settings
)
}.distinctBy { it.clusterName }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot
import io.envoyproxy.controlplane.cache.SnapshotResources
import io.envoyproxy.envoy.config.cluster.v3.Cluster
import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment
import pl.allegro.tech.servicemesh.envoycontrol.groups.DependencySettings
import pl.allegro.tech.servicemesh.envoycontrol.groups.Outgoing
import pl.allegro.tech.servicemesh.envoycontrol.groups.TagDependency

typealias ClusterName = String

Expand All @@ -18,16 +18,21 @@ data class GlobalSnapshot(
) {
fun getTagsForDependency(
outgoing: Outgoing
): List<Pair<ClusterName, TagDependency>> {
): List<TagDependencySettings> {
val serviceDependencies = outgoing.getServiceDependencies().map { it.service }.toSet()
return outgoing.getTagDependencies().flatMap { tagDependency ->
tags.filterKeys { !serviceDependencies.contains(it) }
.filterValues { it.contains(tagDependency.tag) }
.map { it.key to tagDependency }
.map { TagDependencySettings(it.key, tagDependency.settings) }
}
}
}

data class TagDependencySettings(
val clusterName: ClusterName,
val settings: DependencySettings
)

@Suppress("LongParameterList")
fun globalSnapshot(
clusters: Iterable<Cluster> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ class EnvoyClustersFactory(
globalSnapshot.clusters
}

val serviceSettings = group.proxySettings.outgoing.getServiceDependencies()
.associateBy({ it.service }, { it.settings })
val serviceSettings =
group.proxySettings.outgoing.getServiceDependencies()
.associate { it.service to it.settings }

val serviceFromTagSettings = globalSnapshot
.getTagsForDependency(group.proxySettings.outgoing)
.map { it.first to it.second.settings }
.distinctBy { it.first }
.associateBy({ it.first }, { it.second })
.distinctBy { it.clusterName }
.associate { it.clusterName to it.settings }

val clustersForGroup = when (group) {
is ServicesGroup -> serviceSettings.mapNotNull {
Expand Down

0 comments on commit 554147a

Please sign in to comment.