From e9c87e2c135f54862905d4677ebf97551bfa1a6e Mon Sep 17 00:00:00 2001 From: Steve Milner Date: Mon, 13 Mar 2017 14:08:13 -0400 Subject: Verify openshift_image_tag is valid during openshift_version main - origin examples: v1.2.3, v1.2.3-alpha, v1.2.3-beta.1, v1.5.0-rc.0 - openshift-enterprise examples: v3.5, v3.5.3, v3.5.3.4, v3.5.3.4-1 --- roles/openshift_version/tasks/main.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'roles/openshift_version') diff --git a/roles/openshift_version/tasks/main.yml b/roles/openshift_version/tasks/main.yml index 4de36ad1b..ef1783244 100644 --- a/roles/openshift_version/tasks/main.yml +++ b/roles/openshift_version/tasks/main.yml @@ -26,6 +26,37 @@ openshift_release: "{{ openshift_release | string }}" when: openshift_release is defined +# Verify that the image tag is in a valid format +- block: + + # Verifies that when the deployment type is origin the version: + # - starts with a v + # - Has 3 integers seperated by dots + # It also allows for optional trailing data which: + # - must start with a dash + # - may contain numbers, letters, dashes and dots. + - assert: + that: + - "{{ openshift_image_tag|match('(^v?\\d+\\.\\d+\\.\\d+(-[\\w\\-\\.]*)?$)') }}" + msg: "openshift_image_tag must be in the format v#.#.#[-optional.#]. Examples: v1.2.3, v3.5.1-alpha.1" + when: openshift.common.deployment_type == 'origin' + + # Verifies that when the deployment type is openshift-enterprise the version: + # - starts with a v + # - Has at least 2 integers seperated by dots + # It also allows for optional trailing data which: + # - must start with a dash + # - may contain numbers + - assert: + that: + - "{{ openshift_image_tag|match('(^v\\d+\\.\\d+[\\.\\d+]*(-\\d+)?$)') }}" + msg: "openshift_image_tag must be in the format v#.#[.#[.#]]. Examples: v1.2, v3.4.1, v3.5.1.3, v1.2-1, v1.2.3-4" + when: openshift.common.deployment_type == 'openshift-enterprise' + + when: + - openshift_image_tag is defined + - openshift_image_tag != "latest" + # Add a v to the start of the openshift_image_tag if one was not provided - set_fact: openshift_image_tag: "{{ 'v' + openshift_image_tag }}" -- cgit v1.2.1