-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Adding Default Filters #43935
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
Adding Default Filters #43935
Changes from all commits
9d2ee1e
bf72f92
ed723c2
dccf44e
7212319
0b4680e
09382e7
5c597cb
f7a1f64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
|
|
||
| import org.springframework.boot.BootstrapRegistry.InstanceSupplier; | ||
| import org.springframework.boot.context.config.ConfigDataLocationResolverContext; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| import org.springframework.boot.context.properties.bind.Bindable; | ||
| import org.springframework.boot.context.properties.bind.Binder; | ||
| import org.springframework.util.StringUtils; | ||
|
|
@@ -15,9 +14,9 @@ | |
| import com.azure.spring.cloud.appconfiguration.config.SecretClientCustomizer; | ||
| import com.azure.spring.cloud.appconfiguration.config.implementation.autofailover.ReplicaLookUp; | ||
| import com.azure.spring.cloud.appconfiguration.config.implementation.properties.AppConfigurationProperties; | ||
| import com.azure.spring.cloud.appconfiguration.config.implementation.properties.AppConfigurationProviderProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.appconfiguration.AzureAppConfigurationProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.context.properties.AzureGlobalProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.keyvault.secrets.properties.AzureKeyVaultSecretProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.properties.core.AbstractAzureHttpConfigurationProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.properties.core.authentication.TokenCredentialConfigurationProperties; | ||
| import com.azure.spring.cloud.autoconfigure.implementation.properties.utils.AzureGlobalPropertiesUtils; | ||
|
|
@@ -26,12 +25,10 @@ | |
| import com.azure.spring.cloud.service.implementation.appconfiguration.ConfigurationClientBuilderFactory; | ||
| import com.azure.spring.cloud.service.implementation.keyvault.secrets.SecretClientBuilderFactory; | ||
|
|
||
| @EnableConfigurationProperties(AppConfigurationProviderProperties.class) | ||
| class AzureAppConfigurationBootstrapRegistrar { | ||
|
|
||
| static void register(ConfigDataLocationResolverContext context, Binder binder, | ||
| AppConfigurationProperties properties, AppConfigurationProviderProperties appProperties, | ||
| ReplicaLookUp replicaLookup) { | ||
| AppConfigurationProperties properties, ReplicaLookUp replicaLookup) { | ||
|
|
||
| AzureGlobalProperties globalProperties = binder | ||
| .bind(AzureGlobalProperties.PREFIX, Bindable.of(AzureGlobalProperties.class)) | ||
|
|
@@ -46,9 +43,9 @@ static void register(ConfigDataLocationResolverContext context, Binder binder, | |
| boolean isCredentialConfigured = isCredentialConfigured(loadedProperties); | ||
|
|
||
| AppConfigurationKeyVaultClientFactory keyVaultClientFactory = appConfigurationKeyVaultClientFactory(context, | ||
| isCredentialConfigured, appProperties.getMaxRetryTime()); | ||
| AppConfigurationReplicaClientsBuilder replicaClientsBuilder = replicaClientBuilder(context, binder, | ||
| keyVaultClientFactory, loadedProperties, isCredentialConfigured, appProperties.getMaxRetries()); | ||
| binder, isCredentialConfigured); | ||
| AppConfigurationReplicaClientsBuilder replicaClientsBuilder = replicaClientBuilder(context, | ||
| keyVaultClientFactory, loadedProperties, isCredentialConfigured); | ||
|
|
||
| context.getBootstrapContext().registerIfAbsent(AppConfigurationKeyVaultClientFactory.class, | ||
| InstanceSupplier.from(() -> keyVaultClientFactory)); | ||
|
|
@@ -57,17 +54,23 @@ static void register(ConfigDataLocationResolverContext context, Binder binder, | |
| } | ||
|
|
||
| private static AppConfigurationKeyVaultClientFactory appConfigurationKeyVaultClientFactory( | ||
| ConfigDataLocationResolverContext context, boolean isCredentialConfigured, Integer maxRetryTime) | ||
| ConfigDataLocationResolverContext context, Binder binder, boolean isCredentialConfigured) | ||
| throws IllegalArgumentException { | ||
|
|
||
| SecretClientCustomizer customizer = context.getBootstrapContext().getOrElse(SecretClientCustomizer.class, null); | ||
| KeyVaultSecretProvider secretProvider = context.getBootstrapContext().getOrElse(KeyVaultSecretProvider.class, | ||
| null); | ||
| SecretClientBuilderFactory secretClientFactory = context.getBootstrapContext() | ||
| .getOrElse(SecretClientBuilderFactory.class, null); | ||
|
|
||
| return new AppConfigurationKeyVaultClientFactory(customizer, secretProvider, secretClientFactory, | ||
| isCredentialConfigured, maxRetryTime); | ||
| AzureKeyVaultSecretProperties secretClientProperties = binder | ||
| .bind(AzureKeyVaultSecretProperties.PREFIX, Bindable.of(AzureKeyVaultSecretProperties.class)) | ||
| .orElseGet(AzureKeyVaultSecretProperties::new); | ||
| SecretClientBuilderFactory secretClientBuilderFactory = new SecretClientBuilderFactory(secretClientProperties); | ||
|
|
||
| context.getBootstrapContext().registerIfAbsent(SecretClientBuilderFactory.class, | ||
| InstanceSupplier.from(() -> secretClientBuilderFactory)); | ||
|
Comment on lines
+64
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I understand this change. Is the previous way (getting the factory from the bootstrap context) wrong? Can you explain to me this part in more detail please
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be easier to explain just what the new code does.
This is part of our change over to the new configuration system. I found a scenario where the SecretClientBuilderFactory hadn't been created by something else in the system before we started. So, I have to do it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. So before, we assumed that SecretClientBuilderFactory will be created by someone else (who?)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you had a dependency on the Azure Spring Key Vault library it would be created. They have one that sort of works like us. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
|
|
||
| return new AppConfigurationKeyVaultClientFactory(customizer, secretProvider, secretClientBuilderFactory, | ||
| isCredentialConfigured); | ||
| } | ||
|
|
||
| private static AppConfigurationReplicaClientFactory buildClientFactory( | ||
|
|
@@ -78,8 +81,8 @@ private static AppConfigurationReplicaClientFactory buildClientFactory( | |
|
|
||
| @SuppressWarnings("unchecked") | ||
| private static AppConfigurationReplicaClientsBuilder replicaClientBuilder(ConfigDataLocationResolverContext context, | ||
| Binder binder, AppConfigurationKeyVaultClientFactory keyVaultClientFactory, | ||
| AzureAppConfigurationProperties properties, boolean isCredentialConfigured, Integer maxRetries) { | ||
| AppConfigurationKeyVaultClientFactory keyVaultClientFactory, AzureAppConfigurationProperties properties, | ||
| boolean isCredentialConfigured) { | ||
|
|
||
| InstanceSupplier<AzureServiceClientBuilderCustomizer<ConfigurationClientBuilder>> customizer = context | ||
| .getBootstrapContext() | ||
|
|
@@ -108,8 +111,8 @@ private static AppConfigurationReplicaClientsBuilder replicaClientBuilder(Config | |
| clientCustomizer = configurationClientCustomizer.get(context.getBootstrapContext()); | ||
| } | ||
|
|
||
| return new AppConfigurationReplicaClientsBuilder(maxRetries, clientFactory, clientCustomizer, | ||
| isCredentialConfigured, keyVaultClientFactory.isConfigured()); | ||
| return new AppConfigurationReplicaClientsBuilder(clientFactory, clientCustomizer, isCredentialConfigured, | ||
| keyVaultClientFactory.isConfigured()); | ||
| } | ||
|
|
||
| private static boolean isCredentialConfigured(AbstractAzureHttpConfigurationProperties properties) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this way faster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other way doesn't work. This PR was the first one I created after merging both of the big PRs for the provider and FM and they didn't agree work. The old way you get a type error when trying to load feature flags as the Feature class in the Provider is different than the one in FM.
This make it into JSON which should be the same as reading from a file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now, thanks