himanshug commented on pull request #9693:
URL: https://github.com/apache/druid/pull/9693#issuecomment-664693895
I have an alternate implementation proposal of achieving this.
Re #9351 : We can still introduce the new interface and use that in this use
case. Migrating all other places from PasswordProvider to new interface could
be taken up in #9351 . No reason for continuing to use PasswordProvider when
there is general agreement on the newer interface.
However, considering this use case, I would name new interface
`DynamicConfigProvider` instead of `CredentialProvider` .
Then `KafkaRecordSupplier` code change would end up looking something like
...
```
public static void addConsumerPropertiesFromConfig(
Properties properties,
ObjectMapper configMapper,
Map<String, Object> consumerProperties
)
{
Object dynamicConfigProviderJson =
consumerProperties.get("DRUID_DYNAMIC_CONFIG_PROVIDER_KEY");
if (dynamicConfigProviderJson != null) {
DynamicConfigProvider dynamicConfigProvider =
configMapper.convertValue(dynamicConfigProviderJson,
DynamicConfigProvider.class);
Map<String, String> dynamicConfig = dynamicConfigProvider.getConfig();
for (Map.Entry<String, Object> entry : consumerProperties.entrySet()) {
String propertyKey = entry.getKey();
if ("DRUID_DYNAMIC_CONFIG_PROVIDER_KEY".equals(propertyKey))
continue; //skip the dynamicConfig entry
String properyValue = String.valueOf(entry.getValue());
String valueFromDynamicConfig = dynamicConfig.get(properyValue);
if (valueFromDynamicConfig == null) {
properties.setProperty(propertyKey, properyValue);
} else {
properties.setProperty(propertyKey, valueFromDynamicConfig);
}
}
} else {
// this is required for backward compabitibility.
for (Map.Entry<String, Object> entry : consumerProperties.entrySet()) {
String propertyKey = entry.getKey();
if
(propertyKey.equals(KafkaSupervisorIOConfig.TRUST_STORE_PASSWORD_KEY)
||
propertyKey.equals(KafkaSupervisorIOConfig.KEY_STORE_PASSWORD_KEY)
|| propertyKey.equals(KafkaSupervisorIOConfig.KEY_PASSWORD_KEY))
{
PasswordProvider configPasswordProvider =
configMapper.convertValue(
entry.getValue(),
PasswordProvider.class
);
properties.setProperty(propertyKey,
configPasswordProvider.getPassword());
} else {
properties.setProperty(propertyKey,
String.valueOf(entry.getValue()));
}
}
}
}
```
which maintains backward compatibility as well which is a concern raised in
another comment.
@gianm @JulianJaffePinterest does that sound reasonable ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]