From 50b989474d874c6004dd2b4f0c1ec598007a2fcb Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Mon, 25 Apr 2016 19:37:03 +0200 Subject: [PATCH] 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 --- ironic_inspector/plugins/rules.py | 1 + ironic_inspector/test/functional.py | 1 + releasenotes/notes/is-empty-missing-a590d580cb62761d.yaml | 3 +++ 3 files changed, 5 insertions(+) create mode 100644 releasenotes/notes/is-empty-missing-a590d580cb62761d.yaml diff --git a/ironic_inspector/plugins/rules.py b/ironic_inspector/plugins/rules.py index 6d96fcb58..436965fc1 100644 --- a/ironic_inspector/plugins/rules.py +++ b/ironic_inspector/plugins/rules.py @@ -69,6 +69,7 @@ class NeCondition(SimpleCondition): class EmptyCondition(base.RuleConditionPlugin): REQUIRED_PARAMS = set() + ALLOW_NONE = True def check(self, node_info, field, params, **kwargs): return field in ('', None, [], {}) diff --git a/ironic_inspector/test/functional.py b/ironic_inspector/test/functional.py index 023c9d87b..88241e0ae 100644 --- a/ironic_inspector/test/functional.py +++ b/ironic_inspector/test/functional.py @@ -320,6 +320,7 @@ class Test(Base): {'field': 'inventory.interfaces[*].ipv4_address', 'op': 'contains', 'value': r'127\.0\.0\.1', 'invert': True, 'multiple': 'all'}, + {'field': 'i.do.not.exist', 'op': 'is-empty'}, ], 'actions': [ {'action': 'set-attribute', 'path': '/extra/foo', diff --git a/releasenotes/notes/is-empty-missing-a590d580cb62761d.yaml b/releasenotes/notes/is-empty-missing-a590d580cb62761d.yaml new file mode 100644 index 000000000..c048fdcf3 --- /dev/null +++ b/releasenotes/notes/is-empty-missing-a590d580cb62761d.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Fixed the "is-empty" condition to return True on missing values.