Feat/gcp parameter manager#1802
Conversation
Adds a new OpenFeature provider for GCP Parameter Manager that enables reading feature flags from GCP Parameter Manager secrets. Includes the provider implementation with flag caching, value conversion, unit tests, integration tests, and a sample application demonstrating usage. Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
1. Fix race condition in the get method 2. Remove spotbugs exclusions that were copy pasted Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
- Use Reason.CACHED instead of Reason.STATIC (value is TTL-cached, not static) - Update log4j-slf4j2-impl to 2.25.4 (latest stable) - Fix pom.xml formatting - Update test assertion to match Reason.CACHED Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
…uos folder Signed-off-by: Mahesh Patil <maheshfinity@gmail.com>
There was a problem hiding this comment.
Code Review
This pull request introduces support for Google Cloud Parameter Manager as an OpenFeature provider, along with a runnable sample application. The review identified several critical issues that will cause compilation and build failures, such as commenting out the required jackson-databind dependency, using incorrect artifact IDs and package imports in the sample application, and a broken link in the documentation. Additionally, defensive null checks were recommended in the provider to prevent potential NullPointerExceptions.
| <!-- <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>2.21.1</version> | ||
| </dependency> | ||
| </dependency> --> |
There was a problem hiding this comment.
Commenting out the jackson-databind dependency will cause compilation or runtime errors because FlagValueConverter.java directly imports and uses Jackson classes (e.g., ObjectMapper, JsonNode). Since the version is managed by the Google Cloud Libraries BOM (libraries-bom) imported in dependencyManagement, you should keep the dependency declared but without a hardcoded version.
| <!-- <dependency> | |
| <groupId>com.fasterxml.jackson.core</groupId> | |
| <artifactId>jackson-databind</artifactId> | |
| <version>2.21.1</version> | |
| </dependency> | |
| </dependency> --> | |
| <dependency> | |
| <groupId>com.fasterxml.jackson.core</groupId> | |
| <artifactId>jackson-databind</artifactId> | |
| </dependency> |
| <dependency> | ||
| <groupId>dev.openfeature.contrib.providers</groupId> | ||
| <artifactId>gcp-parameter-manager</artifactId> | ||
| <version>0.0.1</version> | ||
| </dependency> |
There was a problem hiding this comment.
The artifact ID for the GCP provider is gcp, not gcp-parameter-manager. Additionally, the version should match the current version of the provider module, which is 0.0.2 in this pull request. Using the incorrect artifact ID will cause Maven build failures as the dependency cannot be resolved.
| <dependency> | |
| <groupId>dev.openfeature.contrib.providers</groupId> | |
| <artifactId>gcp-parameter-manager</artifactId> | |
| <version>0.0.1</version> | |
| </dependency> | |
| <dependency> | |
| <groupId>dev.openfeature.contrib.providers</groupId> | |
| <artifactId>gcp</artifactId> | |
| <version>0.0.2</version> | |
| </dependency> |
| import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProvider; | ||
| import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProviderOptions; |
There was a problem hiding this comment.
The package name for the newly added GcpParameterManagerProvider and its options is dev.openfeature.contrib.providers.gcp, not dev.openfeature.contrib.providers.gcpparametermanager. These incorrect imports will cause compilation failures in the sample application.
| import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProvider; | |
| import dev.openfeature.contrib.providers.gcpparametermanager.GcpParameterManagerProviderOptions; | |
| import dev.openfeature.contrib.providers.gcp.GcpParameterManagerProvider; | |
| import dev.openfeature.contrib.providers.gcp.GcpParameterManagerProviderOptions; |
| public GcpParameterManagerProvider(GcpParameterManagerProviderOptions options) { | ||
| this.options = options; | ||
| } |
There was a problem hiding this comment.
To prevent potential NullPointerExceptions during initialization, add a defensive null check for the options parameter in the constructor.
public GcpParameterManagerProvider(GcpParameterManagerProviderOptions options) {
if (options == null) {
throw new IllegalArgumentException("options must not be null");
}
this.options = options;
}| private String fetchFromGcp(String parameterName) { | ||
| try { |
There was a problem hiding this comment.
If the provider is evaluated before it is initialized, or after it has been shut down, client will be null. Accessing client.renderParameterVersion will throw a raw NullPointerException. Adding a defensive check to ensure client is initialized and throwing a GeneralError provides a much clearer error message.
| private String fetchFromGcp(String parameterName) { | |
| try { | |
| private String fetchFromGcp(String parameterName) { | |
| if (client == null) { | |
| throw new GeneralError("ParameterManagerClient is not initialized or has been shut down"); | |
| } | |
| try { |
| @@ -0,0 +1,173 @@ | |||
| # GCP Parameter Manager — OpenFeature Sample | |||
|
|
|||
| A runnable Java application demonstrating the [GCP Parameter Manager OpenFeature provider](../../providers/gcp-parameter-manager). | |||
There was a problem hiding this comment.
The link to the provider directory is incorrect. The provider is located in providers/gcp, not providers/gcp-parameter-manager.
| A runnable Java application demonstrating the [GCP Parameter Manager OpenFeature provider](../../providers/gcp-parameter-manager). | |
| A runnable Java application demonstrating the [GCP Parameter Manager OpenFeature provider](../../providers/gcp). |
|
Hey @mahpatil - are you still interested in adding this? I saw it earlier and came back to review it, and found it closed. |
|
yes @toddbaert definitely, still working on it. I was just trying to initiate some checks. |
|
OK no rush. Keep me posted. |
This PR
Adds a GCP Parameter Manager support to the GCP Provider that reads feature flags from GCP Parameter Manager config.
Includes updates to sample application under samples/gcp/ with setup/teardown script
Package: providers/gcp
Class: GcpParameterManagerProvider
Supports all OpenFeature flag types via structured or plain-text secret values
Configurable poll interval and GCP project settings
Related Issues
Fixes GCP services covered under #1420
Notes
This builds on top of the previous PR that added support for GCP Secret manager.
Follow-up Tasks
How to test