mike-jumper commented on code in PR #717:
URL: https://github.com/apache/guacamole-client/pull/717#discussion_r866358028


##########
guacamole-docker/bin/start.sh:
##########
@@ -251,40 +251,97 @@ environment variables or their corresponding Docker 
secrets by appending _FILE
 to the environment variable, and setting the value to the path of the
 corresponding secret:
 
-    POSTGRES_USER      The user to authenticate as when connecting to
+    POSTGRESQL_USER      The user to authenticate as when connecting to
                        PostgreSQL.
 
-    POSTGRES_PASSWORD  The password to use when authenticating with PostgreSQL
-                       as POSTGRES_USER.
+    POSTGRESQL_PASSWORD  The password to use when authenticating with 
PostgreSQL
+                       as POSTGRESQL_USER.
 
-    POSTGRES_DATABASE  The name of the PostgreSQL database to use for Guacamole
+    POSTGRESQL_DATABASE  The name of the PostgreSQL database to use for 
Guacamole
                        authentication.
 END
     exit 1;
 }
 
+## Provide backward compatibility on POSTGRES_* environment variables
+## In case of new deployment, please use POSTGRESQL_* equivalent variables.
+if [ -n "$POSTGRES_HOSTNAME" ]; then
+    POSTGRESQL_HOSTNAME=$POSTGRES_HOSTNAME;
+fi
+if [ -n "$POSTGRES_PORT" ]; then
+    POSTGRESQL_PORT=$POSTGRES_PORT;
+fi
+if [ -n "$POSTGRES_DATABASE" ]; then
+    POSTGRESQL_DATABASE=$POSTGRES_DATABASE;
+fi
+if [ -n "$POSTGRES_DATABASE_FILE" ]; then
+    POSTGRESQL_DATABASE=$POSTGRES_DATABASE_FILE;
+fi
+if [ -n "$POSTGRES_USER_FILE" ]; then
+    POSTGRESQL_USER_FILE=$POSTGRES_USER_FILE;
+fi
+if [ -n "$POSTGRES_USER" ]; then
+    POSTGRESQL_USER=$POSTGRES_USER;
+fi
+if [ -n "$POSTGRES_PASSWORD_FILE" ]; then
+    POSTGRESQL_PASSWORD_FILE=$POSTGRES_PASSWORD_FILE;
+fi
+if [ -n "$POSTGRES_PASSWORD" ]; then
+    POSTGRESQL_PASSWORD=$POSTGRES_PASSWORD;
+fi
+if [ -n "$POSTGRES_ABSOLUTE_MAX_CONNECTIONS" ]; then
+    POSTGRESQL_ABSOLUTE_MAX_CONNECTIONS=$POSTGRES_ABSOLUTE_MAX_CONNECTIONS;
+fi
+if [ -n "$POSTGRES_DEFAULT_MAX_CONNECTIONS" ]; then
+    POSTGRESQL_DEFAULT_MAX_CONNECTIONS=$POSTGRES_DEFAULT_MAX_CONNECTIONS;
+fi
+if [ -n "$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS" ]; then
+    
POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS=$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS;
+fi
+if [ -n "$POSTGRES_DEFAULT_MAX_CONNECTIONS_PER_USER" ]; then
+    
POSTGRESQL_DEFAULT_MAX_CONNECTIONS_PER_USER=$POSTGRES_DEFAULT_MAX_CONNECTIONS_PER_USER;
+fi
+if [ -n "$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER" ]; then
+    
POSTGRESQL_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER=$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER;
+fi
+if [ -n "$POSTGRES_DEFAULT_STATEMENT_TIMEOUT" ]; then
+    POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT=$POSTGRES_DEFAULT_STATEMENT_TIMEOUT;
+fi
+if [ -n "$POSTGRES_USER_REQUIRED" ]; then
+    POSTGRESQL_USER_REQUIRED=$POSTGRES_USER_REQUIRED;
+fi
+if [ -n "$POSTGRES_SOCKET_TIMEOUT" ]; then
+    POSTGRESQL_SOCKET_TIMEOUT=$POSTGRES_SOCKET_TIMEOUT;
+fi
+if [ -n "$POSTGRES_SSL_KEY_PASSWORD_FILE" ]; then
+    POSTGRESQL_SSL_KEY_PASSWORD_FILE=$POSTGRES_SSL_KEY_PASSWORD_FILE;
+fi
+if [ -n "$POSTGRES_SSL_KEY_PASSWORD" ]; then
+    POSTGRESQL_SSL_KEY_PASSWORD=$POSTGRES_SSL_KEY_PASSWORD;
+fi

Review Comment:
   This is lengthy indeed. I think it would be better here to:
   
   1. Leverage indirect references so we can use a loop and not copy/paste the 
same `if` block repeatedly.
   2. Add a warning message about the deprecation and recommend migration.
   
   For example:
   
   ```bash
   for VAR_BASE in \
       HOSTNAME PORT \
       DATABASE USER PASSWORD \
       DATABASE_FILE USER_FILE PASSWORD_FILE \
       ...; do
   
           OLD_VAR="POSTGRES_$VAR_BASE"
           NEW_VAR="POSTGRESQL_$VAR_BASE"
   
           if [ -n "${!OLD_VAR}" ]; then
               printf -v "$NEW_VAR" "%s" "${!OLD_VAR}"
               echo "Some warning about new vs. old..."
           fi
   
   done



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