-
Notifications
You must be signed in to change notification settings - Fork 11
Feature of adding product manifest generating and removing #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,5 +175,5 @@ | |
| ''' | ||
|
|
||
| PROD_INFO_SUFFIX = ".prodinfo" | ||
|
|
||
| MANIFEST_SUFFIX = ".txt" | ||
| DEFAULT_ERRORS_LOG = "errors.log" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| from charon.utils.archive import extract_npm_tarball | ||
| from charon.pkgs.pkg_utils import upload_post_process, rollback_post_process | ||
| from charon.utils.strings import remove_prefix | ||
| from charon.utils.files import write_manifest | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -62,11 +63,16 @@ def __init__(self, metadata, is_version): | |
|
|
||
|
|
||
| def handle_npm_uploading( | ||
| tarball_path: str, product: str, | ||
| bucket_name=None, prefix=None, | ||
| tarball_path: str, | ||
| product: str, | ||
| bucket_name=None, | ||
| prefix=None, | ||
| aws_profile=None, | ||
| dir_=None, do_index=True, | ||
| dry_run=False | ||
| dir_=None, | ||
| do_index=True, | ||
| dry_run=False, | ||
| target=None, | ||
| manifest_bucket_name=None | ||
| ) -> str: | ||
| """ Handle the npm product release tarball uploading process. | ||
| For NPM uploading, tgz file and version metadata will be relocated based | ||
|
|
@@ -90,6 +96,7 @@ def handle_npm_uploading( | |
| valid_dirs = __get_path_tree(valid_paths, target_dir) | ||
|
|
||
| prefix_ = remove_prefix(prefix, "/") | ||
|
|
||
| logger.info("Start uploading files to s3") | ||
| client = S3Client(aws_profile=aws_profile, dry_run=dry_run) | ||
| bucket = bucket_name | ||
|
|
@@ -102,6 +109,16 @@ def handle_npm_uploading( | |
| ) | ||
| logger.info("Files uploading done\n") | ||
|
|
||
| logger.info("Start uploading manifest to s3") | ||
| if not manifest_bucket_name: | ||
| logger.warning( | ||
| 'Warning: No manifest bucket is provided, will ignore the process of manifest ' | ||
| 'uploading') | ||
| else: | ||
| manifest_name, manifest_full_path = write_manifest(valid_paths, target_dir, product) | ||
| client.upload_manifest(manifest_name, manifest_full_path, target, manifest_bucket_name) | ||
| logger.info("Manifest uploading is done\n") | ||
|
|
||
| logger.info("Start generating package.json for package: %s", package_metadata.name) | ||
| meta_files = _gen_npm_package_metadata_for_upload( | ||
| client, bucket, target_dir, package_metadata, prefix_ | ||
|
|
@@ -145,10 +162,16 @@ def handle_npm_uploading( | |
|
|
||
|
|
||
| def handle_npm_del( | ||
| tarball_path: str, product: str, | ||
| bucket_name=None, prefix=None, | ||
| aws_profile=None, dir_=None, | ||
| do_index=True, dry_run=False | ||
| tarball_path: str, | ||
| product: str, | ||
| bucket_name=None, | ||
| prefix=None, | ||
| aws_profile=None, | ||
| dir_=None, | ||
| do_index=True, | ||
| dry_run=False, | ||
| target=None, | ||
| manifest_bucket_name=None | ||
| ) -> str: | ||
| """ Handle the npm product release tarball deletion process. | ||
| * tarball_path is the location of the tarball in filesystem | ||
|
|
@@ -177,6 +200,10 @@ def handle_npm_del( | |
| ) | ||
| logger.info("Files deletion done\n") | ||
|
|
||
| logger.info("Start deleting manifest from s3") | ||
| client.delete_manifest(product, target, manifest_bucket_name) | ||
| logger.info("Manifest deletion is done\n") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this step can be skipped with a log if manifest_bucket_name is not specified. |
||
|
|
||
| logger.info("Start generating package.json for package: %s", package_name_path) | ||
| meta_files = _gen_npm_package_metadata_for_del( | ||
| client, bucket, target_dir, package_name_path, prefix_ | ||
|
|
@@ -251,8 +278,10 @@ def _gen_npm_package_metadata_for_upload( | |
| package_metadata_key = os.path.join(source_package.name, PACKAGE_JSON) | ||
| if prefix and prefix != "/": | ||
| package_metadata_key = os.path.join(prefix, package_metadata_key) | ||
| (package_json_files, success) = client.get_files(bucket_name=bucket, | ||
| prefix=package_metadata_key) | ||
| (package_json_files, success) = client.get_files( | ||
| bucket_name=bucket, | ||
| prefix=package_metadata_key | ||
| ) | ||
| if not success: | ||
| logger.warning("Error to get remote metadata files for %s", package_metadata_key) | ||
| result = source_package | ||
|
|
@@ -319,8 +348,8 @@ def _gen_npm_package_metadata_for_del( | |
| return meta_files | ||
|
|
||
|
|
||
| def _scan_metadata_paths_from_archive(path: str, prod="", dir__=None) -> Tuple[ | ||
| str, list, NPMPackageMetadata]: | ||
| def _scan_metadata_paths_from_archive(path: str, prod="", dir__=None) -> Tuple[str, list, | ||
| NPMPackageMetadata]: | ||
| tmp_root = mkdtemp(prefix=f"npm-charon-{prod}-", dir=dir__) | ||
| try: | ||
| _, valid_paths = extract_npm_tarball(path, tmp_root, True) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this step can be skipped with a log if manifest_bucket_name is not specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ligangty The case was already covered inside the delete_manifest method, others are sorted based on the comment.