You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/01/07 14:47:52 UTC

[GitHub] [airflow] potiuk commented on a change in pull request #7065: [AIRFLOW-6475] Remove duplication of volume mount specs in Breeze.

potiuk commented on a change in pull request #7065: [AIRFLOW-6475] Remove duplication of volume mount specs in Breeze.
URL: https://github.com/apache/airflow/pull/7065#discussion_r363781961
 
 

 ##########
 File path: scripts/ci/_utils.sh
 ##########
 @@ -78,6 +78,59 @@ function print_info() {
     fi
 }
 
+# shellcheck disable=SC1087
+# Simple (?) no-dependency needed Yaml PARSER
+# From https://stackoverflow.com/questions/5014632/how-can-i-parse-a-yaml-file-from-a-linux-shell-script
+function parse_yaml {
+
+    if [[ -z $1 ]]; then
+        echo "Please provide yaml filename as first parameter."
+        exit 1
+    fi
+    local prefix=$2
+    local s='[[:space:]]*' w='[a-zA-Z0-9_-]*' FS
+    FS=$(echo @|tr @ '\034')
+    sed -ne "s|,$s\]$s\$|]|" \
+         -e ":1;s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s,$s\(.*\)$s\]|\1\2: [\3]\n\1  - \4|;t1" \
+         -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1  - \3|;p" "${1}" | \
+    sed -ne "s|,$s}$s\$|}|" \
+         -e ":1;s|^\($s\)-$s{$s\(.*\)$s,$s\($w\)$s:$s\(.*\)$s}|\1- {\2}\n\1  \3: \4|;t1" \
+         -e    "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1  \2|;p" | \
+    sed -ne "s|^\($s\):|\1|" \
+         -e "s|^\($s\)-$s[\"']\(.*\)[\"']$s\$|\1$FS$FS\2|p" \
+         -e "s|^\($s\)-$s\(.*\)$s\$|\1$FS$FS\2|p" \
+         -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$FS\2$FS\3|p" \
+         -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$FS\2$FS\3|p" | \
+    awk -F"${FS}" '{
+       indent = length($1)/2;
+       vname[indent] = $2;
+       for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}}
+       if(length($2)== 0){  vname[indent]= ++idx[indent] };
+       if (length($3) > 0) {
+          vn=""; for (i=0; i<indent; i++) { vn=(vn)(vname[i])("_")}
+          printf("%s%s%s=\"%s\"\n", "'"${prefix}"'",vn, vname[indent], $3);
+       }
+    }'
+}
+
+# parse docker-compose-local.yaml file to convert volumes entries
+# from airflow-testing section to "-v" "volume mapping" series of options
+function convert_docker_mounts_to_docker_params() {
+    ESCAPED_AIRFLOW_SOURCES=$(echo "${AIRFLOW_SOURCES}" | sed -e 's/[\/&]/\\&/g')
+    # shellcheck disable=2046
+    while IFS= read -r LINE; do
+        echo "-v"
+        echo "${LINE}"
+    done < <(parse_yaml scripts/ci/docker-compose-local.yml COMPOSE_ | \
+            grep "COMPOSE_services_airflow-testing_volumes_" | \
+            sed "s/..\/../${ESCAPED_AIRFLOW_SOURCES}/" | \
+            sed "s/COMPOSE_services_airflow-testing_volumes_//" | \
+            sort -t "=" -k 1 -n | \
 
 Review comment:
   Yes, I prefer to have them sorted - both in the input and output. This way it's consistent (also for tests).

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services