ashb commented on a change in pull request #4938: [AIRFLOW-4117] Multi-staging 
Image - Travis CI tests [Step 3/3]
URL: https://github.com/apache/airflow/pull/4938#discussion_r299359816
 
 

 ##########
 File path: hooks/build
 ##########
 @@ -143,12 +147,33 @@ echo
 
 # Extract python version from image name we want to build in case it was passed
 # Via IMAGE_NAME
-# This nice bash construct below extracts last field after '-' delimiter
-# So for example 'latest-3.6' will produce PYTHON_VERSION=3.6
-PYTHON_VERSION=$(echo "${LOCAL_IMAGE}" | rev | cut -d '-' -f1 | rev )
-export PYTHON_VERSION
+# This nice bash construct below extracts last field after '-python' delimiter
+# So for example 'airflow:master-python3.6' will produce 
LONG_PYTHON_VERSION=python3.6
+LONG_PYTHON_VERSION=$(echo "${LOCAL_IMAGE}" | rev | cut -d '-' -f1 | rev )
+export LONG_PYTHON_VERSION
+
+echo
+echo "LONG_PYTHON_VERSION=${LONG_PYTHON_VERSION}"
+echo
+
+if [[ ! ${LONG_PYTHON_VERSION} =~ python[2-3]\.[0-9]+ ]]; then
+    echo
+    echo "ERROR! Python version extracted from IMAGE_NAME does not match the 
pythonX.Y format"
+    echo "The IMAGE_NAME format should be '<BRANCH>-pythonX.Y'"
+    echo
+    exit 1
+fi
+
+PYTHON_VERSION=${LONG_PYTHON_VERSION:6}
 
 Review comment:
   ```suggestion
   PYTHON_VERSION=${LONG_PYTHON_VERSION#python}
   ```
   
   Would be clearer - I was wondering what "python6" was.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to