https://kotlinlang.org logo
Join SlackCommunities
Powered by
# hoplite
  • s

    Sebastian Schuberth

    03/01/2023, 12:02 PM
    Does anyone have a solution for a use-case as described here, i.e. to override a single property within a list from the command line (not environment)?
    • 1
    • 1
  • d

    David Hamilton

    07/15/2023, 8:26 AM
    Hi - is there a
    ConfigLoaderBuilder
    recipe that mimics the opinionated default loader behaviour of TypeSafe/Lightbend Config, including fallbacks and the various optional property overrides? https://github.com/lightbend/config/blob/main/README.md#standard-behavior
    s
    • 2
    • 5
  • d

    David Hamilton

    07/17/2023, 10:43 AM
    Also, does the builder cache the built configuration environment variables used somewhere? I've written some tests injecting environment vars, and they pass when run individually, but there are failures when run as a suite. If so, is there an approach (apart from the
    ReloadableConfig
    ) that forces expiry of cached values?
    • 1
    • 1
  • d

    Dan T

    09/20/2023, 5:10 PM
    I'm loving the
    withReport
    feature and its related decorators like the HashObfuscator...I don't see it documented yet though, so wondering if it's already documented somewhere, or if you're intentionally not documenting it yet for any reason? If not, lemmeno and I'd be willing to submit a PR for its documentation.
  • s

    sam

    09/20/2023, 6:26 PM
    We should add the documentation yeah, I added that feature as we use it internally when deploying our microservices, and it's been in use for about a year, so it's fully stable.
    🆒 1
  • d

    dave08

    09/28/2023, 3:57 PM
    Say I have:
    Copy code
    http-clients:
      client-1:
        url: ...
    and I'd like to map it to:
    Copy code
    data class Configs(val httpClients: List<HttpClientConfig>)
    
    data class HttpClientConfig(val name: String, val url: String) // Is there some kind of annotation to pull the name 'client-1' out from the map key and use it as name here and have the result as a list? Or even:
    
    data class Configs(val httpClients: Map<String, HttpClientConfig>) // And still not having to specify name in client-1 configs since it can be pulled in from the key...?
  • s

    sam

    09/29/2023, 1:36 AM
    you would need to do:
    Copy code
    http-clients:
      - name: client-1
        url: ....
  • d

    dave08

    10/11/2023, 2:18 PM
    Say I have a configuration in yaml
    Copy code
    s3Configs:
      accessKey: ...
    would the env var S3CONFIGS__ACCESSKEY work @sam?
  • d

    dave08

    10/11/2023, 2:19 PM
    (C in
    s3 C onfigs
    in capital and
    access K ey
    is too)
  • s

    sam

    10/11/2023, 3:15 PM
    I don't think so no, it needs to match case or your var be all lowercase
    🤕 1
    d
    • 2
    • 37
  • d

    dave08

    11/21/2023, 4:14 PM
    It would have been nice to have control over cohort with Hoplite... like in Micronaut, where you can change log levels (or metrics, etc...) using config files or env vars etc... I guess I could always make a data class for all it's options and copy-paste it in all projects, but I think it's a common use-case that could have a simple module that could be re-used...
    s
    • 2
    • 3
  • r

    rocketraman

    03/18/2024, 12:15 PM
    Is there any chance https://github.com/sksamuel/hoplite/issues/386 would see any love in the near future? I would like to transition to hoplite from my forked version of cfg4k (https://github.com/rocketraman/cfg4k), but that issue is a blocker.
    s
    • 2
    • 3
  • r

    rocketraman

    03/27/2024, 1:30 PM
    Trying to understand the interaction between
    ConfigLoaderBuilder.addResourceSource
    and the
    inputs: List<ConfigSource>
    parameter of
    loadConfigOrThrow
    . Why can we define sources in both places, and what happens if we do?
    s
    • 2
    • 1
  • p

    phldavies

    07/08/2024, 10:10 AM
    Has anyone else had any luck using the Arrow
    NonEmptyListDecoder
    with a value class? It seems to work fine with a normal
    List
    field or with
    Nel<String>
    (although the error for an empty list isn't particularly helpful: "Required type class arrow.core.NonEmptyList could not be decoded from a List")
    • 1
    • 1
  • a

    Aeden Jameson

    10/26/2024, 10:04 PM
    It would appear hoplite only lets one map to data classes out of the box and not plain classes. Is that right? I come across frameworks that use
    class
    to hold config values. It would be nice just to use that class for loading. Did I overlook something (a decoder)? If not, do i need to implement a decoder?
  • s

    sam

    10/28/2024, 4:59 AM
    data classes only yes
  • s

    sam

    10/28/2024, 4:59 AM
    You could add your own data class and map after the config is loaded
    a
    • 2
    • 1
  • k

    Kristian Frøhlich

    01/08/2025, 7:16 PM
    Copy code
    fun config() = ConfigLoader.builder()
        .addEnvironmentSource()
        .addPreprocessor(
            VaultSecretPreprocessor(
                {
                    VaultTemplate(
                        VaultEndpoint.create("MY_HOST", MY_PORT),
                        TokenAuthentication("MY_TOKEN")
                    )
                }
            )
        )
        .addResourceSource("/application.conf")
        .withExplicitSealedTypes()
        .build()
        .loadConfigOrThrow<Config>()
    Are there any elegant way of resolving the env variables here or is the easiest to just fall back to
    System.getEnv(...)
    ?
  • d

    dave08

    01/30/2025, 2:38 PM
    Is there any chance this could be added (I hope I did it right...)?
    Copy code
    class IntRangeDecoder() : Decoder<IntRange> {
        override fun supports(type: KType): Boolean = type.classifier == IntRange::class
    
        override fun decode(node: Node, type: KType, context: DecoderContext): ConfigResult<IntRange> = when(node) {
            is StringNode -> runCatching {
                node.value.split("..").let { IntRange(it[0].toInt(), it[1].toInt()) }
            }.toValidated { ConfigFailure.DecodeError(node, type) }
    
            else -> ConfigFailure.DecodeError(node, type).invalid()
        }
    }
  • s

    sam

    01/31/2025, 12:22 AM
    Yeah just pr it :)
  • a

    Amy Lashley

    02/07/2025, 10:01 PM
    👋 @sam I have a ktor service that runs (for now) in ElasticBeanstalk. It's been on hoplite 2.7.5 and I updated to 2.9.0 today. all fine. Then I tried to move from
    hoplite-aws
    to
    hoplite-aws-kotlin
    and ran into issues with the credential provider..only in EB.
    Copy code
    aws.smithy.kotlin.runtime.identity.IdentityProviderException: No identity could be resolved from the chain: CredentialsProviderChain -> SystemPropertyCredentialsProvider -> EnvironmentCredentialsProvider -> ProfileCredentialsProvider -> StsWebIdentityProvider -> EcsCredentialsProvider -> ImdsCredentialsProvider
    I switched over to
    hoplite-aws2
    and all is fine. But I can't figure out what's going on with the kotlin version. Nothing else changed..not my config code or anything about the EB environment. Have you run into this before? We're not planning to stay on EB and I suspect that there's something about accessing roles there that either the hoplite library, or the underlying aws library doesn't like.
    c
    s
    • 3
    • 11
  • d

    David Silva

    02/12/2025, 3:15 PM
    Hi guys, Quick q: are yaml merge keys supported? Glimpsing over the Yaml parser I see references to anchors/aliases at the yaml parser, which are very related features, but nothing on merge keys. I know merge keys are not part of the 1.2 spec, only 1.1, but they are quite handy 😄 I’ll leave some details in a just for the sake of completion 🧵 Thank you!
    s
    c
    • 3
    • 7
  • p

    phldavies

    02/20/2025, 8:22 PM
    is https://github.com/sksamuel/hoplite/pull/477 something that can make it in to a patch release?
  • s

    sam

    02/21/2025, 5:06 PM
    I can back port to 2.8.x sure
    ❤️ 1
  • k

    Kristian Frøhlich

    03/11/2025, 11:30 AM
    @sam Could this also be a candidate for backport ? https://github.com/sksamuel/hoplite/pull/476
  • l

    Laurent Thiebaud

    03/13/2025, 11:30 AM
    @sam Do you think it is that possible to do a new release? (a MR has been merged for a while and still not released) That would really help 🙏
    s
    • 2
    • 2
  • s

    Sebastian Schuberth

    03/25/2025, 5:30 PM
    Can anyone explain to me what the (undocumented)
    prefix
    parameter of the
    loadConfig()
    functions does? When loading e.g. from a YAML file, does it allow to limited loading to a nested key of that name?
    r
    s
    • 3
    • 4
  • s

    Sebastian Schuberth

    03/25/2025, 8:24 PM
    Apparently
    loadConfig()
    fails if there is nothing to load from any configured property source. I'd like to fall back to some default configuration on that kind of "failure". However, I still want to capture "real" failures, like syntax errors in configuration files. What's the correct way to distinguish "no config available" from "config broken" in Hoplite?
    c
    d
    r
    • 4
    • 13
  • s

    Scott Fedorov

    03/27/2025, 3:31 PM
    Looked through issues and pull requests, but doesn't look like anyone has requested a 1password preprocessor.... thoughts or objections to me adding one @sam?
    s
    • 2
    • 1
  • l

    LeoColman

    04/10/2025, 1:33 PM
    Alô! Exception in thread "main" java.util.ServiceConfigurationError: com.sksamuel.hoplite.decoder.Decoder: Provider com.sksamuel.hoplite.decoder.LocaleDecoder not found I'm getting this exception when trying to package an UberJar using hoplite. It's a niche Jetpack Compose Desktop app. How to start understanding this error? I think it's because Hoplite depends on java meta but compose is not packing them
    c
    s
    • 3
    • 9