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

Allow empty prefix in Filter #1053

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions minio/commonconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ def __init__(self, and_operator=None, prefix=None, tag=None):
)
if not valid:
raise ValueError("only one of and, prefix or tag must be provided")
if prefix is not None and not prefix:
raise ValueError("prefix must not be empty")
self._and_operator = and_operator
self._prefix = prefix
self._tag = tag
Expand Down
2 changes: 1 addition & 1 deletion minio/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def findtext(element, name, strict=False):
if strict:
raise ValueError("XML element <{0}> not found".format(name))
return None
return element.text
return element.text or ""


def unmarshal(cls, xmlstring):
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/lifecycleconfig_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ def test_config(self):
)
xml.marshal(config)

config = LifecycleConfig(
[
Rule(
ENABLED,
rule_filter=Filter(prefix=""),
rule_id="rule",
expiration=Expiration(days=365),
),
],
)
xml.marshal(config)

config = xml.unmarshal(
LifecycleConfig,
"""<LifeCycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
Expand Down Expand Up @@ -68,3 +80,20 @@ def test_config(self):
</LifeCycleConfiguration>""",
)
xml.marshal(config)

config = xml.unmarshal(
LifecycleConfig,
"""<LifeCycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Rule>
<ID>DeleteAfterBecomingNonCurrent</ID>
<Filter>
<Prefix></Prefix>
</Filter>
<Status>Enabled</Status>
<NoncurrentVersionExpiration>
<NoncurrentDays>100</NoncurrentDays>
</NoncurrentVersionExpiration>
</Rule>
</LifeCycleConfiguration>""",
)
xml.marshal(config)