Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon committed Sep 28, 2023
1 parent decdf66 commit 7d75f78
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cloudinit/config/cc_puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from cloudinit.cloud import Cloud
from cloudinit.config import Config
from cloudinit.config.schema import MetaSchema, get_meta_doc
from cloudinit.distros import ALL_DISTROS, Distro, InstallerError
from cloudinit.distros import ALL_DISTROS, Distro, PackageInstallerError
from cloudinit.settings import PER_INSTANCE

AIO_INSTALL_URL = "https://raw.githubusercontent.com/puppetlabs/install-puppet/main/install.sh" # noqa: E501
Expand Down Expand Up @@ -242,7 +242,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None:
to_install: List[Union[str, List[str]]]
if package_name is None: # conf has no package_nam
for puppet_name in PUPPET_PACKAGE_NAMES:
with suppress(InstallerError):
with suppress(PackageInstallerError):
to_install = (
[[puppet_name, version]]
if version
Expand Down
6 changes: 3 additions & 3 deletions cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
]


class InstallerError(Exception):
class PackageInstallerError(Exception):
pass


Expand Down Expand Up @@ -187,7 +187,7 @@ def _validate_entry(self, entry):
)

def _extract_package_by_manager(
self, pkglist: Iterable
self, pkglist: PackageList
) -> Tuple[Dict[Type[PackageManager], Set], Set]:
"""Transform the generic package list to package by package manager.
Expand Down Expand Up @@ -257,7 +257,7 @@ def install_packages(self, pkglist: PackageList):
)

if uninstalled:
raise InstallerError(error_message, uninstalled)
raise PackageInstallerError(error_message % uninstalled)

def _write_network(self, settings):
"""Deprecated. Remove if/when arch and gentoo support renderers."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
get_schema,
validate_cloudconfig_schema,
)
from cloudinit.distros import InstallerError
from cloudinit.distros import PackageInstallerError
from cloudinit.subp import SubpResult
from tests.unittests.helpers import skipUnlessJsonSchema
from tests.unittests.util import get_cloud
Expand Down Expand Up @@ -169,7 +169,7 @@ def _new_subp(*args, **kwargs):
cloud = get_cloud("ubuntu")
cfg = {"packages": ["pkg1"]}
with mock.patch("cloudinit.subp.subp", side_effect=_new_subp):
with pytest.raises(InstallerError):
with pytest.raises(PackageInstallerError):
handle("", cfg, cloud, [])

assert caplog.records[-3].levelname == "WARNING"
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/config/test_cc_puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
get_schema,
validate_cloudconfig_schema,
)
from cloudinit.distros import InstallerError
from cloudinit.distros import PackageInstallerError
from cloudinit.subp import ProcessExecutionError
from tests.unittests.helpers import CiTestCase, mock, skipUnlessJsonSchema
from tests.unittests.util import get_cloud
Expand Down Expand Up @@ -408,7 +408,7 @@ def test_puppet_falls_back_to_older_name(self, m_subp, m_man_puppet):
"tests.unittests.util.MockDistro.install_packages"
) as install_pkg:
# puppet-agent not installed, but puppet is
install_pkg.side_effect = (InstallerError, 0)
install_pkg.side_effect = (PackageInstallerError, 0)

cc_puppet.handle("notimportant", cfg, self.cloud, None)
expected_calls = [
Expand Down
7 changes: 5 additions & 2 deletions tests/unittests/distros/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from cloudinit.distros import (
LDH_ASCII_CHARS,
InstallerError,
PackageInstallerError,
_get_package_mirror_info,
)
from tests.unittests.distros import _get_distro
Expand Down Expand Up @@ -316,7 +316,10 @@ def test_non_default_package_manager_fail(
"cloudinit.distros.package_management.snap.Snap.install_packages",
return_value=["pkg3"],
)
with pytest.raises(InstallerError):
with pytest.raises(
PackageInstallerError,
match="Failed to install the following packages: \['pkg3'\]",
):
_get_distro("debian").install_packages(
[{"apt": ["pkg1"]}, "pkg2", {"snap": ["pkg3"]}]
)
Expand Down

0 comments on commit 7d75f78

Please sign in to comment.