diff --git a/changelog/62053.fixed b/changelog/62053.fixed new file mode 100644 index 000000000000..24d281b5f477 --- /dev/null +++ b/changelog/62053.fixed @@ -0,0 +1 @@ +Fixed the humanname being ignored in pkgrepo.managed on openSUSE Leap diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py index e8c82ca76d23..0c48f8961615 100644 --- a/salt/modules/zypperpkg.py +++ b/salt/modules/zypperpkg.py @@ -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. @@ -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 diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py index b2aee269ff60..22137a2544f0 100644 --- a/tests/unit/modules/test_zypperpkg.py +++ b/tests/unit/modules/test_zypperpkg.py @@ -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", } @@ -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 @@ -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, diff --git a/tests/unit/modules/zypp/zypper-repo-1.cfg b/tests/unit/modules/zypp/zypper-repo-1.cfg index 958718c05318..5609abc96b42 100644 --- a/tests/unit/modules/zypp/zypper-repo-1.cfg +++ b/tests/unit/modules/zypp/zypper-repo-1.cfg @@ -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/ diff --git a/tests/unit/modules/zypp/zypper-repo-2.cfg b/tests/unit/modules/zypp/zypper-repo-2.cfg index f55cf183e9d0..63dbaa04d66d 100644 --- a/tests/unit/modules/zypp/zypper-repo-2.cfg +++ b/tests/unit/modules/zypp/zypper-repo-2.cfg @@ -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/