Skip to content
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

Fixed humanname for zypperpkg #62086

Merged
merged 6 commits into from
Oct 20, 2022
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/62053.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the humanname being ignored in pkgrepo.managed on openSUSE Leap
12 changes: 12 additions & 0 deletions salt/modules/zypperpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,9 @@ def mod_repo(repo, **kwargs):
Enable or disable (True or False) repository,
but do not remove if disabled.

name
This is used as the descriptive name value in the repo file.

refresh
Enable or disable (True or False) auto-refresh of the repository.

Expand Down Expand Up @@ -1363,8 +1366,17 @@ def mod_repo(repo, **kwargs):
cmd_opt.append("--priority={}".format(kwargs.get("priority", DEFAULT_PRIORITY)))

if "humanname" in kwargs:
salt.utils.versions.warn_until(
3009,
"Passing 'humanname' to 'mod_repo' is deprecated, slated "
"for removal in {version}. Please use 'name' instead.",
)
cmd_opt.append("--name='{}'".format(kwargs.get("humanname")))

if "name" in kwargs:
cmd_opt.append("--name")
cmd_opt.append(kwargs.get("name"))

if kwargs.get("gpgautoimport") is True:
global_cmd_opt.append("--gpg-auto-import-keys")
call_refresh = True
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/modules/test_zypperpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def setUp(self):
"enabled": False,
"baseurl": self.new_repo_config["url"],
"alias": self.new_repo_config["name"],
"name": self.new_repo_config["name"],
"priority": 1,
"type": "rpm-md",
}
Expand Down Expand Up @@ -1377,10 +1378,35 @@ def test_repo_value_info(self):
self.assertEqual(type(r_info["enabled"]), bool)
self.assertEqual(type(r_info["autorefresh"]), bool)
self.assertEqual(type(r_info["baseurl"]), str)
self.assertEqual(type(r_info["name"]), str)
self.assertEqual(r_info["type"], None)
self.assertEqual(r_info["enabled"], alias == "SLE12-SP1-x86_64-Update")
self.assertEqual(r_info["autorefresh"], alias == "SLE12-SP1-x86_64-Update")

def test_repo_add_mod_name(self):
"""
Test mod_repo adds the new repo and call modify to update descriptive
name.

:return:
"""
url = self.new_repo_config["url"]
name = self.new_repo_config["name"]
desc_name = "Update Repository"
zypper_patcher = patch.multiple(
"salt.modules.zypperpkg", **self.zypper_patcher_config
)

with zypper_patcher:
zypper.mod_repo(name, **{"url": url, "name": desc_name})
self.assertEqual(
zypper.__zypper__(root=None).xml.call.call_args_list,
[call("ar", url, name)],
)
zypper.__zypper__(root=None).refreshable.xml.call.assert_called_once_with(
"mr", "--name", desc_name, name
)

def test_repo_add_nomod_noref(self):
"""
Test mod_repo adds the new repo and nothing else
Expand Down Expand Up @@ -1451,6 +1477,7 @@ def test_repo_noadd_modbaseurl_ref(self):
zypper.mod_repo(name, **params)
expected_params = {
"alias": "mock-repo-name",
"name": "mock-repo-name",
"autorefresh": True,
"baseurl": "http://repo.url/some/path-changed",
"enabled": False,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/modules/zypp/zypper-repo-1.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[SLE12-SP1-x86_64-Update]
name=Update Repository
enabled=1
autorefresh=1
baseurl=http://somehost.com/SUSE/Updates/SLE-SERVER/12-SP1/x86_64/update/
Expand Down
1 change: 1 addition & 0 deletions tests/unit/modules/zypp/zypper-repo-2.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[SLE12-SP1-x86_64-Update-disabled]
name=Update Repository
enabled=0
autorefresh=0
baseurl=http://somehost.com/SUSE/Updates/SLE-SERVER/12-SP1/x86_64/update/
Expand Down