Skip to content

Commit e4777ad

Browse files
Added input verification
1 parent 66b8d2a commit e4777ad

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

plugins/modules/requeue_after.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,37 @@ class KubernetesException(Exception):
1616
'supported_by': 'community'}
1717

1818
DOCUMENTATION = '''
19-
2019
module: requeue_after
21-
2220
short_description: Tells the controller to re-trigger reconciliation after the specified time
23-
2421
version_added: "0.1"
25-
2622
author: "Venkat Ramaraju (@VenkatRamaraju)"
27-
2823
description:
2924
- Tells the controller to pause reconciliation and resume reconciliation after a specified amounts of time.
3025
If the requeue_reconciliation period is set to 't', reconciliation will occur in intervals of 't'.
31-
26+
3227
options:
3328
time:
3429
type: str
3530
description:
3631
- A string containing a time period that will be set on the returned JSON object and then used to requeue
3732
reconciliation of an event. Time can be specified in any combination of hours, minutes, and seconds.
38-
3933
'''
4034

4135
EXAMPLES = '''
42-
4336
- name: "Running the requeue_after module"
4437
requeue_after:
4538
time: 24h
46-
39+
4740
- name: "Running the requeue_after module"
4841
requeue_after:
4942
time: 30m
50-
43+
5144
- name: "Running the requeue_after module"
5245
requeue_after:
5346
time: 5s
54-
5547
'''
5648

5749
RETURN = '''
58-
5950
result:
6051
description:
6152
- If a requeue period was specified under 'time' when calling the requeue_after period from the module,
@@ -80,17 +71,20 @@ class KubernetesException(Exception):
8071
requeued after.
8172
returned: success
8273
type: str
83-
8474
'''
8575

8676
from ansible.module_utils.basic import AnsibleModule
77+
import re
8778

8879

8980
def requeue_after():
9081
module = AnsibleModule(argument_spec={
9182
'time': {'type': 'str', 'required': True},
9283
})
9384

85+
if not re.match("^[hms0-9]*$", module.params['time']):
86+
module.fail_json(msg="invalid time input")
87+
9488
result = dict(
9589
period=module.params['time'],
9690
)
@@ -103,4 +97,4 @@ def main():
10397

10498

10599
if __name__ == '__main__':
106-
main()
100+
main()

0 commit comments

Comments
 (0)