mik-laj commented on a change in pull request #17847:
URL: https://github.com/apache/airflow/pull/17847#discussion_r696666501



##########
File path: scripts/in_container/prod/entrypoint_prod.sh
##########
@@ -83,24 +84,12 @@ function wait_for_connection {
     # It tries `CONNECTION_CHECK_MAX_COUNT` times and sleeps 
`CONNECTION_CHECK_SLEEP_TIME` between checks
     local connection_url
     connection_url="${1}"
-    local detected_backend=""
-    local detected_host=""
-    local detected_port=""
-
-    # Auto-detect DB parameters
-    # Examples:
-    #  postgres://YourUserName:password@YourHostname:5432/YourDatabaseName
-    #  postgres://YourUserName:password@YourHostname:5432/YourDatabaseName
-    #  postgres://YourUserName:@YourHostname:/YourDatabaseName
-    #  postgres://YourUserName@YourHostname/YourDatabaseName
-    [[ ${connection_url} =~ 
([^:]*)://([^:@]*):?([^@]*)@?([^/:]*):?([0-9]*)/([^\?]*)\??(.*) ]] && \
-        detected_backend=${BASH_REMATCH[1]} &&
-        # Not used USER match
-        # Not used PASSWORD match
-        detected_host=${BASH_REMATCH[4]} &&
-        detected_port=${BASH_REMATCH[5]} &&
-        # Not used SCHEMA match
-        # Not used PARAMS match
+    local detected_backend
+    detected_backend=$(python -c "from urllib.parse import urlsplit; 
print(urlsplit('${connection_url}').scheme)")

Review comment:
       For readability, we can extraactt it to a separate function.
   ```
   function get_url_part() {
       url_part="$1";
       connection_url="$2";
       python -c "from urllib.parse import urlsplit; import sys; 
print(getattr(urlsplit(sys.argv[2]), sys.argv[1]))" "${url_part}" 
"${connection_url}"
   }
   get_url_part scheme redis://
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to