@@ -38,19 +38,23 @@ login() {
3838
3939# TODO: handle that previous instance is a different version
4040hook_pre_delete () {
41- for T in $OKAPI_TENANTS ; do
42- echo " [{\" id\" :\" ${SVCID} \" ,\" action\" :\" disable\" }]" | post -d @- $U /_/proxy/tenants/$T /install
43- done
41+ if test -n " ${OKAPI_TENANTS} " ; then
42+ for T in $OKAPI_TENANTS ; do
43+ echo " [{\" id\" :\" ${SVCID} \" ,\" action\" :\" disable\" }]" | post -d @- $U /_/proxy/tenants/$T /install
44+ done
45+ fi
4446 delete " $U /_/discovery/modules/${SVCID} /${INSTID} "
4547 delete " $U /_/proxy/modules/${SVCID} "
4648}
4749
4850hook_post_install () {
4951 echo $OKAPI_MD | post --fail-with-body -d @- $U /_/proxy/modules
5052 echo " {\" srvcId\" :\" $SVCID \" ,\" instId\" :\" ${INSTID} \" ,\" url\" :\" ${MODULE_URL} \" }" | post --fail-with-body -d @- $U /_/discovery/modules
51- for T in $OKAPI_TENANTS ; do
52- echo " [{ \" id\" :\" ${SVCID} \" ,\" action\" :\" enable\" }]" | post --fail-with-body -d @- $U /_/proxy/tenants/$T /install
53- done
53+ if test -n " ${OKAPI_TENANTS} " ; then
54+ for T in $OKAPI_TENANTS ; do
55+ echo " [{ \" id\" :\" ${SVCID} \" ,\" action\" :\" enable\" }]" | post --fail-with-body -d @- $U /_/proxy/tenants/$T /install
56+ done
57+ fi
5458}
5559
5660tenants_lookup () {
@@ -86,8 +90,7 @@ tenants_lookup() {
8690prepare () {
8791 fail=false
8892 if test -z " $OKAPI_TENANTS " ; then
89- echo " OKAPI_TENANTS not set"
90- fail=true
93+ echo " OKAPI_TENANTS not set, will deploy only (no enablement)"
9194 fi
9295 if test -z " $OKAPI_URL " ; then
9396 echo " OKAPI_URL not set"
@@ -118,12 +121,16 @@ prepare() {
118121 OKAPI_ADMIN_TENANT=${OKAPI_ADMIN_TENANT:- supertenant}
119122 SVCID=` echo $OKAPI_MD | jq -r ' .id' `
120123 INSTID=inst-${SVCID}
121- OKAPI_TENANTS=$( echo " $OKAPI_TENANTS " | tr ' ,' ' ' )
124+ if test -n " ${OKAPI_TENANTS} " ; then
125+ OKAPI_TENANTS=$( echo " $OKAPI_TENANTS " | tr ' ,' ' ' )
126+ fi
122127}
123128
124129prepare
125130login
126- tenants_lookup
131+ if test -n " ${OKAPI_TENANTS} " ; then
132+ tenants_lookup
133+ fi
127134
128135hook_pre_delete
129136hook_post_install
0 commit comments