mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 21:55:56 +03:00
[PR #1016] [MERGED] Fix ACL errors for newly created and pre-existing blobs #1118
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#1118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fsouza/fake-gcs-server/pull/1016
Author: @RachitSharma2001
Created: 12/22/2022
Status: ✅ Merged
Merged: 1/8/2023
Merged by: @fsouza
Base:
main← Head:fix_944_945📝 Commits (3)
4b0dd7eFix ACL errors for existing and pre-existing blobs2312a77internal/backend: generalize code a bit0085fc6Remove some comments📊 Changes
7 files changed (+113 additions, -27 deletions)
View changed files
📝
fakestorage/object.go(+23 -3)📝
internal/backend/fs.go(+7 -13)📝
internal/backend/memory.go(+5 -10)📝
internal/backend/object.go(+21 -0)📝
internal/backend/storage.go(+1 -1)📝
main.go(+7 -0)📝
main_test.go(+49 -0)📄 Description
This fixes #944 and fixes #945.
The following two python snippets no longer crash and instead give the correct output. The first one is for a pre-existing blob (thus fixing #944):
The outputs:
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}]
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}, {'entity': 'allUsers', 'role': 'READER'}]
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}]
The second snippet shows how for a newly created blob, the acl's also update when make_public() and make_private() are called:
The outputs:
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}]
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}, {'entity': 'allUsers', 'role': 'READER'}]
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}]
Explanation of my implementation:
For fixing #944:
Within main.go, when it reads all the existing files within the bucket, it previously never set an ACL for any of these objects. I assumed that for these pre-existing blobs, the ACL for each of them would just be
[{'entity': 'projectOwner-test-project', 'role': 'OWNER'}].For fixing #945:
From looking at how the python API updates the ACL's, I found that rather than sending a POST to the endpoint
/b/{bucketName}/o/{objectName:.+}/acl, it instead sends a PATCH request to the endpoint/b/{bucketName}/o/{objectName:.+}.Thus, I needed to update the
patchObjectmethod withinfakestorage/object.goto detect if new ACL's are passed in and update the object's ACL if so.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.