Skip to content

[Java] Support dynamic secret provider registration via SecretRegistrar - #39940

Open
shunping wants to merge 1 commit into
apache:masterfrom
shunping:secret-manager-4
Open

[Java] Support dynamic secret provider registration via SecretRegistrar#39940
shunping wants to merge 1 commit into
apache:masterfrom
shunping:secret-manager-4

Conversation

@shunping

@shunping shunping commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Previously, Secret.java had hardcoded switch statements and factory calls for specific secret managers (such as Google Cloud Secret Manager and HSM-generated secrets). Supporting a new secret manager required directly modifying Secret.java.

This PR refactors Secret to follow Apache Beam's standard Service Provider Interface (SPI) pattern (similar to FileSystems / FileSystemRegistrar). It allows secret providers to register dynamically at runtime via ServiceLoader and @AutoService, decoupling the core Secret management from specific provider implementations.

@shunping shunping changed the title Refactor GCP related secret classes and tests to extensions/google-cloud-platform-core Move GCP related secret classes and tests to extensions/google-cloud-platform-core Aug 31, 2026
@shunping
shunping force-pushed the secret-manager-4 branch 2 times, most recently from 23d91d2 to 2f5bde7 Compare September 1, 2026 02:33
Follow the FileSystems registration pattern by introducing SecretRegistrar SPI
and auto-service discovery in Secret.java. This eliminates hardcoded secret provider
logic in Secret.java and allows modular extension for new secret managers.
@shunping shunping changed the title Move GCP related secret classes and tests to extensions/google-cloud-platform-core [Java] Support dynamic secret provider registration via SecretRegistrar Sep 1, 2026
@shunping
shunping marked this pull request as ready for review September 1, 2026 16:13
@shunping

shunping commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator Author

r: @Abacn

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers


/** {@link AutoService} registrar for the {@link GcpSecret}. */
@AutoService(SecretRegistrar.class)
public class GcpSecretRegistrar implements SecretRegistrar {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike current on-request logic, autoService is loaded in JVM. Shall we move Gcp... classes into extensions/gcp-core module?

Then users not using GCP services or Dataflow runners won't see the service get loaded.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I am preparing a follow-up PR for this, because there are a bunch of gbek tests that need to be relocated as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants