mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Mark playbook objects as finalized after post_validate
After post_validate() is called on an object, there should be no need to continue looking up at parent attributes. This patch adds a new flag (_finalized) which is set to True at the end of post_validate, and getattr will not look beyond its own attributes from that point on.
This commit is contained in:
parent
375f7c515a
commit
7503875ed7
1 changed files with 10 additions and 5 deletions
|
@ -60,10 +60,13 @@ class Base:
|
||||||
# flags and misc. settings
|
# flags and misc. settings
|
||||||
_environment = FieldAttribute(isa='list')
|
_environment = FieldAttribute(isa='list')
|
||||||
_no_log = FieldAttribute(isa='bool')
|
_no_log = FieldAttribute(isa='bool')
|
||||||
_always_run = FieldAttribute(isa='bool')
|
_always_run = FieldAttribute(isa='bool')
|
||||||
_run_once = FieldAttribute(isa='bool')
|
_run_once = FieldAttribute(isa='bool')
|
||||||
_ignore_errors = FieldAttribute(isa='bool')
|
_ignore_errors = FieldAttribute(isa='bool')
|
||||||
_check_mode = FieldAttribute(isa='bool')
|
_check_mode = FieldAttribute(isa='bool')
|
||||||
|
|
||||||
|
# other internal params
|
||||||
|
_finalized = False
|
||||||
|
|
||||||
# param names which have been deprecated/removed
|
# param names which have been deprecated/removed
|
||||||
DEPRECATED_ATTRIBUTES = [
|
DEPRECATED_ATTRIBUTES = [
|
||||||
|
@ -118,7 +121,7 @@ class Base:
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
try:
|
try:
|
||||||
value = self._attributes[prop_name]
|
value = self._attributes[prop_name]
|
||||||
if value is None:
|
if value is None and not self._finalized:
|
||||||
try:
|
try:
|
||||||
if prop_name in self._cached_parent_attrs:
|
if prop_name in self._cached_parent_attrs:
|
||||||
value = self._cached_parent_attrs[prop_name]
|
value = self._cached_parent_attrs[prop_name]
|
||||||
|
@ -421,6 +424,8 @@ class Base:
|
||||||
raise AnsibleParserError("the field '%s' has an invalid value, which appears to include a variable that is undefined."
|
raise AnsibleParserError("the field '%s' has an invalid value, which appears to include a variable that is undefined."
|
||||||
" The error was: %s" % (name,e), obj=self.get_ds())
|
" The error was: %s" % (name,e), obj=self.get_ds())
|
||||||
|
|
||||||
|
self._finalized = True
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
'''
|
'''
|
||||||
Serializes the object derived from the base object into
|
Serializes the object derived from the base object into
|
||||||
|
|
Loading…
Reference in a new issue