Skip to content

Commit

Permalink
Merge pull request ansible#14417 from ansible/params-default-to-str
Browse files Browse the repository at this point in the history
Module params should default to str in most cases.
  • Loading branch information
abadger committed Feb 10, 2016
2 parents 64c976a + 6276585 commit 1f0993c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ansible/module_utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def _convert(node):

FILE_COMMON_ARGUMENTS=dict(
src = dict(),
mode = dict(),
mode = dict(type='raw'),
owner = dict(),
group = dict(),
seuser = dict(),
Expand Down Expand Up @@ -574,6 +574,7 @@ def __init__(self, argument_spec, bypass_checks=False, no_log=False,
'int': self._check_type_int,
'float': self._check_type_float,
'path': self._check_type_path,
'raw': self._check_type_raw,
}
if not bypass_checks:
self._check_required_arguments()
Expand Down Expand Up @@ -1360,15 +1361,23 @@ def _check_type_path(self, value):
value = self._check_type_str(value)
return os.path.expanduser(os.path.expandvars(value))

def _check_type_raw(self, value):
return value


def _check_argument_types(self):
''' ensure all arguments have the requested type '''
for (k, v) in self.argument_spec.items():
wanted = v.get('type', None)
if wanted is None:
continue
if k not in self.params:
continue
if wanted is None:
# Mostly we want to default to str.
# For values set to None explicitly, return None instead as
# that allows a user to unset a parameter
if self.params[k] is None:
continue
wanted = 'str'

value = self.params[k]

Expand Down

0 comments on commit 1f0993c

Please sign in to comment.