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

Allow creating an alias for configuration names #339

Closed
OndroMih opened this issue Apr 7, 2018 · 5 comments
Closed

Allow creating an alias for configuration names #339

OndroMih opened this issue Apr 7, 2018 · 5 comments

Comments

@OndroMih
Copy link
Contributor

OndroMih commented Apr 7, 2018

Allow users to specify an alias for configuration names to map generated configuration names to simpler names.

This is helpful especially to simplify configuration for names generated e.g. by fault tolerance or rest client annotations. These generate a very long and complicated config name and for some sources if also contains illegal characters. This is addressed already by #326. But it doesn't make it easier to work with only possible to use them with those config sources.

I think aliases would be also useful when defining a configuration contract and documentation for the application. It's much easier to work with user-defined configuration names than with generated names, while generated names are used as a fallback if not defined by a user.

@struberg
Copy link
Contributor

struberg commented Apr 7, 2018

You can already do this with variable replacement, isn't?

@Emily-Jiang
Copy link
Member

@OndrejM can you elaborate your user case? Where do you put the alias?

@OndroMih
Copy link
Contributor Author

OndroMih commented Apr 9, 2018

Here's an example how I use injected REST client in an app: https://github.com/OndrejM/getting-started-microprofile/blob/master/src/main/java/ws/ament/microprofile/gettingstarted/AuthorService.java#L20

AFAIK, the only way to specify the URL for the client proxy is to provide it under a generated MP config name, such as ws.ament.microprofile.gettingstarted.AuthorService/mp-rest/url. Before refactoring, the code used JAX-RS client API with @ConfigProperty and a name key. After refactoring, there's no way to use the same config key, the configuration has to be changed to use the new generated key.

@Emily-Jiang Emily-Jiang added this to the MP Config future milestone Apr 9, 2018
@starksm64
Copy link
Contributor

I can use this as well to allow the mapping of the newly introduced mp.jwt.* config names in the MP-JWT spec to previously defined names that were part of the wfswarm implementation. For example:

@Dependent
public class JWTAuthContextInfoProvider {
    private static final String NONE = "NONE";

    @Inject
    @ConfigProperty(name = "mpjwt.signerPublicKey", defaultValue = NONE, alias = "mp.jwt.verify.publickey")
    private Optional<String> publicKeyPemEnc;
    @Inject
    @ConfigProperty(name = "mpjwt.issuedBy", defaultValue = NONE, alias = "mp.jwt.issuer")
    private String issuedBy;
    @Inject
    @ConfigProperty(name = "mpjwt.expGracePeriodSecs", defaultValue = "60")
    private Optional<Integer> expGracePeriodSecs;
    @Inject
    @ConfigProperty(name = "mpjwt.jwksUri", defaultValue = NONE, alias = "mp.jwt.verify.publickey.location")
    private Optional<String> jwksUri;
    @Inject
    @ConfigProperty(name = "mpjwt.jwksRefreshInterval", defaultValue = "60")
    private Optional<Integer> jwksRefreshInterval;

Here I have added the MP-JWT spec defined mp.jwt.verify.publickey, mp.jwt.issuer, and mp.jwt.verify.publickey.location as aliases to the pre-existing vendor specific config names.

@OndroMih
Copy link
Contributor Author

Reviewing this issue again, I've changed my mind. Instead of supporting property mappings, I think it's better if each specification provides means how to simplify the required property name. In the case of REST client, this is already done in version 1.3 with @RegisterRestClient.configKey.

General property mapping, which would be needed @starksm64 is useful only for specific usecases and should be instead optionally provided by implementations or a custom config source.

I'm closing this issue.

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

4 participants