Skip to content

CFE-3635: Prototyped dnf_appstream custom promise type#117

Open
nickanderson wants to merge 1 commit intocfengine:masterfrom
nickanderson:CFE-3635/master
Open

CFE-3635: Prototyped dnf_appstream custom promise type#117
nickanderson wants to merge 1 commit intocfengine:masterfrom
nickanderson:CFE-3635/master

Conversation

@nickanderson
Copy link
Copy Markdown
Member

@nickanderson nickanderson commented Nov 11, 2025

Ticket: CFE-3635

@olehermanse olehermanse self-requested a review November 12, 2025 19:50
@olehermanse olehermanse requested a review from larsewi January 5, 2026 13:53
Copy link
Copy Markdown
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

GJ 🚀

Copy link
Copy Markdown
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Some comments 😉

@nickanderson nickanderson requested a review from larsewi January 22, 2026 20:50
@nickanderson
Copy link
Copy Markdown
Member Author

ok @larsewi 🫣

@nickanderson nickanderson changed the title CFE-3653: Prototyped dnf_appstream custom promise type CFE-3635: Prototyped dnf_appstream custom promise type Jan 22, 2026
Copy link
Copy Markdown
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Getting closer 😉 Please format with black and run a linter like pyright or similar

@nickanderson
Copy link
Copy Markdown
Member Author

OK fixed up review comments, renamed to just appstreams, ready for review again.

A CFEngine custom promise type for managing AppStream modules (https://www.redhat.com/en/blog/introduction-appstreams-and-modules-red-hat-enterprise-linux) on compatible systems.

- Enable, disable, install, and remove AppStream modules
- Support for specifying streams and profiles

Ticket: CFE-3653
Copy link
Copy Markdown
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

The promise type LGTM 🚀 The pytests are written with a framework that I don't know.

Comment on lines +57 to +68
if value not in (
"enabled",
"disabled",
"installed",
"removed",
"default",
"reset",
):
raise ValidationError(
"State attribute must be 'enabled', 'disabled', 'installed', "
"'removed', 'default', or 'reset'"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider:

Suggested change
if value not in (
"enabled",
"disabled",
"installed",
"removed",
"default",
"reset",
):
raise ValidationError(
"State attribute must be 'enabled', 'disabled', 'installed', "
"'removed', 'default', or 'reset'"
)
accepted = (
"enabled",
"disabled",
"installed",
"removed",
"default",
"reset",
)
if value not in accepted:
raise ValidationError(
f"State attribute must be '{"', '".join(accepted)}'"
)


def _validate_module_name(self, name):
# Validate module name to prevent injection
if not re.match(r"^[a-zA-Z0-9_.-]+$", name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

re.match always anchors to the start of the string. Hence, the ^ is redundant. However, it does not hurt to be explicit. You can also consider using re.fullmatch (it reads better):

Suggested change
if not re.match(r"^[a-zA-Z0-9_.-]+$", name):
if not re.fullmatch(r"[a-zA-Z0-9_.-]+", name):

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants