mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Regular __version__
attribute must not include codename.
* Add `noc` and `sha` as `repr` attributes.
This commit is contained in:
parent
fb054029f7
commit
de970edfb2
1 changed files with 34 additions and 21 deletions
|
@ -282,9 +282,10 @@ class SaltStackVersion(object):
|
|||
def formatted_version(self):
|
||||
if self.name and self.major > 10000:
|
||||
return '{0} (Unreleased)'.format(self.name)
|
||||
elif self.name:
|
||||
return '{0} ({1})'.format(self.name, self.string)
|
||||
return self.string
|
||||
version_string = self.string
|
||||
if (self.major, self.minor) in self.RMATCH:
|
||||
version_string += ' ({0})'.format(self.RMATCH[(self.major, self.minor)])
|
||||
return version_string
|
||||
|
||||
def __str__(self):
|
||||
return self.string
|
||||
|
@ -328,6 +329,11 @@ class SaltStackVersion(object):
|
|||
])
|
||||
if self.rc:
|
||||
parts.append('rc={0}'.format(self.rc))
|
||||
if self.noc and self.sha:
|
||||
parts.extend([
|
||||
'noc={0}'.format(self.noc),
|
||||
'sha={0}'.format(self.sha)
|
||||
])
|
||||
return '<{0} {1}>'.format(self.__class__.__name__, ' '.join(parts))
|
||||
|
||||
|
||||
|
@ -343,23 +349,24 @@ class SaltStackVersion(object):
|
|||
# }
|
||||
#
|
||||
# --------------------------------------------------------------------------------------------------------------------
|
||||
# There's no need to edit any of the version dunder objects below, see above why and where to update
|
||||
# Only update __saltstack_version__ if bumping major versions and as such, codenames, of course, don't also
|
||||
# forget to update to the real major version on SaltStackVersion.NAMES.
|
||||
# Minor version bumps should be done on SaltStackVersion.NAMES, see above.
|
||||
# --------------------------------------------------------------------------------------------------------------------
|
||||
__saltstack_version__ = SaltStackVersion.from_name('Hydrogen')
|
||||
__version_info__ = __saltstack_version__.info
|
||||
__version__ = __saltstack_version__.string
|
||||
# <---- Hardcoded Salt Version Information ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
# ----- Dynamic/Runtime Salt Version Information -------------------------------------------------------------------->
|
||||
def __get_version(version, version_info):
|
||||
def __get_version(saltstack_version):
|
||||
'''
|
||||
If we can get a version provided at installation time or from Git, use
|
||||
that instead, otherwise we carry on.
|
||||
'''
|
||||
try:
|
||||
# Try to import the version information provided at install time
|
||||
from salt._version import __version__, __version_info__ # pylint: disable=E0611,F0401
|
||||
return __version__, __version_info__
|
||||
from salt._version import __saltstack_version__ # pylint: disable=E0611,F0401
|
||||
return __saltstack_version__
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
@ -374,12 +381,12 @@ def __get_version(version, version_info):
|
|||
cwd = SETUP_DIRNAME # pylint: disable=E0602
|
||||
if not os.path.exists(os.path.join(cwd, '.git')):
|
||||
# This is not a Salt git checkout!!! Don't even try to parse...
|
||||
return version, version_info
|
||||
return saltstack_version
|
||||
else:
|
||||
cwd = os.path.abspath(os.path.dirname(__file__))
|
||||
if not os.path.exists(os.path.join(os.path.dirname(cwd), '.git')):
|
||||
# This is not a Salt git checkout!!! Don't even try to parse...
|
||||
return version, version_info
|
||||
return saltstack_version
|
||||
|
||||
try:
|
||||
kwargs = dict(
|
||||
|
@ -399,22 +406,22 @@ def __get_version(version, version_info):
|
|||
err = err.strip()
|
||||
|
||||
if not out or err:
|
||||
return version, version_info
|
||||
return saltstack_version
|
||||
|
||||
parsed_version = SaltStackVersion.parse(out)
|
||||
|
||||
if parsed_version.info > version_info:
|
||||
if parsed_version.info > saltstack_version.info:
|
||||
warnings.warn(
|
||||
'The parsed version info, `{0}`, is bigger than the one '
|
||||
'defined in the file, `{1}`. Missing version bump?'.format(
|
||||
parsed_version.info,
|
||||
version_info
|
||||
saltstack_version.info
|
||||
),
|
||||
UserWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return version, version_info
|
||||
elif parsed_version.info < version_info:
|
||||
return saltstack_version
|
||||
elif parsed_version.info < saltstack_version.info:
|
||||
warnings.warn(
|
||||
'The parsed version info, `{0}`, is lower than the one '
|
||||
'defined in the file, `{1}`.'
|
||||
|
@ -424,29 +431,35 @@ def __get_version(version, version_info):
|
|||
'you followed salt\'s contribute documentation. The version '
|
||||
'string WILL NOT include the git hash.'.format(
|
||||
parsed_version.info,
|
||||
version_info
|
||||
saltstack_version.info
|
||||
),
|
||||
UserWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return version, version_info
|
||||
return parsed_version.string, parsed_version.info
|
||||
return saltstack_version
|
||||
return parsed_version
|
||||
except OSError as os_err:
|
||||
if os_err.errno != 2:
|
||||
# If the errno is not 2(The system cannot find the file
|
||||
# specified), raise the exception so it can be catch by the
|
||||
# developers
|
||||
raise
|
||||
return version, version_info
|
||||
return saltstack_version
|
||||
|
||||
|
||||
# Get additional version information if available
|
||||
__version__, __version_info__ = __get_version(__version__, __version_info__)
|
||||
__saltstack_version__ = __get_version(__saltstack_version__)
|
||||
# This function has executed once, we're done with it. Delete it!
|
||||
del __get_version
|
||||
# <---- Dynamic/Runtime Salt Version Information ---------------------------------------------------------------------
|
||||
|
||||
|
||||
# ----- Common version related attributes - NO NEED TO CHANGE ------------------------------------------------------->
|
||||
__version_info__ = __saltstack_version__.info
|
||||
__version__ = __saltstack_version__.string
|
||||
# <---- Common version related attributes - NO NEED TO CHANGE --------------------------------------------------------
|
||||
|
||||
|
||||
def versions_information(include_salt_cloud=False):
|
||||
'''
|
||||
Report on all of the versions for dependent software
|
||||
|
|
Loading…
Add table
Reference in a new issue