You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
#!/usr/bin/env python |
|
|
|
import os |
|
import subprocess |
|
import sys |
|
|
|
|
|
EXCLUDED_DIRS = ('contrib',) |
|
|
|
|
|
def main(args): |
|
if len(args) != 1: |
|
raise SystemExit("Takes one argument, the path to the templates") |
|
|
|
path = args[0] |
|
got_error = False |
|
for root, dirs, files in os.walk(path): |
|
for excluded in EXCLUDED_DIRS: |
|
if excluded in dirs: |
|
dirs.remove(excluded) |
|
for name in files: |
|
if name.endswith((".yaml", ".template")): |
|
got_error = validate(root, name) |
|
sys.exit(int(got_error)) |
|
|
|
|
|
def validate(base, name): |
|
basename, ext = os.path.splitext(name) |
|
if basename.endswith("_env"): |
|
return |
|
args = ["heat", "template-validate", "-f", os.path.join(base, name)] |
|
base_env = "%s_env%s" % (basename, ext) |
|
env = os.path.join(base, base_env) |
|
if os.path.exists(env): |
|
args.extend(["-e", env]) |
|
try: |
|
output = subprocess.check_output(args) |
|
except subprocess.CalledProcessError as e: |
|
print "Got error validating %s" % name |
|
return True |
|
else: |
|
return False |
|
|
|
|
|
if __name__ == '__main__': |
|
main(sys.argv[1:])
|
|
|