Merge ~toabctl/cloud-images/+git/eks-anywhere:main-get-binary-fixes into ~cloud-images/cloud-images/+git/eks-anywhere:main

Proposed by Thomas Bechtold
Status: Merged
Merged at revision: 9745d3d3a6e1021a6d60b8072fb4a7423be514c9
Proposed branch: ~toabctl/cloud-images/+git/eks-anywhere:main-get-binary-fixes
Merge into: ~cloud-images/cloud-images/+git/eks-anywhere:main
Diff against target: 107 lines (+25/-7)
3 files modified
create-debian-orig.py (+14/-1)
get-binary-version (+8/-3)
tests/test_get_binary_version.py (+3/-3)
Reviewer Review Type Date Requested Status
Jess Jang Approve
Review via email: mp+470436@code.launchpad.net

Commit message

feat: include binary-version file into orig.tar.gz
feat: allow custom output-dir in get-binary-version

To post a comment you must log in.
Revision history for this message
Jess Jang (jessica-youjeong) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/create-debian-orig.py b/create-debian-orig.py
2index b3f4fd1..4bc62fc 100755
3--- a/create-debian-orig.py
4+++ b/create-debian-orig.py
5@@ -30,7 +30,7 @@ def main() -> None:
6 with tempfile.TemporaryDirectory() as td:
7 basedir = os.path.join(td, f"eks-anywhere-{args.eksaversion}")
8 os.mkdir(basedir)
9- assets_info_path = os.path.join(basedir, "assets.json")
10+ assets_info_path = os.path.join(td, "assets.json")
11 cmd_asset_info = [
12 sys.executable,
13 "download-assets-info",
14@@ -49,6 +49,19 @@ def main() -> None:
15 cmd_asset_download = [sys.executable, "download-assets", "--assets-info", assets_info_path, "--outdir", basedir]
16 subprocess.check_call(cmd_asset_download)
17
18+ # create binary version file
19+ cmd_binary_version = [
20+ sys.executable,
21+ "get-binary-version",
22+ "--asset-file",
23+ assets_info_path,
24+ "--output-dir",
25+ basedir,
26+ ]
27+ subprocess.check_call(cmd_binary_version)
28+
29+ # drop assets.json - we don't want to include it in the tarball
30+ os.unlink(assets_info_path)
31 # create orig tarball
32 tarball_path = f"eks-anywhere_{args.eksaversion}-{args.k8sversion}.orig.tar.gz"
33 # see https://reproducible-builds.org/docs/archives/
34diff --git a/get-binary-version b/get-binary-version
35index 18d080b..d33786d 100755
36--- a/get-binary-version
37+++ b/get-binary-version
38@@ -70,6 +70,11 @@ def _parser() -> argparse.ArgumentParser:
39 help="File path where asset file exists.",
40 default=os.path.join(current_dir, "debian/eksa/assets.json"),
41 )
42+ parser.add_argument(
43+ "--output-dir",
44+ help="Directory path where binary version information will be saved. Default %(default)s",
45+ default=current_dir,
46+ )
47 return parser
48
49
50@@ -86,7 +91,7 @@ def _check_asset_file(assets) -> None:
51 die("File is empty. Download assets first from running `update-version` script.")
52
53
54-def _get_binaries(assets) -> None:
55+def _get_binaries(assets, output_dir) -> None:
56 """
57 Get dictionaries with binary version information
58 """
59@@ -106,7 +111,7 @@ def _get_binaries(assets) -> None:
60 if key in ["uri", "path", "type", "sha256", "digest"]:
61 binaries[asset_name][key] = value
62
63- file_path = os.path.join(current_dir, f"debian/eksa/{binary_version_file_name}")
64+ file_path = os.path.join(output_dir, binary_version_file_name)
65 with open(file_path, "w") as binary_version_file:
66 json.dump(binaries, binary_version_file, indent=2)
67
68@@ -122,7 +127,7 @@ def get_binary_version() -> None:
69 die(f"{args.asset_file} is not found.")
70
71 _check_asset_file(assets)
72- _get_binaries(assets)
73+ _get_binaries(assets, args.output_dir)
74
75
76 def main():
77diff --git a/tests/test_get_binary_version.py b/tests/test_get_binary_version.py
78index a9844c1..436d4d5 100644
79--- a/tests/test_get_binary_version.py
80+++ b/tests/test_get_binary_version.py
81@@ -33,7 +33,7 @@ def test_asset_file_does_not_have_asset_name():
82 },
83 }
84 with pytest.raises(IndexError) as excinfo:
85- module._get_binaries(assets)
86+ module._get_binaries(assets, ".")
87 assert excinfo.type == IndexError
88
89
90@@ -43,7 +43,7 @@ def test_asset_file_missing_asset_path():
91 "assets": {"1.26": [{"arch": ["amd64"], "uri": "fake-uri", "sha256": "fake-shasum", "type": "file"}]},
92 }
93 with pytest.raises(SystemExit) as excinfo:
94- module._get_binaries(assets)
95+ module._get_binaries(assets, ".")
96 assert excinfo.type == SystemExit
97
98
99@@ -64,7 +64,7 @@ def test_binary_file_generate():
100 }
101 # setting temporary directory for testing result
102 module.current_dir = "tests"
103- module._get_binaries(assets)
104+ module._get_binaries(assets, ".")
105
106 file_path = "tests/debian/eksa/eks-anywhere-binaries-1-26.txt"
107 with open(file_path, "r") as f:

Subscribers

People subscribed via source and target branches