sksamuel / hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes
Apache License 2.0
922 stars 74 forks source link

Support custom Json serde for SecretsManager #423

Closed samu-developments closed 1 month ago

samu-developments commented 3 months ago

Thanks for this great library!

We had a use case where we needed to deserialize a json with a number value (not a quoted number string) from AWS secretsmanager, eg:

{
  "port": 5432,
  "username": "test",
  ...
}

To do this one need to set the isLenient field to true in Json builder:

val json = Json { 
  isLenient = true 
}

This PR adds Json as a constructor parameter to AwsSecretsManagerPreprocessor to support custom json serde config. Let me know what you think.

(In the end we just added our own custom preprocessor, which also works fine)

sksamuel commented 3 months ago

Couple of test failures. Will merge once green.

samu-developments commented 3 months ago

Couple of test failures. Will merge once green.

Local tests were loading region from local config, works now. Thank you!