Skip to content

Conversation

@ZPascal
Copy link
Contributor

@ZPascal ZPascal commented Dec 17, 2025

PR Summary: Google Cloud Secret Store Refactoring

Overview

This PR updates the Google Cloud secret store plugin to improve credential file handling with explicit type detection.

Changes

Code Refactoring

File: plugins/secretstores/googlecloud/googlecloud.go

  • Replaced API: Changed from credentials.DetectDefault() to credentials.NewCredentialsFromJSON() for more explicit credential handling
  • Remove deprecated variables: The variable DetectOptions CredentialsFile is deprecated, and the functionality has been removed.
  • Added credential file parsing: Now manually reads and parses the service account JSON file instead of relying on auto-detection
  • New helper function: Added parseFileType() to extract the type field from the service account JSON, which is required to instantiate credentials correctly
  • Improved error handling: Separate error messages for file reading vs. JSON parsing failures

Test Updates

File: plugins/secretstores/googlecloud/googlecloud_test.go

  • Updated error message assertions to reflect new parsing flow
  • Added test case for missing CA certificate path in GDCH (Google Distributed Cloud Hosted) service accounts

Test Data

New file: plugins/secretstores/googlecloud/testdata/gdch-missing-ca-cert-path.json

  • Added test fixture for GDCH service account credentials with incomplete configuration

Benefits

  • More explicit and debuggable credential initialization
  • Better error messages for troubleshooting credential file issues
  • Compatibility with the latest Google Cloud auth library
  • Improved support for GDCH (Google Distributed Cloud Hosted) authentication flows

Checklist

  • No AI generated code was used in this PR

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Dec 17, 2025
@ZPascal ZPascal marked this pull request as ready for review December 18, 2025 14:11
@srebhan
Copy link
Member

srebhan commented Dec 18, 2025

Shouldn't this just work with v0.18 which included googleapis/google-cloud-go#13317?

@ZPascal
Copy link
Contributor Author

ZPascal commented Dec 18, 2025

Shouldn't this just work with v0.18 which included googleapis/google-cloud-go#13317?

Yes, but the variable DetectOptions CredentialsFile is deprecated and I've adapted the code.

@srebhan
Copy link
Member

srebhan commented Dec 19, 2025

Ok, so the PR title should be something like "update google auth dependency"? Or you should split the PR into two where you first remove the deprecated usage and then bump the lib...

@ZPascal
Copy link
Contributor Author

ZPascal commented Dec 19, 2025

Google Cloud Secret Store Refactoring

HI @srebhan, I think it is better to split the PR. I'll take care of it.

@ZPascal ZPascal force-pushed the fix-bump-the-cloud-auth-version branch from 43acd0d to 7d8d0fc Compare December 19, 2025 18:50
@ZPascal ZPascal changed the title fix: Handle also EC keys fix: Google Cloud Secret Store Refactoring Dec 19, 2025
@ZPascal
Copy link
Contributor Author

ZPascal commented Dec 19, 2025

Google Cloud Secret Store Refactoring

HI @srebhan, I think it is better to split the PR. I'll take care of it.

Hi @srebhan, I've updated the PR. This dedicated PR to bump the version should be merged first. The deprecation is a part of the v0.18 release.

@ZPascal ZPascal force-pushed the fix-bump-the-cloud-auth-version branch from 7d8d0fc to 54ff20d Compare December 19, 2025 19:30
@ZPascal ZPascal force-pushed the fix-bump-the-cloud-auth-version branch from 54ff20d to 292b97a Compare December 19, 2025 20:13
@telegraf-tiger
Copy link
Contributor

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

Labels

fix pr to fix corresponding bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants