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

Add option to set NewerNoncurrentVersions to Lifecycle #1467

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

feschli4
Copy link

@feschli4 feschli4 commented Dec 9, 2024

Needed this functionality for myself and couldn't find it in your repo, so I added it.

lifecyceconfig.NoncurrentVersionExpiration only allows either _noncurrent_days or _noncurrent_versions to be set, but not both at the same time. I don't know minIO well enough to know whether it would be possible to set both at the same time. Feel free to make changes.

def __init__(self, noncurrent_days: int | None = None):
def __init__(self,
noncurrent_days: int | None = None,
noncurrent_versions: int | None = None):
Copy link
Member

Choose a reason for hiding this comment

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

  1. Rename noncurrent_versions as newer_noncurrent_versions everywhere
  2. Add validation here like
if noncurrent_days is None and newer_noncurrent_versions is None:
    raise ValueError("either noncurrent_days or newer_noncurrent_versions must be set")

Comment on lines +200 to +206

if not self._noncurrent_days and not self._noncurrent_versions:
raise ValueError("Either one value must be set")

if self._noncurrent_versions and self._noncurrent_days:
raise ValueError("Only one value can be set")

Copy link
Member

Choose a reason for hiding this comment

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

Remove this check

Comment on lines +208 to +210
SubElement(element, "NoncurrentDays",
str(self._noncurrent_days))

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SubElement(element, "NoncurrentDays",
str(self._noncurrent_days))
SubElement(element, "NoncurrentDays", str(self._noncurrent_days))

if self._noncurrent_versions:
SubElement(element, "NewerNoncurrentVersions",
str(self._noncurrent_versions))

return element

Copy link
Member

Choose a reason for hiding this comment

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

Add newer_noncurrent_versions to class NoncurrentVersionTransition too

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.

2 participants