Skip to content

Commit 1799789

Browse files
authored
Add exception when no dependencies in Chart.yaml (#186)
Signed-off-by: Jiyeong Seok <[email protected]>
1 parent bf75f72 commit 1799789

File tree

1 file changed

+17
-10
lines changed
  • src/fosslight_dependency/package_manager

1 file changed

+17
-10
lines changed

src/fosslight_dependency/package_manager/Helm.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,32 @@ def run_plugin(self):
4444
logger.error(f"Failed to build helm dependency: {cmd}")
4545
ret = False
4646
else:
47-
shutil.copytree(charts_dir, self.tmp_charts_dir)
48-
shutil.rmtree(charts_dir, ignore_errors=True)
49-
50-
ret = extract_compressed_dir(self.tmp_charts_dir, self.tmp_charts_dir, False)
51-
if not ret:
52-
logger.error(f'Fail to extract compressed dir: {self.tmp_charts_dir}')
53-
else:
54-
logger.warning('Success to extract compressed dir')
47+
if not os.path.isdir(charts_dir):
48+
logger.warning(f"Cannot create {charts_dir} because of no dependencies in Chart.yaml. "
49+
f"So you don't need to analyze dependency.")
50+
return True
51+
else:
52+
shutil.copytree(charts_dir, self.tmp_charts_dir)
53+
shutil.rmtree(charts_dir, ignore_errors=True)
54+
if ret:
55+
ret = extract_compressed_dir(self.tmp_charts_dir, self.tmp_charts_dir, False)
56+
if not ret:
57+
logger.error(f'Fail to extract compressed dir: {self.tmp_charts_dir}')
58+
else:
59+
logger.warning('Success to extract compressed dir')
5560

5661
return ret
5762

5863
def parse_oss_information(self, f_name):
5964
dep_item_list = []
6065
sheet_list = []
66+
_dependencies = 'dependencies'
6167

6268
with open(f_name, 'r', encoding='utf8') as yaml_fp:
6369
yaml_f = yaml.safe_load(yaml_fp)
64-
for dep in yaml_f['dependencies']:
65-
dep_item_list.append(dep['name'])
70+
if _dependencies in yaml_f:
71+
for dep in yaml_f[_dependencies]:
72+
dep_item_list.append(dep['name'])
6673
for dep in dep_item_list:
6774
try:
6875
f_path = os.path.join(self.tmp_charts_dir, dep, f_name)

0 commit comments

Comments
 (0)