Skip to content

Commit

Permalink
Add exception when no dependencies in Chart.yaml (#186)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyeong Seok <[email protected]>
  • Loading branch information
dd-jy authored Jan 5, 2024
1 parent bf75f72 commit 1799789
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/fosslight_dependency/package_manager/Helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,32 @@ def run_plugin(self):
logger.error(f"Failed to build helm dependency: {cmd}")
ret = False
else:
shutil.copytree(charts_dir, self.tmp_charts_dir)
shutil.rmtree(charts_dir, ignore_errors=True)

ret = extract_compressed_dir(self.tmp_charts_dir, self.tmp_charts_dir, False)
if not ret:
logger.error(f'Fail to extract compressed dir: {self.tmp_charts_dir}')
else:
logger.warning('Success to extract compressed dir')
if not os.path.isdir(charts_dir):
logger.warning(f"Cannot create {charts_dir} because of no dependencies in Chart.yaml. "
f"So you don't need to analyze dependency.")
return True
else:
shutil.copytree(charts_dir, self.tmp_charts_dir)
shutil.rmtree(charts_dir, ignore_errors=True)
if ret:
ret = extract_compressed_dir(self.tmp_charts_dir, self.tmp_charts_dir, False)
if not ret:
logger.error(f'Fail to extract compressed dir: {self.tmp_charts_dir}')
else:
logger.warning('Success to extract compressed dir')

return ret

def parse_oss_information(self, f_name):
dep_item_list = []
sheet_list = []
_dependencies = 'dependencies'

with open(f_name, 'r', encoding='utf8') as yaml_fp:
yaml_f = yaml.safe_load(yaml_fp)
for dep in yaml_f['dependencies']:
dep_item_list.append(dep['name'])
if _dependencies in yaml_f:
for dep in yaml_f[_dependencies]:
dep_item_list.append(dep['name'])
for dep in dep_item_list:
try:
f_path = os.path.join(self.tmp_charts_dir, dep, f_name)
Expand Down

0 comments on commit 1799789

Please sign in to comment.