Skip to content

Commit c80fc26

Browse files
committed
WIP: OCI tagging
1 parent 6a7f814 commit c80fc26

File tree

13 files changed

+575
-277
lines changed

13 files changed

+575
-277
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ install-test: install-dev
4646
test: install-test
4747
$(POETRY) run pytest -k "not kms"
4848

49+
test-debug: install-test
50+
$(POETRY) run pytest -k "not kms" -vvv -s
51+
52+
test-trace: install-test
53+
$(POETRY) run pytest -k "not kms" -vvv --log-cli-level=DEBUG
54+
4955
format: install-dev
5056
$(POETRY) run black --extend-exclude test-data/gardenlinux .
5157

poetry.lock

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ oras = { git = "https://github.com/oras-project/oras-py.git", rev="caf8db5b2793
1919
python-dotenv = "^1.0.1"
2020
cryptography = "^44.0.0"
2121
boto3 = "*"
22+
click = "^8.2.0"
2223

2324
[tool.poetry.group.dev.dependencies]
2425
bandit = "^1.8.3"

src/gardenlinux/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,5 @@
164164

165165
OCI_ANNOTATION_SIGNATURE_KEY = "io.gardenlinux.oci.signature"
166166
OCI_ANNOTATION_SIGNED_STRING_KEY = "io.gardenlinux.oci.signed-string"
167+
168+
GL_USER_AGENT_REGISTRY = "gardenlinux.oci.registry/1.0"

src/gardenlinux/features/__main__.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,27 @@ def get_flavor_from_cname(cname: str, get_arch: bool = True) -> str:
226226
# transform to flavor:
227227
# azure-gardener_prod_tpm2_trustedboot-amd64
228228

229-
platform = cname.split("-")[0]
230-
features = cname.split("-")[1:-1]
231-
arch = cname.split("-")[-1]
229+
parts = cname.split("-")
232230

231+
# Extract platform, features, and architecture
232+
platform = parts[0]
233+
234+
# If there's more than two parts (beyond platform and arch), those are features
235+
if len(parts) > 2:
236+
features = "-".join(parts[1:-1]) # Join all middle parts with hyphens
237+
else:
238+
features = ""
239+
240+
arch = parts[-1]
241+
242+
# Create the flavor string
233243
if get_arch:
234-
return f"{platform}-{features}-{arch}"
244+
flavor = f"{platform}-{features}-{arch}" if features else f"{platform}-{arch}"
235245
else:
236-
return f"{platform}-{features}"
246+
flavor = f"{platform}-{features}" if features else platform
247+
248+
print(f"Extracted flavor: {flavor}")
249+
return flavor
237250

238251

239252
if __name__ == "__main__":

src/gardenlinux/oci/__main__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ def cli():
2626
type=click.Path(),
2727
help="Version of image",
2828
)
29-
@click.option(
30-
"--commit",
31-
required=False,
32-
type=click.Path(),
33-
default=None,
34-
help="Commit of image",
35-
)
3629
@click.option(
3730
"--arch",
3831
required=True,
@@ -58,16 +51,22 @@ def cli():
5851
default=False,
5952
help="Use HTTP to communicate with the registry",
6053
)
54+
@click.option(
55+
"--additional_tags",
56+
required=False,
57+
multiple=True,
58+
help="Additional tags to push the manifest with",
59+
)
6160
def push_manifest(
6261
container,
6362
version,
64-
commit,
6563
arch,
6664
cname,
6765
directory,
6866
cosign_file,
6967
manifest_file,
7068
insecure,
69+
additional_tags,
7170
):
7271
"""push artifacts from a dir to a registry, get the index-entry for the manifest in return"""
7372
container_name = f"{container}:{version}"
@@ -77,7 +76,7 @@ def push_manifest(
7776
insecure=insecure,
7877
)
7978
digest = registry.push_from_dir(
80-
arch, version, cname, directory, manifest_file, commit=commit
79+
arch, version, cname, directory, manifest_file, additional_tags
8180
)
8281
if cosign_file:
8382
print(digest, file=open(cosign_file, "w"))

0 commit comments

Comments
 (0)