Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support versioning configuration #1284

Merged
merged 2 commits into from
Nov 8, 2022
Merged

Conversation

jeffwang0516
Copy link
Contributor

@jeffwang0516 jeffwang0516 commented Oct 26, 2022

  • Command added
    • Enable versioning: s3cmd setversioning s3://mybucket
    • Suspend versioning: s3cmd setversioning s3://mybucket --versioning-suspended
    • Enable versioning: s3cmd setversioning s3://mybucket enable
    • Suspend versioning: s3cmd setversioning s3://mybucket disable
  • Add versioning status to command info
    $ s3cmd info s3://mybucket
    ...
    Location:  us-east-1
    Payer:     BucketOwner
    Versioning:Suspended
    Expiration Rule: none
    Policy:    none
    ...
    

Resolve #937

S3/S3.py Outdated Show resolved Hide resolved
S3/S3.py Outdated
@@ -1064,6 +1065,27 @@ def set_acl(self, uri, acl):
response = self.send_request(request)
return response

def set_versioning(self, uri, status):
headers = SortedDict(ignore_case = True)
headers['content-type'] = 'application/xml'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that you should set that.
We don't set it usually and it is not an issue. better to stay consistent.

S3/S3.py Outdated Show resolved Hide resolved
S3/S3.py Outdated
@@ -1064,6 +1065,27 @@ def set_acl(self, uri, acl):
response = self.send_request(request)
return response

def set_versioning(self, uri, status):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking the status as string directly here, it is probably better to only take an "on/off" value.

@fviard fviard added this to the 2.4.0 milestone Nov 5, 2022
@fviard
Copy link
Contributor

fviard commented Nov 5, 2022

Thank you for your contribution, this is nice to have but I did a few reviews.

@fviard
Copy link
Contributor

fviard commented Nov 5, 2022

Also, I don't like so much the following syntax to disable:
Suspend versioning: s3cmd setversioning s3://mybucket --versioning-suspended

I think that it is a little bit complicated for someone not knowing it already.

I would have prefer something like one of the following:
A)
Enable: s3cmd setversioning s3://mybucket
Disable: s3cmd delversioning s3://mybucket

B)
Enable: s3cmd setversioning s3://mybucket enable
Disable: s3cmd setversioning s3://mybucket disable

s3cmd Outdated Show resolved Hide resolved
@jeffwang0516
Copy link
Contributor Author

@fviard Thanks for the reviews! I've pushed my changes.

@fviard fviard merged commit f8eafbb into s3tools:master Nov 8, 2022
@fviard
Copy link
Contributor

fviard commented Nov 8, 2022

It looks good now, thanks for the changes.
I have merged it :-)

@fviard
Copy link
Contributor

fviard commented Nov 8, 2022

To be noted for a futur new PR, in such a case, you should "squash" your commits or have relevant commit messages.
I did not take care and so the merge added 2 commits: the original one, and the "refactoring" commit.
It is not too bad, so i don't fix that with a force push, but would be nice to take care of that in the future to have a nice git history :-)

@jeffwang0516
Copy link
Contributor Author

Got it, thanks!

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.

Add bucket operations to enable and disable versioning
2 participants