From 5f4c87d6338aa380c69e8181f3cf35aeec756d6d Mon Sep 17 00:00:00 2001
From: yatinkarel <ykarel@redhat.com>
Date: Fri, 20 Nov 2020 20:30:16 +0530
Subject: [PATCH] Handle DLRN hash in consumer upgrade jobs

dlrn_hash_tag is meant to be named like current-tripleo,
tripleo-ci-testing etc, but with switch to provider/consumer
jobs aggregate/commit hashes are being used as dlrn_hash_tag.

Make repo-setup to handle the case where dlrn_hash_tag is
equivalent to an aggregate hash.

Closes-Bug: #1905034
Change-Id: I098de6def27fbaa47a9cf84ccdf0af085a2db901
---
 config/release/tripleo-ci/CentOS-8/master.yml                 | 4 ++++
 .../tripleo-ci/CentOS-8/promotion-testing-hash-master.yml     | 4 ++++
 .../tripleo-ci/CentOS-8/promotion-testing-hash-train.yml      | 4 ++++
 .../tripleo-ci/CentOS-8/promotion-testing-hash-ussuri.yml     | 4 ++++
 .../tripleo-ci/CentOS-8/promotion-testing-hash-victoria.yml   | 4 ++++
 config/release/tripleo-ci/CentOS-8/train.yml                  | 4 ++++
 config/release/tripleo-ci/CentOS-8/ussuri.yml                 | 4 ++++
 config/release/tripleo-ci/CentOS-8/victoria.yml               | 4 ++++
 8 files changed, 32 insertions(+)

diff --git a/config/release/tripleo-ci/CentOS-8/master.yml b/config/release/tripleo-ci/CentOS-8/master.yml
index e8a393f4..4b4f0fab 100644
--- a/config/release/tripleo-ci/CentOS-8/master.yml
+++ b/config/release/tripleo-ci/CentOS-8/master.yml
@@ -64,11 +64,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-master.yml b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-master.yml
index ec568b26..f35b4660 100644
--- a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-master.yml
+++ b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-master.yml
@@ -52,11 +52,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-train.yml b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-train.yml
index 64c3e433..713239be 100644
--- a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-train.yml
+++ b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-train.yml
@@ -50,11 +50,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-ussuri.yml b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-ussuri.yml
index d1da3fc7..8dccef90 100644
--- a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-ussuri.yml
+++ b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-ussuri.yml
@@ -51,11 +51,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-victoria.yml b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-victoria.yml
index db0230ad..8b913b9d 100644
--- a/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-victoria.yml
+++ b/config/release/tripleo-ci/CentOS-8/promotion-testing-hash-victoria.yml
@@ -52,11 +52,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/train.yml b/config/release/tripleo-ci/CentOS-8/train.yml
index 6cf8daf3..f48d476b 100644
--- a/config/release/tripleo-ci/CentOS-8/train.yml
+++ b/config/release/tripleo-ci/CentOS-8/train.yml
@@ -55,11 +55,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/ussuri.yml b/config/release/tripleo-ci/CentOS-8/ussuri.yml
index 23e149bf..8b7517cf 100644
--- a/config/release/tripleo-ci/CentOS-8/ussuri.yml
+++ b/config/release/tripleo-ci/CentOS-8/ussuri.yml
@@ -72,11 +72,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
diff --git a/config/release/tripleo-ci/CentOS-8/victoria.yml b/config/release/tripleo-ci/CentOS-8/victoria.yml
index c472d43c..e491e9ed 100644
--- a/config/release/tripleo-ci/CentOS-8/victoria.yml
+++ b/config/release/tripleo-ci/CentOS-8/victoria.yml
@@ -64,11 +64,15 @@ repo_cmd_before: |
   fi
   {% if dlrn_hash_path_newest is defined and dlrn_hash_path_newest %}
     export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_path_newest }}"
+  {% elif dlrn_hash_tag_newest is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG_NEWEST="current/{{ dlrn_hash_tag_newest[:2] }}/{{ dlrn_hash_tag_newest[2:4] }}/{{ dlrn_hash_tag_newest }}"
   {% else %}
     export DLRN_PATH_TAG_NEWEST="{{ dlrn_hash_tag_newest }}"
   {% endif %}
   {% if dlrn_hash_path is defined and dlrn_hash_path %}
     export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_path }}"
+  {% elif dlrn_hash_tag is match("^[a-zA-Z0-9]{32}$") %}
+    export DLRN_PATH_TAG="{{ promote_source }}/{{ dlrn_hash_tag[:2] }}/{{ dlrn_hash_tag[2:4] }}/{{ dlrn_hash_tag }}"
   {% else %}
     export DLRN_PATH_TAG="{{ dlrn_hash_tag }}"
   {% endif %}
-- 
2.20.1

