Skip to content

Commit 3d2ad73

Browse files
authored
#221: Added an empty manifest to script language containers (#222)
fixes #221
1 parent ea553e9 commit 3d2ad73

File tree

6 files changed

+45
-4
lines changed

6 files changed

+45
-4
lines changed

doc/changes/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changes
22

3+
* [0.21.0](changes_0.21.0.md)
34
* [0.20.0](changes_0.20.0.md)
45
* [0.19.0](changes_0.19.0.md)
56
* [0.18.3](changes_0.18.3.md)

doc/changes/changes_0.21.0.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Script-Languages-Container-Tool 0.21.0, released t.b.d.
2+
3+
Code name: t.b.d.
4+
5+
## Summary
6+
7+
t.b.d.
8+
9+
## Features
10+
11+
#221: Added an empty manifest to script language containers

exasol_script_languages_container_tool/lib/tasks/export/export_container_base_task.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,21 @@ def _export_container(self, container, release_image_name: str, temp_directory:
152152

153153
def _pack_release_file(self, log_path: Path, extract_dir: str, release_file: Path):
154154
self.logger.info("Pack container file %s", release_file)
155-
extract_content = " ".join("'%s'" % file for file in os.listdir(extract_dir))
156-
command = f"""tar -C '{extract_dir}' -cvzf '{release_file}' {extract_content}"""
157-
self.run_command(command, "packing container file %s" % release_file,
155+
extract_content = " ".join(f"'{file}'" for file in os.listdir(extract_dir))
156+
if not str(release_file).endswith("tar.gz"):
157+
raise ValueError(f"Unexpected release file: '{release_file}'. Expected suffix 'tar.gz'.")
158+
tmp_release_file = release_file.with_suffix("") #cut off ".gz" from ".tar.gz"
159+
command = f"""tar -C '{extract_dir}' -vcf '{tmp_release_file}' {extract_content}"""
160+
self.run_command(command, f"packing container file {tmp_release_file}",
161+
log_path.joinpath("pack_release_file.log"))
162+
manifest_file = os.path.join(extract_dir, "exasol-manifest.json")
163+
with open(manifest_file, "w") as f:
164+
print("{}", file=f)
165+
command = f"""tar -C '{extract_dir}' -rvf '{tmp_release_file}' exasol-manifest.json"""
166+
self.run_command(command, f"adding manifest to '{tmp_release_file}'",
167+
log_path.joinpath("pack_release_file.log"))
168+
command = f"""gzip {tmp_release_file}"""
169+
self.run_command(command, f"Creating '{release_file}'",
158170
log_path.joinpath("pack_release_file.log"))
159171

160172
@staticmethod

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "exasol-script-languages-container-tool"
3-
version = "0.20.0"
3+
version = "0.21.0"
44
description = "Script Languages Container Tool"
55

66
license = "MIT"

test/test_docker_api_export.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import tarfile
23
import unittest
34
from pathlib import Path
45

@@ -29,6 +30,13 @@ def test_docker_export(self):
2930
export_path = Path(export_info.output_file)
3031
self.assertIn(export_path.name, exported_files)
3132

33+
# Verify that "exasol-manifest.json" is the last file in the Tar archive
34+
with tarfile.open(export_path, "r:*") as tf:
35+
tf_members = tf.getmembers()
36+
last_tf_member = tf_members[-1]
37+
assert last_tf_member.name == "exasol-manifest.json"
38+
assert last_tf_member.path == "exasol-manifest.json"
39+
3240

3341
if __name__ == '__main__':
3442
unittest.main()

test/test_docker_export.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import tarfile
23
import unittest
34

45
import utils as exaslct_utils
@@ -24,6 +25,14 @@ def test_docker_export(self):
2425
f"Did not found saved files for repository {self.test_environment.repository_name} "
2526
f"in list {exported_files}")
2627

28+
#Verify that "exasol-manifest.json" is the last file in the Tar archive
29+
with tarfile.open(os.path.join(self.export_path, 'test-flavor_release.tar.gz'), "r:*") as tf:
30+
tf_members = tf.getmembers()
31+
last_tf_member = tf_members[-1]
32+
assert last_tf_member.name == "exasol-manifest.json"
33+
assert last_tf_member.path == "exasol-manifest.json"
34+
35+
2736

2837
if __name__ == '__main__':
2938
unittest.main()

0 commit comments

Comments
 (0)