mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Trigger SaltInvocationError when targeting duplicated package names
This commit is contained in:
parent
72a673ba2c
commit
113e5de656
1 changed files with 13 additions and 2 deletions
|
@ -12,7 +12,7 @@ import pprint
|
|||
import salt.utils.data
|
||||
import salt.utils.versions
|
||||
import salt.utils.yaml
|
||||
from salt.exceptions import SaltInvocationError
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__SUFFIX_NOT_NEEDED = ("x86_64", "noarch")
|
||||
|
@ -27,11 +27,22 @@ def _repack_pkgs(pkgs, normalize=True):
|
|||
_normalize_name = __salt__["pkg.normalize_name"]
|
||||
else:
|
||||
_normalize_name = lambda pkgname: pkgname
|
||||
return {
|
||||
|
||||
repacked_pkgs = {
|
||||
_normalize_name(str(x)): str(y) if y is not None else y
|
||||
for x, y in salt.utils.data.repack_dictlist(pkgs).items()
|
||||
}
|
||||
|
||||
# Check if there were collisions in names
|
||||
if len(pkgs) != len(repacked_pkgs):
|
||||
raise CommandExecutionError(
|
||||
"You are passing a list of packages that contains duplicated packages names: {}. This cannot be processed. In case you are targeting different versions of the same package, please target them individually".format(
|
||||
pkgs
|
||||
)
|
||||
)
|
||||
|
||||
return repacked_pkgs
|
||||
|
||||
|
||||
def pack_sources(sources, normalize=True):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue