Skip to content

Commit eb1a181

Browse files
committed
Add support to add tags to OCI image indices
Signed-off-by: Tobias Wolf <[email protected]> On-behalf-of: SAP <[email protected]>
1 parent 9bc3c1f commit eb1a181

File tree

6 files changed

+86
-59
lines changed

6 files changed

+86
-59
lines changed

.github/actions/features_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ outputs:
1111
runs:
1212
using: composite
1313
steps:
14-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].8
14+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].9
1515
- id: result
1616
shell: bash
1717
run: |

.github/actions/flavors_parse/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ outputs:
1313
runs:
1414
using: composite
1515
steps:
16-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].8
16+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/[email protected].9
1717
- id: matrix
1818
shell: bash
1919
run: |

.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.8"
7+
default: "0.10.9"
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.8"
3+
version = "0.10.9"
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 <[email protected]>"]
66
license = "Apache-2.0"

src/gardenlinux/oci/__main__.py

Lines changed: 79 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,85 @@ def cli() -> None:
2323
pass
2424

2525

26+
@cli.command()
27+
@click.option(
28+
"--index",
29+
required=True,
30+
help="OCI image index",
31+
)
32+
@click.option(
33+
"--index-tag",
34+
required=True,
35+
help="OCI image index tag",
36+
)
37+
@click.option(
38+
"--manifest_folder",
39+
default="manifests",
40+
help="A folder where the index entries are read from.",
41+
)
42+
@click.option(
43+
"--insecure",
44+
default=False,
45+
help="Use HTTP to communicate with the registry",
46+
)
47+
@click.option(
48+
"--additional_tag",
49+
required=False,
50+
multiple=True,
51+
help="Additional tag to push the index with",
52+
)
53+
def push_index_from_directory(
54+
index: str,
55+
index_tag: str,
56+
manifest_folder: str,
57+
insecure: bool,
58+
additional_tag: List[str],
59+
) -> None:
60+
"""
61+
Push a list of files from the `manifest_folder` to an index.
62+
63+
:since: 0.10.9
64+
"""
65+
66+
index = Container(f"{index}/{index_tag}", insecure=insecure)
67+
index.push_index_from_directory(manifest_folder, additional_tag)
68+
69+
70+
@cli.command()
71+
@click.option(
72+
"--index",
73+
required=True,
74+
help="OCI image index",
75+
)
76+
@click.option(
77+
"--index-tag",
78+
required=True,
79+
help="OCI image index tag",
80+
)
81+
@click.option(
82+
"--insecure",
83+
default=False,
84+
help="Use HTTP to communicate with the registry",
85+
)
86+
@click.option(
87+
"--tag",
88+
required=True,
89+
multiple=True,
90+
help="Tag to push the OCI image index with",
91+
)
92+
def push_index_tags(index: str, index_tag: str, insecure: bool, tag: List[str]) -> None:
93+
"""
94+
Push OCI image index tags to a registry.
95+
96+
:since: 0.10.9
97+
"""
98+
99+
index = Container(f"{index}/{index_tag}", insecure=insecure)
100+
101+
image_index = index.read_or_generate_index()
102+
index.push_index_for_tags(image_index, tag)
103+
104+
26105
@cli.command()
27106
@click.option(
28107
"--container",
@@ -182,58 +261,6 @@ def push_manifest_tags(
182261
container.push_manifest_for_tags(manifest, tag)
183262

184263

185-
@cli.command()
186-
@click.option(
187-
"--container",
188-
"container",
189-
required=True,
190-
type=click.Path(),
191-
help="Container Name",
192-
)
193-
@click.option(
194-
"--version",
195-
"version",
196-
required=True,
197-
type=click.Path(),
198-
help="Version of image",
199-
)
200-
@click.option(
201-
"--manifest_folder",
202-
default="manifests",
203-
help="A folder where the index entries are read from.",
204-
)
205-
@click.option(
206-
"--insecure",
207-
default=False,
208-
help="Use HTTP to communicate with the registry",
209-
)
210-
@click.option(
211-
"--additional_tag",
212-
required=False,
213-
multiple=True,
214-
help="Additional tag to push the index with",
215-
)
216-
def update_index(
217-
container: str,
218-
version: str,
219-
manifest_folder: str,
220-
insecure: bool,
221-
additional_tag: List[str],
222-
) -> None:
223-
"""
224-
Push a list of files from the `manifest_folder` to an index.
225-
226-
:since: 0.7.0
227-
"""
228-
229-
container = Container(
230-
f"{container}:{version}",
231-
insecure=insecure,
232-
)
233-
234-
container.push_index_from_directory(manifest_folder, additional_tag)
235-
236-
237264
def main() -> None:
238265
"""
239266
gl-oci main()

tests/oci/test_oci.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def update_index(
121121
print("Updating index")
122122

123123
cmd = [
124-
"update-index",
125-
"--container",
124+
"push-index-from-directory",
125+
"--index",
126126
CONTAINER_NAME_ZOT_EXAMPLE,
127-
"--version",
127+
"--index-tag",
128128
version,
129129
"--insecure",
130130
"True",

0 commit comments

Comments
 (0)