japgolly / clear-config

Scala FP configuration library with a focus on runtime clarity
Apache License 2.0
140 stars 5 forks source link

Support for HOCON (typesafe config) backend? #26

Open Daenyth opened 5 years ago

Daenyth commented 5 years ago

I didn't see an example in the README - is this something that could be added, perhaps as a separate module?

japgolly commented 5 years ago

I don't think it's possible but if it is I'd be happy for it to be an optional module.

On Tue, 25 Jun. 2019, 4:13 am Gavin Bisesi, notifications@github.com wrote:

I didn't see an example in the README - is this something that could be added, perhaps as a separate module?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/japgolly/clear-config/issues/26?email_source=notifications&email_token=AABRRNYAT25ELNKB3T3BHG3P4EFDBA5CNFSM4H3BB5W2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3LOTJA, or mute the thread https://github.com/notifications/unsubscribe-auth/AABRRN2M7J3DXAVIHLIAHADP4EFDBANCNFSM4H3BB5WQ .

yadavan88 commented 2 years ago

@japgolly I came to know about this library and it is really awesome :) Thanks

Regarding the hocon format, if I currently have a config format as:

database {
  mongo {
   username = "mongoUser"
   password = "pass1"
  }
  postgres {
    username = "pgUser"
    password = "pass2"
  }
}

I should re-write them as and use .withPrefix("database.mongo.") and withPrefix("database.postgres.")

database.mongo.username = "mongoUser"
database.mongo.password = "pass1"
database.postgres.username = "pgUser"
database.postgres.password = "pass2"

Is this correct, or am I missing something?

japgolly commented 2 years ago

Hi @yadavan88 , currently we don't support reading from HOCON format.

If you mean you're moving away from HOCON, then yes that's the right way to do it. You could also have .withPrefix("mongo.") and .withPrefix("postgres.") and then after they're composed together, put a .withPrefix("database.") on the outside, but that depends on how you structure your config code. Whichever way works best for you is the one you should choose.