Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Do I Correctly Add A Preprocessor? #408

Open
aedenj opened this issue Mar 13, 2024 · 1 comment
Open

How Do I Correctly Add A Preprocessor? #408

aedenj opened this issue Mar 13, 2024 · 1 comment

Comments

@aedenj
Copy link

aedenj commented Mar 13, 2024

With the line,

    ConfigLoaderBuilder.default().addPreprocessor(AwsSecretsManagerPreprocessor()

I've observed that the AwsSecretsManagerPreprocessor would run after
the replacement preprocessor. However, my config looks like,

key = "awssm://services/my-service[api-key]",
secret = "awssm://services/my-service[api-secret]",


myConfigString = "myKey=${key} mySecret=${secret};"

And myConfigString doesn't contain the correct key and secret. Instead
it contains the strings for key and secret. The only way around this
I've found is to copy the contents of the .default() like this,

            return ConfigLoaderBuilder.empty()
                .addPreprocessor(AwsSecretsManagerPreprocessor())
                .addDefaultPreprocessors()
                .addDefaultDecoders()
                .addDefaultParsers()
                .addDefaultParamMappers()
                .addDefaultPropertySources()
                .addResourceSource("....")
                .build()
                .loadConfigOrThrow<MyConfig>()

This doesn't seem quite right. Is there a better way?

@sksamuel
Copy link
Owner

Any custom preprocessors will run after the replacement one.
What you're doing is the way to define it.
Or add the replacement one again after the AwsSecretsManagerPreprocessor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants