Skip to content

Implement client.quadlets.install#633

Open
inknos wants to merge 2 commits intocontainers:mainfrom
inknos:post-quadlets
Open

Implement client.quadlets.install#633
inknos wants to merge 2 commits intocontainers:mainfrom
inknos:post-quadlets

Conversation

@inknos
Copy link
Contributor

@inknos inknos commented Mar 4, 2026

Install quadlet passing them to the install function as as a tuples (name, content) or a file path or a list of both.

Fixes: https://issues.redhat.com/browse/RUN-4367

Install quadlet passing them to the install function as as a tuples
(name, content) or a file path or a list of both.

Fixes: https://issues.redhat.com/browse/RUN-4367

Signed-off-by: Nicola Sella <[email protected]>
"reload-systemd": reload_systemd,
}

first = files[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the files are empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function will fail before with TypeError because file is a named arg

>>> client.quadlets.install()
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    client.quadlets.install()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
TypeError: QuadletsManager.install() missing 1 required positional argument: 'files'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about len(files) == 0 case?

FileNotFoundError: when a provided file path does not exist on
disk.
"""
if not isinstance(files, builtins.list):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it is tupple?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if tuple, it will move through this check and it will be processed inside _prepare_install_body, which will check for tuple or pathlike and process the files arg

@staticmethod
def _is_tar_path(item: "QuadletFileItem") -> bool:
"""Return True if *item* looks like a path to a ``.tar`` archive."""
return isinstance(item, (str, os.PathLike)) and str(item).endswith(".tar")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about tar.gz?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, I'll improve and test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it in a separate commit so you can review it with convenience, then I'll squash before merging once you approve



# Type alias – importable for type annotations in calling code.
QuadletFileItem = Union[tuple[str, str], str, os.PathLike]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QuadletFileItem = Union[tuple[str, str], str, os.PathLike]
QuadletFileItem = Union[tuple[str, Union[str, bytes]], str, os.PathLike]

Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question otherwise. LGTM.

"reload-systemd": reload_systemd,
}

first = files[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about len(files) == 0 case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants