Skip to content

Add Google Cloud Storage (GCS) backend support#1

Open
joeybaer wants to merge 1 commit intomainfrom
add-gcs-backend
Open

Add Google Cloud Storage (GCS) backend support#1
joeybaer wants to merge 1 commit intomainfrom
add-gcs-backend

Conversation

@joeybaer
Copy link
Owner

Summary

Adds GCS backend support alongside the existing S3 backend.

Implementation

  • GCS Backend (pkg/backends/gcs.go)

    • Implements Backend interface with full GCS support
    • Uses Application Default Credentials
    • Compatible with Workload Identity Federation for GitHub Actions
    • Stores cache metadata in object custom metadata
    • Properly manages GCS client lifecycle
  • Configuration (main.go)

    • Added -gcs-bucket and -gcs-prefix flags
    • Added GCS_BUCKET and GCS_PREFIX environment variables
    • Updated all command help text
    • Added GCS backend case in createBackend()
  • Integration Test (integrationtests/integration_gcs_test.go)

    • Full integration test following S3 test pattern
    • Requires TEST_GCS_BUCKET environment variable
  • Dependencies (go.mod)

    • Added cloud.google.com/go/storage v1.59.1

Usage

# Using flags
./gobuildcache -backend=gcs -gcs-bucket=my-cache-bucket

# Using environment variables
export GCS_BUCKET=my-cache-bucket
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
./gobuildcache -backend=gcs

Testing

# Build
go build .

# Integration test
export TEST_GCS_BUCKET=my-test-bucket
go test -v ./integrationtests -run TestCacheIntegrationGCS

Implements GCS backend alongside existing S3 backend.

- Add pkg/backends/gcs.go with GCS implementation
  - Uses Application Default Credentials (ADC)
  - Supports Workload Identity Federation
  - Stores metadata in object custom metadata
  - Properly closes GCS client resources

- Update main.go with GCS flags and configuration
  - Add -gcs-bucket and -gcs-prefix flags
  - Add GCS_BUCKET and GCS_PREFIX environment variables
  - Add gcs case in createBackend()

- Add integrationtests/integration_gcs_test.go
  - Requires TEST_GCS_BUCKET environment variable

- Update go.mod with cloud.google.com/go/storage dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant