summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2016-10-31 10:42:17 -0400
committerGitHub <noreply@github.com>2016-10-31 10:42:17 -0400
commit0b9e5b499098be3031c0553fc2649cf2b330cdfb (patch)
treea855943520aca3e3190528424196b141dd5647bd
parente5fdc799b8ff193ff275c6071dac1db9914a2607 (diff)
parent9a2f90fb76aa415813d934731ddd9099aab07587 (diff)
downloadopenshift-0b9e5b499098be3031c0553fc2649cf2b330cdfb.tar.gz
openshift-0b9e5b499098be3031c0553fc2649cf2b330cdfb.tar.bz2
openshift-0b9e5b499098be3031c0553fc2649cf2b330cdfb.tar.xz
openshift-0b9e5b499098be3031c0553fc2649cf2b330cdfb.zip
Merge pull request #2680 from tbielawa/BZ389137
Remove commit offset strings from parsed versions
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 0a783b164..6c045e7ab 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1206,7 +1206,7 @@ def get_openshift_version(facts):
# version
if 'common' in facts:
if 'version' in facts['common'] and facts['common']['version'] is not None:
- return facts['common']['version']
+ return chomp_commit_offset(facts['common']['version'])
if os.path.isfile('/usr/bin/openshift'):
_, output, _ = module.run_command(['/usr/bin/openshift', 'version'])
@@ -1221,7 +1221,27 @@ def get_openshift_version(facts):
_, output, _ = module.run_command(['/usr/local/bin/openshift', 'version'])
version = parse_openshift_version(output)
- return version
+ return chomp_commit_offset(version)
+
+
+def chomp_commit_offset(version):
+ """Chomp any "+git.foo" commit offset string from the given `version`
+ and return the modified version string.
+
+Ex:
+- chomp_commit_offset(None) => None
+- chomp_commit_offset(1337) => "1337"
+- chomp_commit_offset("v3.4.0.15+git.derp") => "v3.4.0.15"
+- chomp_commit_offset("v3.4.0.15") => "v3.4.0.15"
+- chomp_commit_offset("v1.3.0+52492b4") => "v1.3.0"
+ """
+ if version is None:
+ return version
+ else:
+ # Stringify, just in case it's a Number type. Split by '+' and
+ # return the first split. No concerns about strings without a
+ # '+', .split() returns an array of the original string.
+ return str(version).split('+')[0]
def get_container_openshift_version(facts):