Skip to content

Commit f3504d1

Browse files
committed
Update S3 artifact metadata suffix , gardenlinux_epoch and `build_timestamp (#314)
* Ensure S3 artifact metadata `suffix` is not missing content * Ensure S3 aritfact metadata `gardenlinux_epoch` remains a int * Bump version to `0.10.13` Signed-off-by: Tobias Wolf <wolf@b1-systems.de> On-behalf-of: SAP <tobias.wolf@sap.com>
1 parent 1294c05 commit f3504d1

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Installs the given GardenLinux Python library
44
inputs:
55
version:
66
description: GardenLinux Python library version
7-
default: "0.10.12"
7+
default: "0.10.13"
88
python_version:
99
description: Python version to setup
1010
default: "3.13"

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 = "gardenlinux"
3-
version = "0.10.12"
3+
version = "0.10.13"
44
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
55
authors = ["Garden Linux Maintainers <contact@gardenlinux.io>"]
66
license = "Apache-2.0"

src/gardenlinux/s3/s3_artifacts.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def upload_from_directory(
133133
requirements_file = artifacts_dir.joinpath(f"{base_name}.requirements")
134134
require_uefi = None
135135
secureboot = None
136+
tpm2 = None
136137

137138
if requirements_file.exists():
138139
requirements_config = ConfigParser(allow_unnamed_section=True)
@@ -149,6 +150,9 @@ def upload_from_directory(
149150
UNNAMED_SECTION, "secureboot"
150151
)
151152

153+
if requirements_config.has_option(UNNAMED_SECTION, "tpm2"):
154+
tpm2 = requirements_config.getboolean(UNNAMED_SECTION, "tpm2")
155+
152156
if arch is None:
153157
raise RuntimeError(
154158
"Architecture could not be determined from release or requirements file"
@@ -160,6 +164,9 @@ def upload_from_directory(
160164
if secureboot is None:
161165
secureboot = "_trustedboot" in feature_set_list
162166

167+
if tpm2 is None:
168+
tpm2 = "_tpm2" in feature_set_list
169+
163170
# RegEx for S3 supported characters
164171
re_object = re.compile("[^a-zA-Z0-9\\s+\\-=.\\_:/@]")
165172

@@ -169,22 +176,17 @@ def upload_from_directory(
169176
if commit_id_or_hash is None:
170177
commit_id_or_hash = cname_object.commit_id
171178

172-
version_epoch = str(cname_object.version_epoch)
173-
174-
if version_epoch is None:
175-
version_epoch = ""
176-
177179
metadata = {
178180
"platform": cname_object.feature_set_platform,
179181
"architecture": arch,
180182
"base_image": None,
181183
"build_committish": commit_id_or_hash,
182-
"build_timestamp": datetime.fromtimestamp(release_timestamp).isoformat(),
183-
"gardenlinux_epoch": version_epoch,
184+
"build_timestamp": datetime.fromtimestamp(release_timestamp),
184185
"logs": None,
185186
"modifiers": feature_set_list,
186187
"require_uefi": require_uefi,
187188
"secureboot": secureboot,
189+
"tpm2": tpm2,
188190
"published_image_metadata": None,
189191
"s3_bucket": self._bucket.name,
190192
"s3_key": f"meta/singles/{base_name}",
@@ -193,6 +195,9 @@ def upload_from_directory(
193195
"paths": [],
194196
}
195197

198+
if cname_object.version_epoch is not None:
199+
metadata["gardenlinux_epoch"] = cname_object.version_epoch
200+
196201
platform_variant = cname_object.platform_variant
197202

198203
if platform_variant is not None:
@@ -210,13 +215,11 @@ def upload_from_directory(
210215
md5sum = file_digest(fp, "md5").hexdigest()
211216
sha256sum = file_digest(fp, "sha256").hexdigest()
212217

213-
suffixes = "".join(artifact.name)[1 + base_name_length :]
214-
215218
artifact_metadata = {
216219
"name": artifact.name,
217220
"s3_bucket_name": self._bucket.name,
218221
"s3_key": s3_key,
219-
"suffix": re_object.sub("+", suffixes),
222+
"suffix": re_object.sub("+", artifact.name[base_name_length:]),
220223
"md5sum": md5sum,
221224
"sha256sum": sha256sum,
222225
}

tests/s3/constants.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
architecture: amd64
1717
base_image: null
1818
build_committish: abc123lo
19-
build_timestamp: '{build_timestamp}'
20-
gardenlinux_epoch: '1234'
19+
build_timestamp: {build_timestamp}
2120
logs: null
2221
modifiers:
2322
- _usi
2423
- _trustedboot
2524
require_uefi: true
2625
secureboot: true
26+
tpm2: false
2727
published_image_metadata: null
2828
s3_bucket: test-bucket
2929
s3_key: meta/singles/container-amd64-1234.1-abc123lo
@@ -33,7 +33,8 @@
3333
- name: container-amd64-1234.1-abc123lo.release
3434
s3_bucket_name: test-bucket
3535
s3_key: objects/container-amd64-1234.1-abc123lo/container-amd64-1234.1-abc123lo.release
36-
suffix: release
36+
suffix: .release
3737
md5sum: {md5sum}
3838
sha256sum: {sha256sum}
39+
gardenlinux_epoch: 1234
3940
""".strip()

tests/s3/test_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def test_main_with_expected_result(
9696
result = capsys.readouterr().out.strip()
9797

9898
result = re.sub(
99-
"^(.*)build_timestamp\\: '.+'$",
100-
"\\1build_timestamp: '{build_timestamp}'",
99+
"^(.*)build_timestamp\\: (\\w|\\-|\\:|\\.| )+$",
100+
"\\1build_timestamp: {build_timestamp}",
101101
result,
102102
flags=re.M,
103103
)

0 commit comments

Comments
 (0)