Skip to content

Commit 50024dc

Browse files
committed
Fix note, err log, repos param list type, merged dir name length, typo issues
1 parent 6d4dc56 commit 50024dc

15 files changed

+42
-58
lines changed

charon/cmd/cmd_upload.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def upload(
156156
"""Upload all files from released product REPOs to Ronda
157157
Service. The REPOs point to a product released tarballs which
158158
are hosted in remote urls or local paths.
159+
Notes: It does not support multiple repos for NPM archives
159160
"""
160161
tmp_dir = work_dir
161162
try:

charon/pkgs/maven.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def __gen_digest_file(hash_file_path, meta_file_path: str, hashtype: HashType) -
262262

263263

264264
def handle_maven_uploading(
265-
repos: Union[str, List[str]],
265+
repos: List[str],
266266
prod_key: str,
267267
ignore_patterns=None,
268268
root="maven-repository",
@@ -295,8 +295,7 @@ def handle_maven_uploading(
295295
"""
296296
if targets is None:
297297
targets = []
298-
if isinstance(repos, str):
299-
repos = [repos]
298+
300299
# 1. extract tarballs
301300
tmp_root = _extract_tarballs(repos, root, prod_key, dir__=dir_)
302301

@@ -706,29 +705,16 @@ def _extract_tarballs(repos: List[str], root: str, prefix="", dir__=None) -> str
706705
extracted_dirs.append(tmp_root)
707706

708707
except BadZipFile as e:
709-
logger.error("Tarball extraction error: %s", e)
708+
logger.error("Tarball extraction error for repo %s: %s", repo, e)
710709
sys.exit(1)
711710
else:
712711
logger.error("Error: archive %s does not exist", repo)
713712
sys.exit(1)
714713

715714
# Merge all extracted directories
716715
if extracted_dirs:
717-
# Get top-level directory names for merged from all repos
718-
top_level_merged_name_dirs = []
719-
for extracted_dir in extracted_dirs:
720-
for item in os.listdir(extracted_dir):
721-
item_path = os.path.join(extracted_dir, item)
722-
# Check the root maven-repository subdirectory existence
723-
maven_repo_path = os.path.join(item_path, root)
724-
if os.path.isdir(item_path) and os.path.exists(maven_repo_path):
725-
top_level_merged_name_dirs.append(item)
726-
break
727-
728716
# Create merged directory name
729-
merged_dir_name = (
730-
"_".join(top_level_merged_name_dirs) if top_level_merged_name_dirs else "merged"
731-
)
717+
merged_dir_name = "merged_repositories"
732718
merged_dest_dir = os.path.join(final_tmp_root, merged_dir_name)
733719

734720
# Merge content from all extracted directories

tests/test_cf_maven_ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_cf_after_upload(self):
3131
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
3232
product = "commons-client-4.5.6"
3333
handle_maven_uploading(
34-
test_zip, product,
34+
[test_zip], product,
3535
targets=[('', TEST_BUCKET, 'ga', '', 'maven.repository.redhat.com')],
3636
dir_=self.tempdir,
3737
do_index=True,
@@ -52,7 +52,7 @@ def test_cf_after_del(self):
5252
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
5353
product_456 = "commons-client-4.5.6"
5454
handle_maven_uploading(
55-
test_zip, product_456,
55+
[test_zip], product_456,
5656
targets=[('', TEST_BUCKET, 'ga', '', 'maven.repository.redhat.com')],
5757
dir_=self.tempdir,
5858
do_index=True

tests/test_cf_reindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_cf_maven_after_reindex(self):
4040
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
4141
product_456 = "commons-client-4.5.6"
4242
handle_maven_uploading(
43-
test_zip, product_456,
43+
[test_zip], product_456,
4444
targets=[('', TEST_BUCKET, 'ga', '', 'maven.repository.redhat.com')],
4545
dir_=self.tempdir
4646
)

tests/test_extract_tarballs.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_extract_tarballs(self):
1313
]
1414
final_merged_path = _extract_tarballs(mvn_tarballs, "maven-repository")
1515
expected_dir = os.path.join(
16-
final_merged_path, "commons-client-4.5.6_commons-client-4.5.9", "maven-repository"
16+
final_merged_path, "merged_repositories", "maven-repository"
1717
)
1818
self.assertTrue(os.path.exists(expected_dir))
1919

@@ -26,6 +26,3 @@ def test_extract_tarballs(self):
2626
for expected_file in expected_files:
2727
file_path = os.path.join(expected_dir, expected_file)
2828
self.assertTrue(os.path.exists(file_path))
29-
30-
def test_download_archive(self):
31-
pass

tests/test_manifest_del.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __prepare_maven_content(self):
7777
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
7878
product = "commons-client-4.5.6"
7979
handle_maven_uploading(
80-
test_zip, product,
80+
[test_zip], product,
8181
targets=[(TEST_TARGET, TEST_BUCKET, '', '')],
8282
dir_=self.tempdir,
8383
do_index=False,

tests/test_manifest_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_maven_manifest_upload(self):
3636
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
3737
product = "commons-client-4.5.6"
3838
handle_maven_uploading(
39-
test_zip, product,
39+
[test_zip], product,
4040
targets=[(TEST_TARGET, TEST_BUCKET, '', '')],
4141
dir_=self.tempdir,
4242
do_index=False,

tests/test_maven_del.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def __prepare_content(self, prefix=None):
190190
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
191191
product_456 = "commons-client-4.5.6"
192192
handle_maven_uploading(
193-
test_zip, product_456,
193+
[test_zip], product_456,
194194
targets=[('', TEST_BUCKET, prefix, '')],
195195
dir_=self.tempdir,
196196
do_index=False
@@ -199,7 +199,7 @@ def __prepare_content(self, prefix=None):
199199
test_zip = os.path.join(INPUTS, "commons-client-4.5.9.zip")
200200
product_459 = "commons-client-4.5.9"
201201
handle_maven_uploading(
202-
test_zip, product_459,
202+
[test_zip], product_459,
203203
targets=[('', TEST_BUCKET, prefix, '')],
204204
dir_=self.tempdir,
205205
do_index=False

tests/test_maven_del_multi_tgts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def __prepare_content(self, prefix=None):
259259
product_456 = "commons-client-4.5.6"
260260
targets_ = [('', TEST_BUCKET, prefix, ''), ('', TEST_BUCKET_2, prefix, '')]
261261
handle_maven_uploading(
262-
test_zip, product_456,
262+
[test_zip], product_456,
263263
targets=targets_,
264264
dir_=self.tempdir,
265265
do_index=False
@@ -268,7 +268,7 @@ def __prepare_content(self, prefix=None):
268268
test_zip = os.path.join(INPUTS, "commons-client-4.5.9.zip")
269269
product_459 = "commons-client-4.5.9"
270270
handle_maven_uploading(
271-
test_zip, product_459,
271+
[test_zip], product_459,
272272
targets=targets_,
273273
dir_=self.tempdir,
274274
do_index=False

tests/test_maven_index.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_uploading_index(self):
3737
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
3838
product = "commons-client-4.5.6"
3939
handle_maven_uploading(
40-
test_zip, product,
40+
[test_zip], product,
4141
targets=[('', TEST_BUCKET, '', '')],
4242
dir_=self.tempdir
4343
)
@@ -79,15 +79,15 @@ def test_overlap_upload_index(self):
7979
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
8080
product_456 = "commons-client-4.5.6"
8181
handle_maven_uploading(
82-
test_zip, product_456,
82+
[test_zip], product_456,
8383
targets=[('', TEST_BUCKET, '', '')],
8484
dir_=self.tempdir
8585
)
8686

8787
test_zip = os.path.join(INPUTS, "commons-client-4.5.9.zip")
8888
product_459 = "commons-client-4.5.9"
8989
handle_maven_uploading(
90-
test_zip, product_459,
90+
[test_zip], product_459,
9191
targets=[('', TEST_BUCKET, '', '')],
9292
dir_=self.tempdir
9393
)
@@ -130,7 +130,7 @@ def test_re_index(self):
130130
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
131131
product = "commons-client-4.5.6"
132132
handle_maven_uploading(
133-
test_zip, product,
133+
[test_zip], product,
134134
targets=[('', TEST_BUCKET, '', '')],
135135
dir_=self.tempdir
136136
)
@@ -221,7 +221,7 @@ def __test_upload_index_with_prefix(self, prefix: str):
221221
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
222222
product = "commons-client-4.5.6"
223223
handle_maven_uploading(
224-
test_zip, product,
224+
[test_zip], product,
225225
targets=[('', TEST_BUCKET, prefix, '')],
226226
dir_=self.tempdir
227227
)
@@ -403,15 +403,15 @@ def __prepare_content(self, prefix=None):
403403
test_zip = os.path.join(INPUTS, "commons-client-4.5.6.zip")
404404
product_456 = "commons-client-4.5.6"
405405
handle_maven_uploading(
406-
test_zip, product_456,
406+
[test_zip], product_456,
407407
targets=[('', TEST_BUCKET, prefix, '')],
408408
dir_=self.tempdir
409409
)
410410

411411
test_zip = os.path.join(INPUTS, "commons-client-4.5.9.zip")
412412
product_459 = "commons-client-4.5.9"
413413
handle_maven_uploading(
414-
test_zip, product_459,
414+
[test_zip], product_459,
415415
targets=[('', TEST_BUCKET, prefix, '')],
416416
dir_=self.tempdir
417417
)

0 commit comments

Comments
 (0)