diff options
author | Tim Bielawa <tbielawa@redhat.com> | 2016-10-27 11:41:42 -0700 |
---|---|---|
committer | Tim Bielawa <tbielawa@redhat.com> | 2016-10-31 07:33:34 -0700 |
commit | 9a2f90fb76aa415813d934731ddd9099aab07587 (patch) | |
tree | a855943520aca3e3190528424196b141dd5647bd /roles/openshift_facts/library | |
parent | e5fdc799b8ff193ff275c6071dac1db9914a2607 (diff) | |
download | openshift-9a2f90fb76aa415813d934731ddd9099aab07587.tar.gz openshift-9a2f90fb76aa415813d934731ddd9099aab07587.tar.bz2 openshift-9a2f90fb76aa415813d934731ddd9099aab07587.tar.xz openshift-9a2f90fb76aa415813d934731ddd9099aab07587.zip |
Remove commit offset strings from parsed versions
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 24 |
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): |