mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Use str() method instead of repo_line for SourceEntry
This commit is contained in:
parent
3012dc42d6
commit
b17cdf0da4
3 changed files with 36 additions and 1 deletions
1
changelog/62546.fixed
Normal file
1
changelog/62546.fixed
Normal file
|
@ -0,0 +1 @@
|
|||
Use str() method instead of repo_line for when python3-apt is installed or not in aptpkg.py.
|
|
@ -182,6 +182,9 @@ if not HAS_APT:
|
|||
self.file = str(pathlib.Path(os.sep, "etc", "apt", "sources.list"))
|
||||
self._parse_sources(line)
|
||||
|
||||
def str(self):
|
||||
return self.repo_line()
|
||||
|
||||
def repo_line(self):
|
||||
"""
|
||||
Return the repo line for the sources file
|
||||
|
@ -2946,7 +2949,7 @@ def mod_repo(repo, saltenv="base", aptkey=True, **kwargs):
|
|||
|
||||
if mod_source.uri != repo_uri:
|
||||
mod_source.uri = repo_uri
|
||||
mod_source.line = mod_source.repo_line()
|
||||
mod_source.line = mod_source.str()
|
||||
|
||||
sources.save()
|
||||
# on changes, explicitly refresh
|
||||
|
|
|
@ -537,6 +537,37 @@ def test_repo_present_absent_no_trailing_slash_uri(pkgrepo, trailing_slash_repo_
|
|||
assert ret.result
|
||||
|
||||
|
||||
@pytest.mark.requires_salt_states("pkgrepo.managed", "pkgrepo.absent")
|
||||
def test_repo_present_absent_no_trailing_slash_uri_add_slash(
|
||||
pkgrepo, trailing_slash_repo_file
|
||||
):
|
||||
"""
|
||||
test adding a repo without a trailing slash, and then running it
|
||||
again with a trailing slash.
|
||||
"""
|
||||
# without the trailing slash
|
||||
repo_content = "deb http://www.deb-multimedia.org stable main"
|
||||
# initial creation
|
||||
ret = pkgrepo.managed(
|
||||
name=repo_content, file=trailing_slash_repo_file, refresh=False, clean_file=True
|
||||
)
|
||||
with salt.utils.files.fopen(trailing_slash_repo_file, "r") as fp:
|
||||
file_content = fp.read()
|
||||
assert file_content.strip() == "deb http://www.deb-multimedia.org stable main"
|
||||
assert ret.changes
|
||||
# now add a trailing slash in the name
|
||||
repo_content = "deb http://www.deb-multimedia.org/ stable main"
|
||||
ret = pkgrepo.managed(
|
||||
name=repo_content, file=trailing_slash_repo_file, refresh=False
|
||||
)
|
||||
with salt.utils.files.fopen(trailing_slash_repo_file, "r") as fp:
|
||||
file_content = fp.read()
|
||||
assert file_content.strip() == "deb http://www.deb-multimedia.org/ stable main"
|
||||
# absent
|
||||
ret = pkgrepo.absent(name=repo_content)
|
||||
assert ret.result
|
||||
|
||||
|
||||
@attr.s(kw_only=True)
|
||||
class Repo:
|
||||
key_root = attr.ib(default=pathlib.Path("/usr", "share", "keyrings"))
|
||||
|
|
Loading…
Add table
Reference in a new issue