Browse Source

Fix image version handling for v1.2.0-rc1

Scott Dodson 9 years ago
parent
commit
b90fb39790
2 changed files with 8 additions and 4 deletions
  1. 5 2
      filter_plugins/oo_filters.py
  2. 3 2
      roles/openshift_docker/tasks/main.yml

+ 5 - 2
filter_plugins/oo_filters.py

@@ -820,15 +820,18 @@ class FilterModule(object):
     def oo_image_tag_to_rpm_version(version, include_dash=False):
     def oo_image_tag_to_rpm_version(version, include_dash=False):
         """ Convert an image tag string to an RPM version if necessary
         """ Convert an image tag string to an RPM version if necessary
             Empty strings and strings that are already in rpm version format
             Empty strings and strings that are already in rpm version format
-            are ignored.
+            are ignored. Also remove non semantic version components.
 
 
             Ex. v3.2.0.10 -> -3.2.0.10
             Ex. v3.2.0.10 -> -3.2.0.10
+                v1.2.0-rc1 -> -1.2.0
         """
         """
         if not isinstance(version, basestring):
         if not isinstance(version, basestring):
             raise errors.AnsibleFilterError("|failed expects a string or unicode")
             raise errors.AnsibleFilterError("|failed expects a string or unicode")
-
+        # TODO: Do we need to make this actually convert v1.2.0-rc1 into 1.2.0-0.rc1
+        # We'd need to be really strict about how we build the RPM Version+Release
         if version.startswith("v"):
         if version.startswith("v"):
             version = version.replace("v", "")
             version = version.replace("v", "")
+            version = version.split('-')[0]
 
 
             if include_dash:
             if include_dash:
                 version = "-" + version
                 version = "-" + version

+ 3 - 2
roles/openshift_docker/tasks/main.yml

@@ -9,7 +9,8 @@
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool and openshift_image_tag is not defined
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool and openshift_image_tag is not defined
 
 
 - set_fact:
 - set_fact:
-    l_image_tag: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0] }}"
+    l_image_tag: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-') if openshift.common.deployment_type == 'origin' else
+                     cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0] }}"
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool and openshift_image_tag is not defined
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool and openshift_image_tag is not defined
 
 
 - set_fact:
 - set_fact:
@@ -24,5 +25,5 @@
   - role: docker
   - role: docker
     local_facts:
     local_facts:
       openshift_image_tag: "{{ l_image_tag }}"
       openshift_image_tag: "{{ l_image_tag }}"
-      openshift_version: "{{ l_image_tag if l_image_tag is defined else '' | oo_image_tag_to_rpm_version }}"
+      openshift_version: "{{ l_image_tag.split('-')[0] if l_image_tag is defined else '' | oo_image_tag_to_rpm_version }}"
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool
   when: openshift.common.is_containerized is defined and openshift.common.is_containerized | bool