8000 pkgrepo: account for 'name' attr being part of the state by mattp- · Pull Request #68107 · saltstack/salt · GitHub
[go: up one dir, main page]

Skip to content

pkgrepo: account for 'name' attr being part of the state #68107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
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
1 change: 1 addition & 0 deletions changelog/68107.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkgrepo.managed not applying changes / account for 'name' attr being part of the state
6 changes: 2 additions & 4 deletions salt/states/pkgrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ def managed(name, ppa=None, copr=None, aptkey=True, **kwargs):
)
return ret

repo = name
kwargs["name"] = repo = name

if __grains__["os"] in ("Ubuntu", "Mint"):
if ppa is not None:
# overload the name/repo value for PPAs cleanly
Expand All @@ -437,9 +438,6 @@ def managed(name, ppa=None, copr=None, aptkey=True, **kwargs):

if "humanname" in kwargs:
kwargs["name"] = kwargs.pop("humanname")
if "name" not in kwargs:
# Fall back to the repo name if humanname not provided
kwargs["name"] = repo

kwargs["enabled"] = (
not salt.utils.data.is_true(disabled)
Expand Down
20 changes: 20 additions & 0 deletions tests/pytests/unit/states/test_pkgrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ def configure_loader_modules():
}


def test_name_change():
"""
Test when only the key_url is changed that a change is triggered
"""
kwargs = {
"name": "deb http://apt.example.com/{{grains['os'] | lower}} {{grains['oscodename']}} main",
"disabled": False,
"key_url": "https://mock/changed_gpg.key",
}

new = kwargs.copy()
new["name"] = (
"deb [arch=amd64] http://apt.example.com/{{grains['os'] | lower}} {{grains['oscodename']}} main"
)

with patch.dict(pkgrepo.__salt__, {"pkg.get_repo": MagicMock(return_value=kwargs)}):
ret = pkgrepo.managed(**new)
assert ret["changes"] == {"name": {"old": kwargs["name"], "new": new["name"]}}


def test_new_key_url():
"""
Test when only the key_url is changed that a change is triggered
Expand Down
Loading
0