Skip to content

feat: improve Google Drive credential flexibility and readability #176

@rmanibus

Description

@rmanibus

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCore CLI command surface and UXenhancementNew feature or request

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions