Skip to content

add support for pulp_labels key in rpm_repository#240

Merged
mdellweg merged 2 commits into
pulp:developfrom
philnewm:rpm-repo-pulp-labels
May 11, 2026
Merged

add support for pulp_labels key in rpm_repository#240
mdellweg merged 2 commits into
pulp:developfrom
philnewm:rpm-repo-pulp-labels

Conversation

@philnewm
Copy link
Copy Markdown
Contributor

@philnewm philnewm commented May 3, 2026

Resolves #239

Adds the pulp_labels parameter to the rpm_repository module and extends the tests based on the ones from repo_config parameter.

Other repository modules might require this enhancement as well but for now I only need this one.

@philnewm philnewm marked this pull request as draft May 3, 2026 12:09
@philnewm philnewm marked this pull request as ready for review May 3, 2026 12:42
Comment thread plugins/modules/rpm_repository.py Outdated
@mdellweg
Copy link
Copy Markdown
Member

mdellweg commented May 4, 2026

Please take a look at the docs testing this.

@philnewm philnewm force-pushed the rpm-repo-pulp-labels branch from e0020bd to 9da1857 Compare May 6, 2026 19:33
@philnewm
Copy link
Copy Markdown
Contributor Author

philnewm commented May 6, 2026

Did read the docs on testing and adjusted PR accordingly.
Let me know if I missed something or perhaps misunderstood.

Comment thread plugins/modules/rpm_repository.py Outdated
@philnewm philnewm force-pushed the rpm-repo-pulp-labels branch from 9da1857 to 2a65ced Compare May 7, 2026 14:44
Comment thread plugins/modules/rpm_repository.py Outdated
pulp_labels:
description:
- A JSON document or data structure assigning pulp labels
type: dict[str, str]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's hope ansible-lint tells us whether this is the supposed language here. ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to this discussion and the linked issue it seems that the argument spec does not offer any way to define the data types of dictionary elements.
So this can only be done via runtime validation in the modules code from what I understood.

Comment thread plugins/modules/rpm_repository.py Outdated
# Encode the pulp_labels unless its a string, then assume it is a pre-formatted JSON
if "pulp_labels" in desired_attributes and isinstance(
desired_attributes["pulp_labels"], string_types
):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And now this part is superfluous, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This implementation is indeed. I replaced it with an actual check for strings.

- name: Add pulp_labels (string) to repository (Validate no change)
pulp.squeezer.rpm_repository:
name: test_rpm_repository
pulp_labels: '{"test_label": "1"}'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also we don't expect that to work anymore.

Maybe:

Suggested change
pulp_labels: '{"test_label": "1"}'
pulp_labels: "{{ '{\"test_label\": \"1\"}' | from_json }}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assumed that too but the tests still made it through. It seems that Ansible does convert inputs for dict parameters through some filter already before the data arrives at the module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ohh interesting.

@philnewm philnewm force-pushed the rpm-repo-pulp-labels branch from 2a65ced to 2f9e290 Compare May 8, 2026 21:08
@mdellweg
Copy link
Copy Markdown
Member

Thank you!

@mdellweg mdellweg enabled auto-merge May 11, 2026 08:02
@mdellweg mdellweg merged commit 5f198e9 into pulp:develop May 11, 2026
3 of 4 checks passed
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.

rpm_repository lacks the pulp_labels option

2 participants