is-empty conditions should accept missing values
Returning False from is-empty condition on missing values seems extremely confusing and rules out some potential use cases. Closes-Bug: #1578184 Change-Id: I8f976516f89367512e2ffae2815085be1776b6f6
This commit is contained in:
parent
77b4725261
commit
50b989474d
@ -69,6 +69,7 @@ class NeCondition(SimpleCondition):
|
|||||||
|
|
||||||
class EmptyCondition(base.RuleConditionPlugin):
|
class EmptyCondition(base.RuleConditionPlugin):
|
||||||
REQUIRED_PARAMS = set()
|
REQUIRED_PARAMS = set()
|
||||||
|
ALLOW_NONE = True
|
||||||
|
|
||||||
def check(self, node_info, field, params, **kwargs):
|
def check(self, node_info, field, params, **kwargs):
|
||||||
return field in ('', None, [], {})
|
return field in ('', None, [], {})
|
||||||
|
@ -320,6 +320,7 @@ class Test(Base):
|
|||||||
{'field': 'inventory.interfaces[*].ipv4_address',
|
{'field': 'inventory.interfaces[*].ipv4_address',
|
||||||
'op': 'contains', 'value': r'127\.0\.0\.1',
|
'op': 'contains', 'value': r'127\.0\.0\.1',
|
||||||
'invert': True, 'multiple': 'all'},
|
'invert': True, 'multiple': 'all'},
|
||||||
|
{'field': 'i.do.not.exist', 'op': 'is-empty'},
|
||||||
],
|
],
|
||||||
'actions': [
|
'actions': [
|
||||||
{'action': 'set-attribute', 'path': '/extra/foo',
|
{'action': 'set-attribute', 'path': '/extra/foo',
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixed the "is-empty" condition to return True on missing values.
|
Loading…
Reference in New Issue
Block a user