Skip to content

Commit

Permalink
- refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
shakeeb-upstart committed Sep 25, 2024
1 parent 54afcf5 commit d3c83f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import com.typesafe.config.Config

import org.apache.pekko.util.OptionConverters._

final class Settings(configNamespace: Option[String], system: ExtendedActorSystem) extends Extension {
final class Settings(kubernetesApi: Config) extends Extension {

def this(system: ExtendedActorSystem) = this(None, system)
def this(system: ExtendedActorSystem) = this(system.settings.config.getConfig("pekko.discovery.kubernetes-api"))

/**
* Copied from PekkoManagementSettings, which we don't depend on.
Expand All @@ -37,14 +37,6 @@ final class Settings(configNamespace: Option[String], system: ExtendedActorSyste
if (hasDefined(key)) Some(config.getString(key)) else None
}

private val defaultConfig = system.settings.config.getConfig("pekko.discovery.kubernetes-api")

private val kubernetesApi =
configNamespace match {
case Some(namespace) => system.settings.config.getConfig(namespace).withFallback(defaultConfig)
case _ => defaultConfig
}

val apiCaPath: String =
kubernetesApi.getString("api-ca-path")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@ class KubernetesApiServiceDiscoverySpec extends AnyWordSpec with Matchers {

"The discovery loading mechanism" should {
"allow loading kubernetes-api discovery even if it is not the default" in {
implicit val system = ActorSystem()
val system = ActorSystem()
// #kubernetes-api-discovery
val d = new KubernetesApiServiceDiscovery()
val discovery = Discovery(system).loadServiceDiscovery("kubernetes-api")
// #kubernetes-api-discovery
discovery shouldBe a[KubernetesApiServiceDiscovery]
Expand Down

0 comments on commit d3c83f0

Please sign in to comment.