added sort_key within json dump and addressed linting issue

pull/82829/head
Thomas Wang 8 months ago
parent 22909f56b6
commit b3ec5d7d7c

@ -1187,7 +1187,7 @@ def _build_files_manifest_distlib(b_collection_path, namespace, name, manifest_c
) )
manifest['files'].append(manifest_entry) manifest['files'].append(manifest_entry)
manifest["files"].sort(key=lambda x: x["name"])
return manifest return manifest
@ -1260,6 +1260,7 @@ def _build_files_manifest_walk(b_collection_path, namespace, name, ignore_patter
) )
_walk(b_collection_path, b_collection_path) _walk(b_collection_path, b_collection_path)
manifest["files"].sort(key=lambda x: x["name"])
return manifest return manifest
@ -1306,7 +1307,7 @@ def _build_collection_tar(
"""Build a tar.gz collection artifact from the manifest data.""" """Build a tar.gz collection artifact from the manifest data."""
file_manifest["files"].sort(key=lambda x: x["name"]) file_manifest["files"].sort(key=lambda x: x["name"])
files_manifest_json = to_bytes(json.dumps(file_manifest, indent=True), errors='surrogate_or_strict') files_manifest_json = to_bytes(json.dumps(file_manifest, indent=True), errors='surrogate_or_strict')
collection_manifest['file_manifest_file']['chksum_sha256'] = secure_hash_s(files_manifest_json, hash_func=sha256) files_manifest_json = to_bytes(json.dumps(file_manifest, indent=True, sort_keys=True), errors='surrogate_or_strict')
collection_manifest_json = to_bytes(json.dumps(collection_manifest, indent=True), errors='surrogate_or_strict') collection_manifest_json = to_bytes(json.dumps(collection_manifest, indent=True), errors='surrogate_or_strict')
with _tempdir() as b_temp_path: with _tempdir() as b_temp_path:

@ -83,7 +83,7 @@
- name: Define extraction path - name: Define extraction path
set_fact: set_fact:
extraction_path: "/tmp/ansible_collections_extraction" extraction_path: "/tmp/new_ansible_collections_extraction"
- name: Ensure extraction directory exists - name: Ensure extraction directory exists
file: file:
@ -99,7 +99,7 @@
- name: Slurp FILES.json content - name: Slurp FILES.json content
slurp: slurp:
src: "/tmp/ansible_collections_extraction/FILES.json" src: "/tmp/new_ansible_collections_extraction/FILES.json"
register: files_content register: files_content
- name: Decode FILES.json content - name: Decode FILES.json content

Loading…
Cancel
Save