Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 12 22:32
    ekrich commented #651
  • Sep 12 21:45
    jamesratzlaff edited #651
  • Sep 12 21:44
    jamesratzlaff opened #651
  • Sep 11 14:11
    Pilvinen opened #650
  • Sep 11 13:37
    johanandren commented #619
  • Sep 06 13:59
    jamesratzlaff commented #494
  • Sep 06 00:48
    jamesratzlaff opened #649
  • Sep 04 14:32

    johanandren on v1.3.5-RC1

    (compare)

  • Sep 04 14:00
    johanandren commented #619
  • Sep 03 20:46

    havocp on master

    Performance fix: added capacity… Merge pull request #648 from wi… (compare)

  • Sep 03 20:46
    havocp closed #648
  • Sep 03 20:46
    havocp commented #648
  • Sep 03 20:45
    havocp labeled #648
  • Sep 03 18:44
    widgetii opened #648
  • Aug 26 11:28
    domdorn commented #122
  • Aug 20 13:04
    patriknw milestoned #167
  • Aug 20 13:03
    patriknw commented #619
  • Aug 20 13:02

    patriknw on master

    Allow application.conf to overr… (compare)

  • Aug 20 13:02
    patriknw closed #619
  • Aug 16 14:55
    havocp commented #494
Erik Erlandson
@erikerlandson
I wrote a blog post about adding unit types to lightbend/config:
http://erikerlandson.github.io/blog/2019/05/09/preventing-configuration-errors-with-unit-types/
Salil Kanetkar
@salilkanetkar
Hello,
I had a use case whereby I want to generate a random number/string in my .conf file. Is there a way to do that in typesafe?
Martynas Mickevičius
@2m
I would go for a source generator in SBT, or your build tool of choice, for that.
Eric K Richardson
@ekrich
What is the minimum code needed to resolve a substitution?
  val configStr =
      """
        |pattern.default.main = "default"
        |core = {
        |  version: "0.1"
        |  extends: [
        |    ${pattern_default_main}
        |  ]
        |}
    """.stripMargin

    val conf = ConfigFactory.parseString(configStr)
    println(conf.isResolved ) // false
    val rconf = conf.resolve()
Maciej Nowicki
@Vistritium

Hello, anyone knows any library that can parse typesafe config onto case class using runtime types?

def read(clazz: Class[_], config: com.typesafe.config.Config, path: String): AnyRef = {
    ??? // config.as(clazz, path)
}

clazz is a case class.

nafg
@nafg
@Vistritium wdym exactly by "runtime types"
maheswar4b4
@maheswar4b4
Hi,
I have application.conf which has the default config and
env specific config in another file. How do i specify multiple config files on the command line ?.
Martynas Mickevičius
@2m
@maheswar4b4 include the directory that has both of the config files to the classpath.
maheswar4b4
@maheswar4b4
@2m Yeah, That should work as well, but I want to minimize the config files. Here is what I have 1) application.conf 2) env specific file that has seed hosts and canonical hostname 3) another conf file that includes both the application.conf and env conf file. What I am looking for is there any way through which I can avoid the 3rd file that does nothing but includes #1 and #2 config files. Any system parameter through which I can specify multiple config files
Tim Moore
@TimMoore
@maheswar4b4 the more common thing would be to have the env-specific one as the top level config file that you specify with a system property on the command line, and then that includes application.conf
ahmad-shahzad-hut
@ahmad-shahzad-hut
Hi I have an issue. I have a value in my config file which I am trying to override when i exectute the jar. Like doing java -Dfoo.bar.value=5 -jar myJar.jar
but it does not overwrite the value defined in the conf file.
do you know if I am doing anything wrong.
Tim Moore
@TimMoore
@ahmad-shahzad-hut that seems like that should work, but to help you we would need more details (code examples, with exactly what you tried)
ahmad-shahzad-hut
@ahmad-shahzad-hut
thansk a lot. I have learnt that it matters the way a configuration file is loaded.
maheswar4b4
@maheswar4b4
hi, Is this supported ${key:-defaultValue} or something similar in config library ?
If key is set, return the value, else return the default value.
Havoc Pennington
@havocp
can set the key once to default and then on the next line set it to ${?override} which will only override if override is set ?
nafg
@nafg
I posted a question on https://gitter.im/scala/scala that is relevant to hocon, if anyone has a suggestion
Seth Lasky
@TheMover
Hey all, say I have a conf file that looks like the following:
optional = {
    thing1 = ${?THING_1}
    thing2 = ${?THING_2}
}

someInt = 1
I'm parsing this into a case class with Circe that looks like
Config(optional: Option[OptionalConfig],  someInt: Int)
This doesn't work obviously because the overall object optional still exists while thing1 and thing2 only exist if the environment variables are set
Is there an easy way to tell typesafe that optional is null unless 1 or more of it's properties are set?
Havoc Pennington
@havocp
Not that I can think of. I think there may be an issue about it (it’s even less intuitive if you write it as optional.thing1=${?THING_1} that’s what I remember from the previous discussion)
Seth Lasky
@TheMover
Argh ok, guess I'll validate on a single property then. If you happen to remember the issue could you post it?
Jakub Kozłowski
@kubukoz

Hi, I seem to be unable to override a setting with system properties.

In my application.conf:

http {
  host = "0.0.0.0"
  port = 8080
}

Running the app: java -jar ./target/out/ReportService.jar -Dhttp.port=8089

and the application starts with the 8080 port.

Am I doing something wrong?
Tim Moore
@TimMoore
@kubukoz you need to put -Dhttp.port=8089 before -jar ./target/out/ReportService.jar or else the JVM thinks its an argument to your main class, rather than an argument to the JVM itself: java -Dhttp.port=8089 -jar ./target/out/ReportService.jar
Jakub Kozłowski
@kubukoz
oh
bbaldino
@bbaldino
i was wondering how specifically the namereference.conf is relied on, as i find the name a bit confusing and would rather use defaults.conf. the defaults.conf file does get picked up by load, but i wonder if i'm introducing a landmine by not using reference.conf?
bbaldino
@bbaldino
oh, actually i'm wrong...load() won't see defaults.conf by default, have to specify it. but, assuming i do use that for defaults, is the only concern that a reference.conf could be added there and it would serve as the 'true' defaults file because it's explicitly handled by the lib?
Havoc Pennington
@havocp
all libraries on the classpath that need config are intended to provide a reference.conf, and ConfigFactory.load() would load all of those by default. If you're shipping an app, providing a reference.conf isn't really the intent; if you're shipping a library, then you'd need to use the name reference.conf or apps wouldn't know which name to load. See also https://github.com/lightbend/config#standard-behavior
bbaldino
@bbaldino
ok. but if my app has defaults (that live in the code) that can be overridden (by, say an overrides file provided at runtime) should the app use reference.conf?
i've been using defaults.conf and overriding lib defaults in the app, so it was working with that filename, but maybe coincidentally?
Havoc Pennington
@havocp
ConfigFactory.load() won't load defaults.conf as far as I know. ConfigFactory.load("defaults") would use defaults.conf instead of application.conf
if someone then does java -Dconfig.file=something.conf that would override application.conf
typical use is to include "application" at the top of the override file to start with the normal stuff, but you could also put a reference.conf in the app
bbaldino
@bbaldino
ok: so libs use reference.conf for defaults, application uses application.conf (which can override values for libs). if at runtime an override is passed to the app, will it fall back to application?
ah ok
Havoc Pennington
@havocp
yeah the -Dconfig.file replaces application.conf, but you can include it if you want
bbaldino
@bbaldino
ok, so if i don't want to have to rely on the include, i should put a reference.conf in the app with just the app defaults, and an application.conf with lib overrides?
hm, but i wouldn't want that being replaced if one was passed at runtime
i could put lib overrides in the app's reference.conf, right?
Havoc Pennington
@havocp
the only issue with that is that the reference.conf are stacked in the order they're returned by the class loader, which isn't really defined (I think in practice it's "classpath order"). As long as the app reference.conf comes back at the start of the classpath order I think it will work.
bbaldino
@bbaldino
ah, ok
i think i'm looking for a way to be able to support: a lib has its own defaults. an app has its defaults, and perhaps some known overrides for the lib, and overrides can be passed at runtime that could override both app and lib settings, but should fallback to first the app's overrides and then to the lib's originals
am i thinking about it wrong?
i guess maybe will just have to do the ' include'
but that isn't a big deal, just wanted to make sure i understood the options. thanks for the clarification @havocp !
Havoc Pennington
@havocp
you're welcome! I don't think you're thinking about it wrongly
bbaldino
@bbaldino
is there any idiom for defining a property name such that it is used by the config file and can be used in tests to override settings? as opposed to hard-coding the property name in the test. i realize this is probably a stretch, unfortunately i'm not a position to be able to manually pass a config instance here (anytime soon, at least)