Skip to content

Add --version option to rpm and file distribution commands#1448

Merged
mdellweg merged 1 commit into
pulp:mainfrom
dralley:repoversion
Jul 24, 2026
Merged

Add --version option to rpm and file distribution commands#1448
mdellweg merged 1 commit into
pulp:mainfrom
dralley:repoversion

Conversation

@dralley

@dralley dralley commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Allow setting repository_version on distributions for publication-based plugins (rpm, file), matching the capability added in pulpcore 3.106.0.

Assisted-By: Claude Opus 4.6

@mdellweg mdellweg left a comment

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.

The cli option part looks nice and clean.
The preprocess_entity in glue has a lot of branches i need to trace for a verdict.
Do you think we should unittest this very function here?

But in any case can you please add a changelog entry, ideally one for cli and glue each?

Comment thread pulp-glue/src/pulp_glue/rpm/context.py Outdated
def preprocess_entity(self, body: EntityDefinition, partial: bool = False) -> EntityDefinition:
body = super().preprocess_entity(body, partial=partial)
if "version" in body:
self.pulp_ctx.needs_plugin(PluginRequirement("core", specifier=">=3.106.0"))

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.

So {"version": None} is supposed to fail on pulp_rpm < 3.106.0?

I wonder if we should just move this statements after line 94.

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.

Setting repository version on a distribution for a publication based plugin should fail if <3.106

Comment thread pulp-glue/src/pulp_glue/rpm/context.py Outdated
Comment on lines +96 to +103
if not repository_href and partial:
current_entity = self.entity
repository_href = current_entity.get("repository")
if not repository_href and (
repository_version_href := current_entity.get("repository_version")
):
repository_href = f"{repository_version_href.rsplit('/', 3)[0]}/"
if not repository_href:

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.

This could be

if repository_href is None:
    if partial:
        ...
        repository_href = ...
    else:
        raise ...

raise PulpException(_("--repository must be provided"))
body["repository_version"] = f"{repository_href}versions/{version}/"
body["repository"] = None
elif "repository" in body and self.pulp_ctx.has_plugin(

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.

Is the intention here that when specifying the repository but not the version, the version should be nullified?
So we need the "repository" in body part of that condition?

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.

There's 2 fields in the CLI (repository and version) which controls which of the 3 fields on distribution get set. If both are present then it sets the repository version, otherwise it sets the repository only.

@dralley

dralley commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@mdellweg How's this? I simplified it a bit and removed the ability to switch version without re-specifying repository.

Commits should be squashed before merging

@mdellweg mdellweg left a comment

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.

Just one tiny suggestion to try.

elif "repository" in body and self.pulp_ctx.has_plugin(
PluginRequirement("core", specifier=">=3.106.0")
):
body["repository_version"] = None

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.

Now that is kind of easy to follow.

Comment thread pulp-glue/tests/test_distribution_preprocess.py Outdated
Allow setting repository_version on distributions for publication-based
plugins (rpm, file), matching the capability added in pulpcore 3.106.0.

Assisted-By: Claude Opus 4.6
@mdellweg
mdellweg enabled auto-merge (rebase) July 24, 2026 14:30
@mdellweg
mdellweg merged commit 28ef586 into pulp:main Jul 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants