Skip to content

Commit c847335

Browse files
authored
Google Drive SDK does not bail on bad configuration (#733)
1 parent e731e54 commit c847335

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

internal/storage/googledrive/googledrive.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import (
1212
"time"
1313

1414
"crypto/tls"
15+
"net/http"
16+
1517
"github.com/offen/docker-volume-backup/internal/errwrap"
1618
"github.com/offen/docker-volume-backup/internal/storage"
1719
"golang.org/x/oauth2"
1820
"golang.org/x/oauth2/google"
1921
"google.golang.org/api/drive/v3"
2022
"google.golang.org/api/option"
21-
"net/http"
2223
)
2324

2425
type googleDriveStorage struct {
@@ -47,6 +48,8 @@ func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error
4748
}
4849
if opts.ImpersonateSubject != "" {
4950
config.Subject = opts.ImpersonateSubject
51+
} else {
52+
return nil, errwrap.Wrap(nil, "GOOGLE_DRIVE_IMPERSONATE_SUBJECT cannot be left blank")
5053
}
5154
if opts.TokenURL != "" {
5255
config.TokenURL = opts.TokenURL

test/googledrive/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ services:
3636
GOOGLE_DRIVE_ENDPOINT: http://openapi_mock:8080
3737
GOOGLE_DRIVE_TOKEN_URL: http://oauth2_mock:8090/issuer1/token
3838
GOOGLE_DRIVE_CREDENTIALS_JSON_FILE: /etc/gdrive/credentials.json
39+
GOOGLE_DRIVE_IMPERSONATE_SUBJECT: me@example.com
3940
GOOGLE_DRIVE_FOLDER_ID: "root"
4041
volumes:
4142
- app_data:/backup/app_data:ro

0 commit comments

Comments
 (0)