https://kotlinlang.org logo
#http4k
Title
# http4k
d

dave

06/27/2019, 4:54 AM
@Razi Kheir FromResource() will load from the classpath and not from a file on disk
👍 1
r

Razi Kheir

06/27/2019, 4:55 AM
I see, so resource comes first but file system is just before last? Why is it not detecting my filesystem override unless its the first in line?
d

dave

06/27/2019, 4:56 AM
There shouldn't be a special order apart from the chain that you specify.
r

Razi Kheir

06/27/2019, 5:02 AM
I mean if I put the filesystem environment as the first override everything works prefectly the lenses read the variables etc. If I put it under jvm flags, suddenly it throws lens exception
I would assume that if it doesn’t find any jvm flags for example it would then search in the second one instead of throwing exception no?
d

dave

06/27/2019, 5:12 AM
Yes - that the expected behaviour.
Can you post a simple.code version that we can run?
r

Razi Kheir

06/27/2019, 5:16 AM
Ill do that later today 🙂 thanks
👍 1
I solved it by making all the lenses use EnvironmentKey.xxx().optional instead of .required. I will post an example anyway later today
d

dave

06/27/2019, 8:10 AM
Here's my experiment, which works ok:
Copy code
fun main() {
    /**
     * Given: foo.propertie
     * 
     * foo=bar
     */
    val key = EnvironmentKey.required("foo")

    val file = Environment.from(File("path/foo.properties"))

    val comp = Environment.from("BAR" to "foo") overrides file

    println(key(comp))
}
4 Views