From c9feabe2053e70be297dfa171e8cfb5eb5b9008f Mon Sep 17 00:00:00 2001 From: n30nx Date: Mon, 20 Mar 2023 22:18:05 +0300 Subject: [PATCH] fix: directory not empty & permission error (#677) --- terraform_compliance/extensions/terraform.py | 2 ++ terraform_compliance/main.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/terraform_compliance/extensions/terraform.py b/terraform_compliance/extensions/terraform.py index a869f548..ee982377 100644 --- a/terraform_compliance/extensions/terraform.py +++ b/terraform_compliance/extensions/terraform.py @@ -583,6 +583,8 @@ def parse(self): for _, resource in self.resources.items(): self._expand_resource_tags(resource) + + self.cache.close() def _add_action_status(self): ''' diff --git a/terraform_compliance/main.py b/terraform_compliance/main.py index 1753cef4..861e6863 100644 --- a/terraform_compliance/main.py +++ b/terraform_compliance/main.py @@ -1,4 +1,5 @@ import os +import shutil import atexit from argparse import ArgumentParser from tempfile import mkdtemp @@ -35,7 +36,7 @@ class ArgHandling(object): def cleanup(): - os.remove(Defaults().cache_file) + shutil.rmtree(Defaults().cache_dir) def cli(arghandling=ArgHandling(), argparser=ArgumentParser(prog=__app_name__,