pkg.install and pkg.remove on the command line take number version numbers,

store them within a float. However version is a string, to support versions
numbers like 1.3.4

The following for example would not work as version would be a float, and a
float does not match a string a dict with key of strings.
c:\salt\salt-call -l debug pkg.install name=softwarename version=3.1
This commit is contained in:
Damon Atkins 2017-07-03 19:27:00 +10:00
parent 7160697123
commit cf55c3361c

View file

@ -1020,10 +1020,15 @@ def install(name=None, refresh=False, pkgs=None, **kwargs):
ret[pkg_name] = 'Unable to locate package {0}'.format(pkg_name)
continue
# Get the version number passed or the latest available
# Get the version number passed or the latest available (must be a string)
version_num = ''
if options:
version_num = options.get('version', False)
version_num = options.get('version', '')
# The user user salt cmdline with version=5.3 might be interpreted
# as a float it must be converted to a string in order for
# string matching to work.
if not isinstance(version, six.string_types):
version_num = str(version_num)
if not version_num:
version_num = _get_latest_pkg_version(pkginfo)
@ -1355,6 +1360,11 @@ def remove(name=None, pkgs=None, version=None, **kwargs):
continue
if version_num is not None:
# The user user salt cmdline with version=5.3 might be interpreted
# as a float it must be converted to a string in order for
# string matching to work.
if not isinstance(version, six.string_types):
version_num = str(version_num)
if version_num not in pkginfo and 'latest' in pkginfo:
version_num = 'latest'
elif 'latest' in pkginfo: