mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add float and percent types for FieldAttributes
Also sets the max_fail_percentage value to the percent type.
This commit is contained in:
parent
9f95720ef7
commit
af41ba929c
2 changed files with 9 additions and 1 deletions
|
@ -289,8 +289,16 @@ class Base:
|
||||||
value = unicode(value)
|
value = unicode(value)
|
||||||
elif attribute.isa == 'int':
|
elif attribute.isa == 'int':
|
||||||
value = int(value)
|
value = int(value)
|
||||||
|
elif attribute.isa == 'float':
|
||||||
|
value = float(value)
|
||||||
elif attribute.isa == 'bool':
|
elif attribute.isa == 'bool':
|
||||||
value = boolean(value)
|
value = boolean(value)
|
||||||
|
elif attribute.isa == 'percent':
|
||||||
|
# special value, which may be an integer or float
|
||||||
|
# with an optional '%' at the end
|
||||||
|
if isinstance(value, string_types) and '%' in value:
|
||||||
|
value = value.replace('%', '')
|
||||||
|
value = float(value)
|
||||||
elif attribute.isa == 'list':
|
elif attribute.isa == 'list':
|
||||||
if value is None:
|
if value is None:
|
||||||
value = []
|
value = []
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Play(Base, Taggable, Become):
|
||||||
# Flag/Setting Attributes
|
# Flag/Setting Attributes
|
||||||
_any_errors_fatal = FieldAttribute(isa='bool', default=False)
|
_any_errors_fatal = FieldAttribute(isa='bool', default=False)
|
||||||
_force_handlers = FieldAttribute(isa='bool')
|
_force_handlers = FieldAttribute(isa='bool')
|
||||||
_max_fail_percentage = FieldAttribute(isa='string', default='0')
|
_max_fail_percentage = FieldAttribute(isa='percent')
|
||||||
_serial = FieldAttribute(isa='int', default=0)
|
_serial = FieldAttribute(isa='int', default=0)
|
||||||
_strategy = FieldAttribute(isa='string', default='linear')
|
_strategy = FieldAttribute(isa='string', default='linear')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue