Bowrna commented on a change in pull request #21145:
URL: https://github.com/apache/airflow/pull/21145#discussion_r805174798



##########
File path: dev/breeze/src/airflow_breeze/shell/enter_shell.py
##########
@@ -0,0 +1,176 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from pathlib import Path
+from typing import Dict, List
+
+from airflow_breeze import global_constants
+from airflow_breeze.cache import (
+    check_cache_and_write_if_not_cached,
+    read_from_cache_file,
+    write_to_cache_file,
+)
+from airflow_breeze.console import console
+from airflow_breeze.global_constants import (
+    FLOWER_HOST_PORT,
+    MSSQL_HOST_PORT,
+    MSSQL_VERSION,
+    MYSQL_HOST_PORT,
+    MYSQL_VERSION,
+    POSTGRES_HOST_PORT,
+    POSTGRES_VERSION,
+    REDIS_HOST_PORT,
+    SSH_PORT,
+    WEBSERVER_HOST_PORT,
+)
+from airflow_breeze.shell.shell_builder import ShellBuilder
+from airflow_breeze.utils.docker_command_utils import (
+    check_docker_compose_version,
+    check_docker_resources,
+    check_docker_version,
+)
+from airflow_breeze.utils.path_utils import BUILD_CACHE_DIR
+from airflow_breeze.utils.run_utils import (
+    filter_out_none,
+    instruct_for_setup,
+    md5sum_check_if_build_is_needed,
+    run_command,
+)
+from airflow_breeze.visuals import ASCIIART, ASCIIART_STYLE, CHEATSHEET, 
CHEATSHEET_STYLE
+
+PARAMS_TO_ENTER_SHELL = {
+    "HOST_USER_ID": "host_user_id",
+    "HOST_GROUP_ID": "host_group_id",
+    "COMPOSE_FILE": "compose_files",
+    "PYTHON_MAJOR_MINOR_VERSION": "python_version",
+    "BACKEND": "backend",
+    "AIRFLOW_VERSION": "airflow_version",
+    "INSTALL_AIRFLOW_VERSION": "install_airflow_version",
+    "AIRFLOW_SOURCES": "airflow_sources",
+    "AIRFLOW_CI_IMAGE": "airflow_ci_image_name",
+    "AIRFLOW_CI_IMAGE_WITH_TAG": "airflow_ci_image_name_with_tag",
+    "AIRFLOW_PROD_IMAGE": "airflow_prod_image_name",
+    "AIRFLOW_IMAGE_KUBERNETES": "airflow_image_kubernetes",
+    "SQLITE_URL": "sqlite_url",
+    "USE_AIRFLOW_VERSION": "use_airflow_version",
+    "SKIP_TWINE_CHECK": "skip_twine_check",
+    "USE_PACKAGES_FROM_DIST": "use_packages_from_dist",
+    "EXECUTOR": "executor",
+    "START_AIRFLOW": "start_airflow",
+    "ENABLED_INTEGRATIONS": "enabled_integrations",
+    "GITHUB_ACTIONS": "github_actions",
+    "ISSUE_ID": "issue_id",
+    "NUM_RUNS": "num_runs",
+    "VERSION_SUFFIX_FOR_SVN": "version_suffix_for_svn",
+    "VERSION_SUFFIX_FOR_PYPI": "version_suffix_for_pypi",
+}
+
+PARAMS_FOR_SHELL_CONSTANTS = {
+    "SSH_PORT": SSH_PORT,
+    "WEBSERVER_HOST_PORT": WEBSERVER_HOST_PORT,
+    "FLOWER_HOST_PORT": FLOWER_HOST_PORT,
+    "REDIS_HOST_PORT": REDIS_HOST_PORT,
+    "MYSQL_HOST_PORT": MYSQL_HOST_PORT,
+    "MYSQL_VERSION": MYSQL_VERSION,
+    "MSSQL_HOST_PORT": MSSQL_HOST_PORT,
+    "MSSQL_VERSION": MSSQL_VERSION,
+    "POSTGRES_HOST_PORT": POSTGRES_HOST_PORT,
+    "POSTGRES_VERSION": POSTGRES_VERSION,
+}
+
+PARAMS_IN_CACHE = {
+    'python_version': 'PYTHON_MAJOR_MINOR_VERSION',
+    'backend': 'BACKEND',
+    'executor': 'EXECUTOR',
+    'postgres_version': 'POSTGRES_VERSION',
+    'mysql_version': 'MYSQL_VERSION',
+    'mssql_version': 'MSSQL_VERSION',
+}
+
+DEFAULT_VALUES_FOR_PARAM = {
+    'python_version': 'DEFAULT_PYTHON_MAJOR_MINOR_VERSION',
+    'backend': 'DEFAULT_BACKEND',
+    'executor': 'DEFAULT_EXECUTOR',
+    'postgres_version': 'POSTGRES_VERSION',
+    'mysql_version': 'MYSQL_VERSION',
+    'mssql_version': 'MSSQL_VERSION',
+}
+
+
+def construct_arguments_docker_compose_command(shell_params: ShellBuilder) -> 
List[str]:
+    args_command = []
+    for param_name in PARAMS_TO_ENTER_SHELL:
+        param_value = PARAMS_TO_ENTER_SHELL[param_name]
+        args_command.append("-e")
+        args_command.append(param_name + '=' + str(getattr(shell_params, 
param_value)))
+    for constant_param_name in PARAMS_FOR_SHELL_CONSTANTS:
+        constant_param_value = PARAMS_FOR_SHELL_CONSTANTS[constant_param_name]
+        args_command.append("-e")
+        args_command.append(constant_param_name + '=' + 
str(constant_param_value))
+    return args_command
+
+

Review comment:
       @potiuk this is how I tried to implement running docker-compose command 
with `-e` flags.




-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to