]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ceph-ansible-pr-syntax-chec: add test_ceph_release_in_ceph_default 1104/head
authorSébastien Han <seb@redhat.com>
Wed, 22 Aug 2018 09:30:53 +0000 (11:30 +0200)
committerSébastien Han <seb@redhat.com>
Wed, 22 Aug 2018 10:04:32 +0000 (12:04 +0200)
function

This new function searches for statements like '    -
ceph_release_num[ceph_release] ' in the ceph-defaults role. These must
never be used since the ceph_release is set by role running after
ceph-defaults.
However, the ceph-ansible ci passes this variable when running so it's
always defined, even before ceph-defaults runs. This is particularity
from our CI. So this is done, our Ci won't complain but general users
will end with an error like "'dict object' has no attribute" since the
variable does not exist at the time of the ceph-defaults play.

Signed-off-by: Sébastien Han <seb@redhat.com>
ceph-ansible-pr-syntax-check/build/build

index 045ed2f02460a49651746383c54b014632f85e6b..29d48faf704a7dab7d9a69b360fd9fc88e57344f 100644 (file)
@@ -66,13 +66,22 @@ function test_sign_off {
 
 function test_capital_letter {
   if git_diff_to_head | grep -E '^[<>+].*- name:' | grep '[[:upper:]]'; then
-      echo "'- name:' statement must not contain any capital letters!"
-      echo "Remove any capital letters from task's name."
-      return 1
-    fi
+    echo "'- name:' statement must not contain any capital letters!"
+    echo "Remove any capital letters from task's name."
+    return 1
+  fi
   echo "No capital letters found in task's name!" && return 0
 }
 
+function test_ceph_release_in_ceph_default {
+  if match_file "roles/ceph-defaults/" | grep -E '^[<>+].*- ceph_release_num\[ceph_release\]'; then
+    echo "Do not use statements like '- ceph_release_num[ceph_release]' in ceph-defaults role!"
+    echo "'ceph_release' is only populated **after** the play of ceph-defaults, typically in ceph-common or ceph-docker-common."
+    return 1
+  fi
+  echo "No '- ceph_release_num[ceph_release]' statements found in ceph-defaults role!" && return 0
+}
+
 
 ########
 # MAIN #
@@ -83,3 +92,4 @@ syntax_check
 group_vars_check
 test_sign_off
 test_capital_letter
+test_ceph_release_in_ceph_default