aboutsummaryrefslogtreecommitdiffstats
path: root/tools/yaml-validate.py
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2016-01-12 19:03:30 +0000
committerSteven Hardy <shardy@redhat.com>2016-03-23 15:35:28 +0000
commit5cb0134c8462daf68b42525809fd4c0ce774ec5a (patch)
treea8e50f7a1b238a08e38bb74da66665bd838cb7f4 /tools/yaml-validate.py
parent1dd6de571c79625ccf5520895b764bb9c2dd75d3 (diff)
Add simple parameter test to yaml-validate.py
Output a warning for parameters which look unused, this should help developers clean up the template a bit, and eventually could maybe be developed further into something we can use for gating. Change-Id: Ide4fbe3c85854cbddee44801d39ae73003d63bb8
Diffstat (limited to 'tools/yaml-validate.py')
-rwxr-xr-xtools/yaml-validate.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/yaml-validate.py b/tools/yaml-validate.py
index fe690d8c..2da873d0 100755
--- a/tools/yaml-validate.py
+++ b/tools/yaml-validate.py
@@ -24,10 +24,19 @@ def exit_usage():
def validate(filename):
print('Validating %s' % filename)
try:
- yaml.load(open(filename).read())
+ tpl = yaml.load(open(filename).read())
except Exception:
print(traceback.format_exc())
return 1
+ # yaml is OK, now walk the parameters and output a warning for unused ones
+ for p in tpl.get('parameters', {}):
+ str_p = '\'%s\'' % p
+ in_resources = str_p in str(tpl.get('resources', {}))
+ in_outputs = str_p in str(tpl.get('outputs', {}))
+ if not in_resources and not in_outputs:
+ print('Warning: parameter %s in template %s appears to be unused'
+ % (p, filename))
+
return 0
if len(sys.argv) < 2: