feat: Add Google Drive storage backend with custom endpoint support#613
feat: Add Google Drive storage backend with custom endpoint support#613m90 merged 9 commits intooffen:mainfrom
Conversation
|
Thanks a lot for following up on this so quickly. Two questions before I have a closer look:
|
|
|
||
| if s.c.GoogleDriveCredentialsJSON != "" { | ||
| googleDriveConfig := googledrive.Config{ | ||
| CredentialsJSON: s.c.GoogleDriveCredentialsJSON, |
There was a problem hiding this comment.
Is it also possible to pass the JSON as a string instead of as a file location here? In case yes, we could leverage the existing configuration mechanism so that:
- People can pass a JSON string to
GOOGLE_DRIVE_CREDENTIALS_JSONif they don't want to / can't mount the file - People can pass a file location using
GOOGLE_DRIVE_CREDENTIALS_JSON_FILEwhich is automatically provided by the current configuration package
There was a problem hiding this comment.
I was trying to aim to only accept FILE, as it is an oddly long string to be putting on an envvar, but gemini got lost at some point and added it for me.
Also, I know _FILE is a pattern everywhere, but I have not seen it on other variables here, should we add it?
Let me know if you think just the JSON is enough, or if you prefer both so I an either remove that logic or fix the envvars and docs.
There was a problem hiding this comment.
Also, I know _FILE is a pattern everywhere, but I have not seen it on other variables here, should we add it?
_FILE is supported automatically. If you define FOO_BAR, FOO_BAR_FILE will be accepted as well. I would also think passing the entire JSON blob as an env var will rarely be done, but like this, it'd be consistent with what's already there.
The tests were mainly copied from dropbox. But they were anchored by messages from storage.go, so I think it would be better to decouple it and fail with any ERROR message. I'm not sure if its a pattern, but the For the lint issue, I was about to ask for your help, but then I asked Gemini and he did this. |
This must mean that now the
Exactly this. Thanks, |
|
Looking into the tests more closely, I think the underlying problem is that the mock is not fully featured yet. What the test tries to do:
What the test currently does:
This is why there are assertions on the log output which are currently missing from the googledrive test case. An alternative would be looking at the files itself which is what the s3 test case does. |
|
hey @m90 thanks for your kind review. |
|
hey @m90, comming back to it =]
I took a better look at dropbox, and it seems like it is the same behavior =/
Without further looking into code, I guess we don't want non-zero exit codes in order to prevent the container from dying due to one backup failure, so the schedule (and possibly other backends) can carry on, am I right? With that guess, I figured it would be good to test this failure on a normal run as well, but it didn't fail, it actually behaved like I was expecting the tests to (keeping the container alive and displaying the error message): screenshot I have yet to learn how to properly debug golang, so my hope is that you can easily spot what is going on 😅 Any ideas? I didn't have much time this weekend 😢 so I couldn't look into the other 2 issues, but:
|
|
I think the Dropbox tests work as expected. When querying for what files exist, the mock will always return two existing files, which are backdated by these lines: so the tests go kind of like this
When I change the mock like you shown in the screenshot, I get a failing test (exits 1), which is expected.
Since all test cases use Even if it's not perfect, I think we could get the same done for Google Drive by adding a proper response here: https://github.com/offen/docker-volume-backup/pull/613/files#diff-3af2262cc057a6c13dfc4c4b0924326705ddfee2a56a7492bc7690194437dc73R95-R119 |
Sorry, I just checked and it does exit with code 1. I assumed it didn't because there's no output. But anyways, I was stuck on this thinking I was doing something wrong, but turns out that GoogleDrive behaves the same.
Bro, I had to google it to understand what it does and I'm not completly sure I got it. I just reported what I did with the help of AI 😅 which was to "wrap" the backup exec with it, like this.
That's the plan! |
This is not ideal, but there is indeed a reason for that. Looking at the code: logs=$(docker compose exec -T backup backup)
echo "$logs"
# Do some assertions on the log outputThis means Maybe it'd be a good time now to fix this and use some logs=$(docker compose exec -T backup backup | tee /dev/stderr)
# Do some assertions on the log outputLet me know if there are any open questions still, happy to help out. |
- Implement Google Drive storage backend using service account authentication - Add support for custom Google Drive API endpoints for testing - Include comprehensive test setup with mock services - Add configuration options for Google Drive credentials and folder ID - Update documentation with Google Drive configuration examples
|
I updatde my fork main and the PR was automatically closed 😅
Awesome! That solves it! =] Tests are updated, working exactly like the dropbox one. Will add the _FILE now. |
|
_FILE support fixed! Please let me know if there's something else that I missed or could be improved =] |
m90
left a comment
There was a problem hiding this comment.
Looks great, there's one tiny issue with the test output still, but if this is fixed, I would say this is ready to be shipped. Thanks a lot!
test/googledrive/run.sh
Outdated
|
|
||
| logs=$(docker compose exec -T backup backup | tee /dev/stderr) | ||
|
|
||
| echo "$logs" |
There was a problem hiding this comment.
This (and the two occurences above) isn't needed anymore now that tee is used and currently duplicates the log output, which can be a bit confusing. It's probably better to remove these.
There was a problem hiding this comment.
aw, true, I missed that.
Done!
Thank you =]
|
This is now released in v2.44.0, thank you 🎩 |
Relates to #471