mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-10-24 14:05:54 +08:00
Fix googledrive support for _FILE credentials
This commit is contained in:
parent
4722963c2a
commit
eb8ca52e34
3 changed files with 15 additions and 9 deletions
|
|
@ -389,12 +389,19 @@ The values for each key currently match its default.
|
|||
########### GOOGLE DRIVE STORAGE
|
||||
|
||||
# The JSON credentials for a Google service account with access to Google Drive.
|
||||
# The value should be the path to a json file you mounted into the container.
|
||||
# You can provide either:
|
||||
# 1. The actual JSON content directly
|
||||
# 2. Use the _FILE suffix to load from a file (e.g., GOOGLE_DRIVE_CREDENTIALS_JSON_FILE)
|
||||
#
|
||||
# Example:
|
||||
# Examples:
|
||||
# Option 1 - JSON content:
|
||||
# docker run [...] \
|
||||
# -e GOOGLE_DRIVE_CREDENTIALS_JSON='{"type":"service_account",...}'
|
||||
#
|
||||
# Option 2 - Using _FILE suffix (recommended for Docker Secrets):
|
||||
# docker run [...] \
|
||||
# -v ./credentials.json:/creds/google-credentials.json \
|
||||
# -e GOOGLE_DRIVE_CREDENTIALS_JSON=/creds/google-credentials.json
|
||||
# -e GOOGLE_DRIVE_CREDENTIALS_JSON_FILE=/creds/google-credentials.json
|
||||
#
|
||||
# GOOGLE_DRIVE_CREDENTIALS_JSON=""
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,10 @@ type Config struct {
|
|||
// NewStorageBackend creates and initializes a new Google Drive storage backend.
|
||||
func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error) {
|
||||
ctx := context.Background()
|
||||
b, err := os.ReadFile(opts.CredentialsJSON)
|
||||
if err != nil {
|
||||
return nil, errwrap.Wrap(err, "unable to read credentials")
|
||||
}
|
||||
config, err := google.JWTConfigFromJSON(b, drive.DriveScope)
|
||||
|
||||
credentialsBytes := []byte(opts.CredentialsJSON)
|
||||
|
||||
config, err := google.JWTConfigFromJSON(credentialsBytes, drive.DriveScope)
|
||||
if err != nil {
|
||||
return nil, errwrap.Wrap(err, "unable to parse credentials")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ services:
|
|||
BACKUP_PRUNING_PREFIX: test
|
||||
GOOGLE_DRIVE_ENDPOINT: http://openapi_mock:8080
|
||||
GOOGLE_DRIVE_TOKEN_URL: http://oauth2_mock:8090/issuer1/token
|
||||
GOOGLE_DRIVE_CREDENTIALS_JSON: /etc/gdrive/credentials.json
|
||||
GOOGLE_DRIVE_CREDENTIALS_JSON_FILE: /etc/gdrive/credentials.json
|
||||
GOOGLE_DRIVE_FOLDER_ID: "root"
|
||||
volumes:
|
||||
- app_data:/backup/app_data:ro
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue