https://kotlinlang.org logo
Join Slack
Powered by
# hoplite
  • 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
  • k

    Kristian Frøhlich

    06/11/2025, 7:12 AM
    @sam Any timeline for a 3.0 release ?
  • s

    sam

    06/12/2025, 3:41 AM
    RC1 is out if you want to try that
    👍 1
    👀 1
    K 1
  • s

    Scott Fedorov

    06/28/2025, 3:15 PM
    https://blog.jetbrains.com/kotlin/2025/06/ktor-3-2-0-is-now-available/#typed-configuration Ktor adding some Hoplite like functionality to their native config.
  • s

    sam

    06/28/2025, 4:35 PM
    does Simon work for Jetbrains now? https://blog.jetbrains.com/author/simon-vergauwen-jetbrains-com/
    👌 1
    s
    s
    • 3
    • 6
  • s

    sam

    06/28/2025, 4:35 PM
    If so that's really cool
  • s

    sam

    06/28/2025, 4:38 PM
    I think you meant Hoplite not Cohort @Scott Fedorov
  • s

    sam

    06/28/2025, 4:38 PM
    btw Cohort is listed on the plugins page too now https://start.ktor.io/settings
  • s

    Scott Fedorov

    06/28/2025, 4:38 PM
    oops, yeah I did lol