Problem
The Google Drive source (gdrive.go) currently only accepts credentials via file paths or secret refs. This limits library users who manage auth externally and CI/CD environments where mounting credential files is inconvenient.
Additionally, the auth logic in NewGDriveSource is a 60-line nested if/else chain — hard to read and extend.
Proposed Solution
Library-level (pkg/source)
WithDriveService(srv) — inject a pre-built *drive.Service, skipping all internal auth (escape hatch for ADC, custom TokenSource, etc.)
WithCredsJSON(data) — provide credentials as inline JSON bytes (OAuth client or service account), mirroring rclone's service_account_credentials
- Refactor the auth if/else chain into focused helpers:
buildDriveService, loadCredsBytes, serviceFromCredsBytes, resolveDriveName
CLI-level (cmd/cloudstic)
--google-credentials-json flag + GOOGLE_CREDENTIALS_JSON env var
- Wire through profiles (
ProfileAuth.GoogleCredsJSON, BackupProfile.GoogleCredsJSON)
Documentation
- Update user guide with credential priorities, usage examples, and env var table
Comparison with Other Tools
| Tool |
Inline JSON support |
| rclone |
✅ service_account_credentials |
| duplicacy |
❌ file only |
| cloudstic (after this) |
✅ --google-credentials-json / GOOGLE_CREDENTIALS_JSON |
Problem
The Google Drive source (
gdrive.go) currently only accepts credentials via file paths or secret refs. This limits library users who manage auth externally and CI/CD environments where mounting credential files is inconvenient.Additionally, the auth logic in
NewGDriveSourceis a 60-line nested if/else chain — hard to read and extend.Proposed Solution
Library-level (pkg/source)
WithDriveService(srv)— inject a pre-built*drive.Service, skipping all internal auth (escape hatch for ADC, custom TokenSource, etc.)WithCredsJSON(data)— provide credentials as inline JSON bytes (OAuth client or service account), mirroring rclone'sservice_account_credentialsbuildDriveService,loadCredsBytes,serviceFromCredsBytes,resolveDriveNameCLI-level (cmd/cloudstic)
--google-credentials-jsonflag +GOOGLE_CREDENTIALS_JSONenv varProfileAuth.GoogleCredsJSON,BackupProfile.GoogleCredsJSON)Documentation
Comparison with Other Tools
service_account_credentials--google-credentials-json/GOOGLE_CREDENTIALS_JSON