From 328e4051977f7b0c5e645b11638c91b60f3674f6 Mon Sep 17 00:00:00 2001 From: n30nx <22144985+n30nx@users.noreply.github.com> Date: Mon, 20 Mar 2023 13:48:12 +0300 Subject: [PATCH] feat: delete temp file (#677) (#685) --- terraform_compliance/main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/terraform_compliance/main.py b/terraform_compliance/main.py index 8da2328c..1753cef4 100644 --- a/terraform_compliance/main.py +++ b/terraform_compliance/main.py @@ -1,4 +1,5 @@ import os +import atexit from argparse import ArgumentParser from tempfile import mkdtemp from git import Repo @@ -33,8 +34,14 @@ class ArgHandling(object): pass +def cleanup(): + os.remove(Defaults().cache_file) + + def cli(arghandling=ArgHandling(), argparser=ArgumentParser(prog=__app_name__, description='BDD Test Framework for Hashicorp terraform')): + atexit.register(cleanup) + args = arghandling parser = argparser parser.add_argument('--terraform', '-t', dest='terraform_file', metavar='terraform_file', type=str, nargs='?', @@ -151,4 +158,4 @@ def cli(arghandling=ArgHandling(), argparser=ArgumentParser(prog=__app_name__, if __name__ == '__main__': - cli() \ No newline at end of file + cli()