Skip to content

Commit

Permalink
Renamed new builder
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel committed May 27, 2023
1 parent b4653a4 commit 6d16761
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
test("context pattern should be detected and used") {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:foo }}"
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -53,7 +53,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
test("prefix pattern should be detected and used") {
val props = Properties()
props["a"] = "aws-secrets-manager://foo"
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -64,7 +64,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
test("unknown secret should return error and include key") {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:qwerty }}"
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -76,7 +76,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:bibblebobble }}"
client.createSecret(CreateSecretRequest().withName("bibblebobble").withSecretString(""))
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -87,7 +87,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
test("unknown secret should return error and not include prefix") {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:unkunk }}"
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -101,7 +101,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
props["a"] = "\${{ aws-secrets-manager:foo.bar }}"
props["b"] = "\${{ aws-secrets-manager:bar.baz }}"
shouldThrow<ConfigException> {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand All @@ -112,7 +112,7 @@ class AwsSecretsManagerResolverTest : FunSpec() {
test("should support index keys") {
val props = Properties()
props["a"] = "\${{ aws-secrets-manager:bubble[f] }}"
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addResolver(AwsSecretsManagerContextResolvers { client })
.addPropertySource(PropsPropertySource(props))
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ConfigLoaderBuilder private constructor() {
* use [empty] to obtain an empty ConfigLoaderBuilder and call the various addDefault methods manually.
*/
@ExperimentalHoplite
fun create(): ConfigLoaderBuilder {
fun newBuilder(): ConfigLoaderBuilder {
return empty()
.addDefaultDecoders()
.addDefaultResolvers()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.sksamuel.hoplite.resolver

import com.sksamuel.hoplite.ConfigLoaderBuilder
import com.sksamuel.hoplite.ExperimentalHoplite
import com.sksamuel.hoplite.parsers.PropsPropertySource
import io.kotest.core.spec.style.StringSpec
import io.kotest.extensions.system.withSystemProperty
import io.kotest.matchers.shouldBe
import java.util.Properties

@OptIn(ExperimentalHoplite::class)
class RecursiveResolverTest : StringSpec() {
init {

Expand All @@ -20,7 +22,7 @@ class RecursiveResolverTest : StringSpec() {
props["baz"] = "oat"
props["result"] = "b\${{ ref:b\${{ ref:b\${{ ref:foo }} }} }}ymcb\${{ ref:b\${{ ref:b\${{ ref:foo }} }} }}face"

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.addPropertySource(PropsPropertySource(props))
.build()
.loadConfigOrThrow<Config>()
Expand All @@ -35,7 +37,7 @@ class RecursiveResolverTest : StringSpec() {
props["result"] = "boaty\${{ ref:foo }}boat\${{sysprop:bar}}"

val config = withSystemProperty("bar", "face") {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.addPropertySource(PropsPropertySource(props))
.build()
.loadConfigOrThrow<Config>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SealedClassDiscriminatorFieldTest : FunSpec({
test("empty sealed type should error") {
data class TestConfig(val database: Foo)
shouldThrowAny {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -36,7 +36,7 @@ database:
test("sealed classes decoding using discriminator field for class subtype") {
data class TestConfig(val database: Database)

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -57,7 +57,7 @@ database:
test("sealed classes decoding using discriminator field for object subtype") {
data class TestConfig(val database: Database)

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -75,7 +75,7 @@ database:
test("sealed classes decoding using top level field for object subtype") {
data class TestConfig(val database: Database)

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -93,7 +93,7 @@ database: InMemory
data class TestConfig(val database: Database)

shouldThrowAny {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -111,7 +111,7 @@ database:
data class TestConfig(val database: Database)

shouldThrowAny {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -132,7 +132,7 @@ database:
data class TestConfig(val database: Database)

shouldThrowAny {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand All @@ -152,7 +152,7 @@ database:
test("list of sealed classes using discriminator field per entry") {
data class TestConfig(val databases: List<Database>)

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand Down Expand Up @@ -189,7 +189,7 @@ databases:
data class TestConfig(val databases: List<Database>)

shouldThrowAny {
ConfigLoaderBuilder.create()
ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand Down Expand Up @@ -217,7 +217,7 @@ databases:
test("list of sealed classes mixing class and object implementations") {
data class TestConfig(val databases: List<Database>)

val config = ConfigLoaderBuilder.create()
val config = ConfigLoaderBuilder.newBuilder()
.withExplicitSealedTypes()
.addPropertySource(
YamlPropertySource(
Expand Down

0 comments on commit 6d16761

Please sign in to comment.