Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "python_gardenlinux_lib"
version = "0.4.2"
version = "0.4.3"
description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames"
authors = ["Garden Linux Maintainers <contact@gardenlinux.io>"]
license = "Apache-2.0"
Expand Down
37 changes: 37 additions & 0 deletions src/python_gardenlinux_lib/oras/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,43 @@ def push_from_tar(self, architecture: str, version: str, cname: str, tar: str):
print("removed tmp files.")
return digest

def push_from_dir(self, architecture: str, version: str, cname: str, dir: str):
# Step 1 scan and extract nested artifacts:
for file in os.listdir(dir):
try:
if file.endswith(".pxe.tar.gz"):
logger.info(f"Found nested artifact {file}")
nested_tar_obj = tarfile.open(f"{dir}/{file}")
nested_tar_obj.extractall(filter="data", path=dir)
nested_tar_obj.close()
except (OSError, tarfile.FilterError, tarfile.TarError) as e:
print(f"Failed to extract nested artifact {file}", e)
exit(1)

try:
oci_metadata = get_oci_metadata_from_fileset(os.listdir(dir), architecture)

features = ""
for artifact in oci_metadata:
if artifact["media_type"] == "application/io.gardenlinux.release":
file = open(f"{dir}/{artifact["file_name"]}", "r")
lines = file.readlines()
for line in lines:
if line.strip().startswith("GARDENLINUX_FEATURES="):
features = line.strip().removeprefix(
"GARDENLINUX_FEATURES="
)
break
file.close()

digest = self.push_image_manifest(
architecture, cname, version, dir, oci_metadata, features
)
except Exception as e:
print("Error: ", e)
exit(1)
return digest


def extract_tar(tar: str, tmpdir: str):
"""
Expand Down