From c892ed2f6c807146150864b20fb6fd818290b1da Mon Sep 17 00:00:00 2001
From: Jarek Potiuk <jarek@potiuk.com>
Date: Sun, 16 Feb 2020 14:40:13 +0100
Subject: [PATCH] [AIRFLOW-6820] split breeze into functions

---
 .travis.yml                                   |    2 +-
 airflow/www/static/docs                       |    1 -
 breeze                                        | 1429 +++++++++--------
 breeze-complete                               |    6 +-
 common/_autodetect_variables.sh               |    6 +-
 hooks/build                                   |  109 +-
 scripts/ci/_utils.sh                          |   98 +-
 scripts/ci/ci_check_license.sh                |    2 +-
 scripts/ci/ci_cleanup.sh                      |   33 -
 scripts/ci/ci_docs.sh                         |   14 +
 scripts/ci/ci_fix_ownership.sh                |    2 +-
 scripts/ci/ci_flake8.sh                       |    4 +-
 scripts/ci/ci_mypy.sh                         |    2 +-
 scripts/ci/ci_pylint_main.sh                  |    4 +-
 scripts/ci/ci_pylint_tests.sh                 |    4 +-
 scripts/ci/ci_refresh_pylint_todo.sh          |    2 +-
 .../ci/in_container/_in_container_utils.sh    |   96 +-
 scripts/ci/in_container/check_environment.sh  |   34 +-
 scripts/ci/in_container/entrypoint_ci.sh      |    3 +-
 .../in_container/kubernetes/app/deploy_app.sh |    6 +-
 .../kubernetes/setup_kind_cluster.sh          |    2 -
 tests/bats/test_breeze_params.bats            |    8 +-
 22 files changed, 900 insertions(+), 967 deletions(-)
 delete mode 120000 airflow/www/static/docs
 delete mode 100755 scripts/ci/ci_cleanup.sh

diff --git a/.travis.yml b/.travis.yml
index 460843f20754f..91c23cef1810c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ env:
   global:
     - BUILD_ID=${TRAVIS_BUILD_ID}
     - MOUNT_LOCAL_SOURCES="false"
-    - AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS="true"
+    - MOUNT_HOST_AIRFLOW_VOLUME="true"
     - FORCE_ANSWER_TO_QUESTIONS="yes"
     - AIRFLOW_CI_SILENT="true"
     - CI="true"
diff --git a/airflow/www/static/docs b/airflow/www/static/docs
deleted file mode 120000
index d5d38018e2486..0000000000000
--- a/airflow/www/static/docs
+++ /dev/null
@@ -1 +0,0 @@
-../../../docs/_build/html/
\ No newline at end of file
diff --git a/breeze b/breeze
index 7747a6fcf9d86..fe7599fe4f65a 100755
--- a/breeze
+++ b/breeze
@@ -16,146 +16,239 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-
-# Bash sanity settings (error on exit, complain for undefined vars, error when pipe fails)
 set -euo pipefail
 
-export BREEZE=true
-
 MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-export AIRFLOW_SOURCES="${MY_DIR}"
+# Bash arrays need to be defined outside of functions unfortunately :(
+# Array with extra options for Docker compose
+declare -a EXTRA_DC_OPTIONS
+# Array with selected integrations
+declare -a INTEGRATIONS
+# This is where remaining args are passed
+declare -a REMAINING_ARGS
 
-# Directory where all CI scripts are located
-export SCRIPTS_CI_DIR="${MY_DIR}/scripts/ci"
+function setup_default_breeze_variables() {
+    # Whether to actually run docker compose with the command set given
+    COMMAND_TO_RUN="enter_breeze"
+    export BREEZE=true
 
-BUILD_CACHE_DIR="${MY_DIR}/.build"
-FILES_DIR="${MY_DIR}/files"
-TMP_DIR="${MY_DIR}/tmp"
+    export AIRFLOW_SOURCES="${MY_DIR}"
 
-mkdir -pv "${BUILD_CACHE_DIR}"
-mkdir -pv "${TMP_DIR}"
-mkdir -pv "${FILES_DIR}"
+    # Directory where all CI scripts are located
+    SCRIPTS_CI_DIR="${MY_DIR}/scripts/ci"
 
-# Note - we do not use __script_init.sh here because it can only be used from within
-# the CI directory and we need to overrride PYTHON_VERSION based on what we store
-# in the .build directory
+    BUILD_CACHE_DIR="${MY_DIR}/.build"
+    FILES_DIR="${MY_DIR}/files"
+    TMP_DIR="${MY_DIR}/tmp"
 
-# Beginning of the initialisation here
+    mkdir -pv "${BUILD_CACHE_DIR}"
+    mkdir -pv "${TMP_DIR}"
+    mkdir -pv "${FILES_DIR}"
 
-# shellcheck source=scripts/ci/_utils.sh
-. "${SCRIPTS_CI_DIR}/_utils.sh"
-
-initialize_breeze_environment
-
-export PYTHON_VERSION="${PYTHON_VERSION:=$(read_from_file PYTHON_VERSION)}"
-
-basic_sanity_checks
-
-script_start
-
-trap script_end EXIT
-
-# End of initialisation here
+    # Note - we do not use __script_init.sh here because it can only be used from within
+    # the CI directory and we need to overrride PYTHON_VERSION based on what we store
+    # in the .build directory
 
+    # Beginning of the initialisation here
 
-# Sets width of the screen
-SEPARATOR_WIDTH="$(tput cols)"
+    # shellcheck source=scripts/ci/_utils.sh
+    . "${SCRIPTS_CI_DIR}/_utils.sh"
 
-# Name of the script
-CMDNAME="$(basename -- "$0")"
+    export PYTHON_VERSION="${PYTHON_VERSION:=$(read_from_file PYTHON_VERSION)}"
 
-# Update short and long options in the breeze-complete script
-# This way autocomplete will work automatically with all options
-# shellcheck source=breeze-complete
-. "${MY_DIR}/breeze-complete"
+    # Sets width of the screen
+    SEPARATOR_WIDTH="$(tput cols)"
 
-# Whether to actually run docker compose with the command set given
-ENTER_ENVIRONMENT="true"
+    # Name of the script
+    CMDNAME="$(basename -- "$0")"
 
+    # Update short and long options in the breeze-complete script
+    # This way autocomplete will work automatically with all options
+    # shellcheck source=breeze-complete
+    . "${MY_DIR}/breeze-complete"
 
-# Whether to cleanup local image
-CLEANUP_IMAGES="false"
+    # Skips mounting local Airflow sources
+    SKIP_MOUNTING_LOCAL_SOURCES="false"
 
-# Skips mounting local Airflow sources
-SKIP_MOUNTING_LOCAL_SOURCES="false"
+    # Holds chosen command if the -x flag is used.
+    RUN_COMMAND=""
 
-# If set, we initialize local virtualenv and install all dependencies
-INITIALIZE_LOCAL_VIRTUALENV=false
+    # Holds the test target if the -t flag is used.
+    TEST_TARGET=""
 
-# If set, we setup autocomplete for breeze
-SETUP_AUTOCOMPLETE=false
+    # Holds docker compose command if the -d flag is used.
+    DOCKER_COMPOSE_COMMAND=""
 
-# Holds chosen command if the -x flag is used.
-RUN_COMMAND=""
+    # If true, the docker images are rebuilt locally.
+    export NEEDS_DOCKER_BUILD="false"
 
-# Holds the test target if the -t flag is used.
-TEST_TARGET=""
+    # By default we only pull images if we do not have them locally.
+    # This can be overridden by -p flag
+    export FORCE_PULL_IMAGES="false"
 
-# Holds docker compose command if the -d flag is used.
-DOCKER_COMPOSE_COMMAND=""
+    # Runtime is empty initially (might be set to kubernetes in case kubernetes is chosen)
+    RUNTIME=""
 
-#extra options for Docker compose
-EXTRA_DC_OPTIONS=()
+    # Do not enable Kind Kubernetes cluster by default
+    export ENABLE_KIND_CLUSTER="false"
 
-# If true, the docker images are rebuilt locally.
-export AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="false"
+    # We use docker image caches by default to speed up the builds
+    export USE_PULLED_IMAGES_AS_CACHE=${USE_PULLED_IMAGES_AS_CACHE:="true"}
 
-# By default we only pull images if we do not have them locally.
-# This can be overridden by -p flag
-export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES="false"
+    # By default we do not push images. This can be overridden by -u flag.
+    export PUSH_IMAGES=${PUSH_IMAGES:="false"}
 
-# Start airflow-testing image with all the dependencies
-export AIRFLOW_CONTAINER_DEPS="true"
-
-# Runtime is empty initially (might be set to kubernetes in case kubernetes is chosen)
-export RUNTIME=""
-
-# Do not enable Kind Kubernetes cluster by default
-export ENABLE_KIND_CLUSTER="false"
+    # Determine version of the Airflow from version.py
+    AIRFLOW_VERSION=$(cat airflow/version.py - << EOF | python
+print(version.replace("+",""))
+EOF
+    )
+    export AIRFLOW_VERSION
 
-# Do not recreate Kubernetes cluster by default
-export RECREATE_KIND_CLUSTER="false"
+    # Verbosity in running ci scripts
+    export VERBOSE="false"
 
-# Do not stop Kubernetes cluster by default
-export STOP_KIND_CLUSTER="false"
+    # Whether to force build without checking if it is needed
+    export FORCE_BUILD_IMAGES=${FORCE_BUILD_IMAGES:="false"}
 
-# We use docker image caches by default to speed up the builds
-export AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE=${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE:="true"}
+    # Files determining whether asciiart/cheatsheet are suppressed
+    SUPPRESS_CHEATSHEET_FILE="${MY_DIR}/.suppress_cheatsheet"
+    SUPPRESS_ASCIIART_FILE="${MY_DIR}/.suppress_asciiart"
 
-# By default we do not push images. This can be overridden by -u flag.
-export AIRFLOW_CONTAINER_PUSH_IMAGES=${AIRFLOW_CONTAINER_PUSH_IMAGES:="false"}
+    # Default values for flags
 
-# Skip building full CI image locally
-export AIRFLOW_CONTAINER_SKIP_CI_IMAGE="false"
+    _BREEZE_DEFAULT_BACKEND="sqlite"
+    _BREEZE_DEFAULT_KUBERNETES_MODE="git_mode"
+    _BREEZE_DEFAULT_KUBERNETES_VERSION="v1.15.3"
+}
+# End of initialisation here
 
-# Branch name of the base image used (usually master or v1-10-test or v1-10-stable)
-export AIRFLOW_CONTAINER_BRANCH_NAME=${AIRFLOW_CONTAINER_BRANCH_NAME:=${DEFAULT_BRANCH}}
+function initialize_virtualenv() {
+   # Check if we are in virtualenv
+   set +e
+   echo -e "import sys\nif not hasattr(sys,'base_prefix'):\n  sys.exit(1)" | "python${PYTHON_VERSION}"
+   RES=$?
+   set -e
+   if [[ ${RES} != "0" ]]; then
+        echo >&2
+        echo >&2 "ERROR:  Initializing local virtualenv only works when you have virtualenv activated"
+        echo >&2
+        echo >&2 "Please enter your local virtualenv before (for example using 'workon') "
+        echo >&2
+        exit 1
+   else
+        # If no Airflow Home defined - fallback to ${HOME}/airflow
+        AIRFLOW_HOME_DIR=${AIRFLOW_HOME:=${HOME}/airflow}
+        export CASS_DRIVER_NO_CYTHON="1"
+        echo
+        echo "Initializing the virtualenv: $(command -v python)!"
+        echo
+        echo "This will wipe out ${AIRFLOW_HOME_DIR} and reset all the databases!"
+        echo
+        "${MY_DIR}/confirm" "Proceeding with the initialization"
+        echo
+        pushd "${MY_DIR}"
+        set +e
+        pip install -e ".[devel]"
+        RES=$?
+        set -e
+        popd
+        if [[ ${RES} != "0" ]]; then
+            echo "#######################################################################"
+            echo "  You had some troubles installing the venv !!!!!"
+            echo "  Try runnning the command below and rerun virtualenv installation"
+            echo
+            SYSTEM=$(uname -s)
+            if [[ ${SYSTEM} == "Darwin" ]]; then
+                echo "  brew install sqlite mysql postgresql"
+            else
+                echo "  sudo apt install build-essentials python3.6-dev python3.7-dev python-dev openssl sqlite sqlite-dev default-libmysqlclient-dev libmysqld-dev postgresql"
+            fi
+            echo
+            echo "#######################################################################"
+            exit ${RES}
+        fi
+        echo
+        echo "Wiping and recreating ${AIRFLOW_HOME_DIR}"
+        echo
+        rm -rvf "${AIRFLOW_HOME_DIR}"
+        mkdir -p "${AIRFLOW_HOME_DIR}"
+        echo
+        echo "Resetting AIRFLOW sqlite database"
+        echo
+        unset AIRFLOW__CORE__UNIT_TEST_MODE
+        airflow db reset -y
+        echo
+        echo "Resetting AIRFLOW sqlite unit test database"
+        echo
+        export AIRFLOW__CORE__UNIT_TEST_MODE=True
+        airflow db reset -y
+        exit 0
+   fi
+}
 
-# Determine version of the Airflow from version.py
-AIRFLOW_VERSION=$(cat airflow/version.py - << EOF | python
-print(version.replace("+",""))
+function setup_autocomplete() {
+    echo "Installing bash/zsh completion for local user"
+    echo "Note that completion for zsh is just limited to flags - without their values"
+    echo
+    echo
+    set +e
+    grep ".bash_completion.d" "${HOME}/.bashrc" >/dev/null 2>&1
+    RES=$?
+    set -e
+    if [[ "${RES}" == "0" ]]; then
+        echo >&2
+        echo >&2 "ERROR:  Bash completion already setup before."
+        echo >&2
+        exit 1
+    fi
+    "${MY_DIR}/confirm" "This will create ~/.bash_completion.d/ directory and modify ~/.bashrc and ~/.zshrc file"
+    echo
+    echo
+    mkdir -pv ~/.bash_completion.d
+    ln -sf "${MY_DIR}/breeze-complete" "${HOME}/.bash_completion.d/"
+    touch ~/.bashrc
+    cat >>~/.bashrc <<"EOF"
+for BCFILE in ~/.bash_completion.d/* ; do
+    . ${BCFILE}
+done
 EOF
-)
-export AIRFLOW_VERSION
-
-# Verbosity in running ci scripts
-export VERBOSE="false"
-
-# Enter environment by default, rather than run tests or bash command or docker compose or static checks
-export RUN_TESTS="false"
-export RUN_DOCKER_COMPOSE="false"
-export RUN_IN_BASH="false"
-export RUN_STATIC_CHECKS="false"
-export RUN_BUILD_DOCS="false"
-export RUN_BUILD="true"
-
-export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD=${AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD:="false"}
-
-# Files determining whether asciiart/cheatsheet are suppressed
-
-SUPPRESS_CHEATSHEET_FILE="${MY_DIR}/.suppress_cheatsheet"
-SUPPRESS_ASCIIART_FILE="${MY_DIR}/.suppress_asciiart"
+    cat >>~/.zshrc <<"EOF"
+autoload compinit && compinit
+autoload bashcompinit && bashcompinit
+source ~/.bash_completion.d/breeze-complete
+EOF
+    if [[ "${OSTYPE}" == "darwin"* ]]; then
+        #  For MacOS we have to handle the special case where terminal app DOES NOT run .bashrc by default
+        #  But re-runs .bash_profile :(
+        #  See https://scriptingosx.com/2017/04/about-bash_profile-and-bashrc-on-macos/
+        set +e
+        grep ".bashrc" "${HOME}/.bash_profile"
+        RES=$?
+        set -e
+        if [[ "${RES}" == "0" ]]; then
+            echo "  Seems you already source .bashrc in your .bash_profile so not adding it."
+        else
+            "${MY_DIR}/confirm" "This will modify  ~/.bash_profile and source .bashrc from it"
+            echo
+            echo
+            cat >>~/.bash_profile <<"EOF"
+if [ -r ~/.bashrc ]; then
+    source ~/.bashrc
+fi
+EOF
+        fi
+    fi
+    echo
+    echo
+    echo "Breeze bash completion installed to ~/.bash_completion.d/breeze-complete"
+    echo
+    echo
+    echo "Please re-enter bash or run '. ~/.bash_completion.d/breeze-complete'"
+    echo
+    exit 0
+}
 
 function print_badge {
     if [[ ! -f "${SUPPRESS_ASCIIART_FILE}" ]]; then
@@ -202,7 +295,7 @@ function print_badge {
 &&&&&&&&&&&&&  &&     &&&&@   &&&&&&&&&&&@  &&&&&&&&&&&&  @&&&&&&&&&&&   &&&&&&&&&&&
 
 
-                               Branch name:        ${AIRFLOW_CONTAINER_BRANCH_NAME}
+                               Branch name:        ${BRANCH_NAME}
                                Docker image:       ${AIRFLOW_CI_IMAGE}
                                Airflow version:    ${AIRFLOW_VERSION}
                                Python version:     ${PYTHON_VERSION}
@@ -225,7 +318,7 @@ EOF
     else
         cat <<EOF
 
-   Branch name:        ${AIRFLOW_CONTAINER_BRANCH_NAME}
+   Branch name:        ${BRANCH_NAME}
    Docker image:       ${AIRFLOW_CI_IMAGE}
    Airflow version:    ${AIRFLOW_VERSION}
    Python version:     ${PYTHON_VERSION}
@@ -276,11 +369,298 @@ EOF
     chmod u+x "${FILE}"
 }
 
-# Default values
+function prepare_command_files() {
+    MAIN_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/base.yml
+    BACKEND_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/backend-${BACKEND}.yml
+    LOCAL_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/local.yml
+    KUBERNETES_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/runtime-kubernetes.yml
+
+    COMPOSE_FILE=${MAIN_DOCKER_COMPOSE_FILE}:${BACKEND_DOCKER_COMPOSE_FILE}
+
+    if [[ "${SKIP_MOUNTING_LOCAL_SOURCES}" != "true" ]]; then
+        COMPOSE_FILE=${COMPOSE_FILE}:${LOCAL_DOCKER_COMPOSE_FILE}
+    fi
+
+    if [[ ${RUNTIME} == "kubernetes" ]]; then
+        COMPOSE_FILE=${COMPOSE_FILE}:${KUBERNETES_DOCKER_COMPOSE_FILE}
+    fi
+
+    set +u
+    # shellcheck disable=SC2207
+    UNIQUE_INTEGRATIONS=($(echo "${INTEGRATIONS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+
+    for _INT in "${UNIQUE_INTEGRATIONS[@]}"
+    do
+        COMPOSE_FILE=${COMPOSE_FILE}:${SCRIPTS_CI_DIR}/docker-compose/integration-${_INT}.yml
+    done
+    set -u
+
+    export COMPOSE_FILE
+
+    CI_ENTRYPOINT_FILE="/opt/airflow/scripts/ci/in_container/entrypoint_ci.sh"
+
+    # Base python image for the build
+    export PYTHON_BASE_IMAGE=python:${PYTHON_VERSION}-slim-stretch
+    export AIRFLOW_CI_IMAGE="${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${BRANCH_NAME}-python${PYTHON_VERSION}-ci"
+    export BUILT_IMAGE_FLAG_FILE="${BUILD_CACHE_DIR}/${BRANCH_NAME}/.built_${PYTHON_VERSION}"
+
+    DC_RUN_COMMAND="run --service-ports --rm airflow-testing \"${CI_ENTRYPOINT_FILE} "
+
+    LAST_DC_RUN_FILE="cmd_run"
+    LAST_DC_TEST_FILE="test_run"
+    LAST_DC_FILE="dc"
+
+    # Prepare script for "run command"
+    prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}" "${DC_RUN_COMMAND}" "false" '*'
+
+    # Prepare script for "run test"
+    prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE}" "${DC_RUN_COMMAND}" "true" '*'
+
+    # Prepare script for "run docker compose command"
+    prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_FILE}" '"' "false"
+}
+
+function parse_arguments() {
+    if ! PARAMS=$(getopt \
+        -o "${_BREEZE_GETOPT_SHORT_OPTIONS:=}" \
+        -l "${_BREEZE_GETOPT_LONG_OPTIONS:=}" \
+        --name "$CMDNAME" -- "$@")
+    then
+        usage
+        exit 1
+    fi
+
+    eval set -- "${PARAMS}"
+    unset PARAMS
+
+    # Parse Flags.
+    # Please update short and long options in the breeze-complete script
+    # This way autocomplete will work out-of-the-box
+    while true
+    do
+      case "${1}" in
+        -h|--help)
+          usage;
+          exit 0 ;;
+        -P|--python)
+          export PYTHON_VERSION="${2}";
+          echo "Python version: ${PYTHON_VERSION}"
+          echo
+          shift 2 ;;
+        -B|--backend)
+          export BACKEND="${2}";
+          echo "Backend: ${BACKEND}"
+          echo
+          shift 2 ;;
+        -I|--integration)
+          INTEGRATION=${2}
+          check_and_save_allowed_param "INTEGRATION"  "integration" "--integration"
+          echo "Integration: ${INTEGRATION}"
+          if [[ ${INTEGRATION} == "all" ]]; then
+             for _INT in ${_BREEZE_ALLOWED_INTEGRATIONS}
+             do
+                 if [[ ${_INT} != "all" ]];  then
+                     echo "${_INT}"
+                     INTEGRATIONS+=("${_INT}")
+                 fi
+             done
+          else
+              INTEGRATIONS+=("${INTEGRATION}");
+          fi
+          echo
+          shift 2 ;;
+        -K|--start-kind-cluster)
+          export RUNTIME=kubernetes
+          export ENABLE_KIND_CLUSTER="true"
+          export KIND_CLUSTER_OPERATION="start"
+          echo "Starting kubernetes cluster"
+          echo
+          shift ;;
+        -z|--recreate-kind-cluster)
+          export RUNTIME=kubernetes
+          export ENABLE_KIND_CLUSTER="true"
+          export KIND_CLUSTER_OPERATION="recreate"
+          echo "Recreating kind cluster"
+          echo
+          shift ;;
+        -X|--stop-kind-cluster)
+          export RUNTIME=kubernetes
+          export ENABLE_KIND_CLUSTER="true"
+          export KIND_CLUSTER_OPERATION="stop"
+          echo "Stop kind cluster"
+          echo
+          shift ;;
+        -M|--kubernetes-mode)
+          export KUBERNETES_MODE="${2}";
+          echo "Kubernetes mode: ${KUBERNETES_MODE}"
+          echo
+          shift 2 ;;
+        -V|--kubernetes-version)
+          export KUBERNETES_VERSION="${2}";
+          echo "Kubernetes version: ${KUBERNETES_VERSION}"
+          echo
+          shift 2 ;;
+        -s|--skip-mounting-local-sources)
+          SKIP_MOUNTING_LOCAL_SOURCES="true"
+          echo "Skip mounting local sources: ${SKIP_MOUNTING_LOCAL_SOURCES}"
+          echo
+          shift ;;
+        -b|--build-only)
+          COMMAND_TO_RUN="build_ci_images_only"
+          # if you want to build an image - assume you want to build it :)
+          export FORCE_ANSWER_TO_QUESTIONS="yes"
+          # and assume you want to build it no matter if it is needed
+          export FORCE_BUILD_IMAGES="true"
+          echo "Only build. Do not enter airflow-testing container"
+          echo
+          shift ;;
+        -v|--verbose)
+          VERBOSE="true"
+          echo "Verbose output"
+          echo
+          shift ;;
+        -y|--assume-yes)
+          export FORCE_ANSWER_TO_QUESTIONS="yes"
+          echo "Assuming 'yes' answer to all questions."
+          echo
+          shift ;;
+        -n|--assume-no)
+          export FORCE_ANSWER_TO_QUESTIONS="no"
+          echo "Assuming 'no' answer to all questions."
+          echo
+          shift ;;
+        -q|--assume-quit)
+          export FORCE_ANSWER_TO_QUESTIONS="quit"
+          echo "Assuming 'quit' answer to all questions."
+          echo
+          shift ;;
+        -C|--toggle-suppress-cheatsheet)
+          if [[ -f "${SUPPRESS_CHEATSHEET_FILE}" ]]; then
+            rm -f "${SUPPRESS_CHEATSHEET_FILE}"
+          else
+            touch "${SUPPRESS_CHEATSHEET_FILE}"
+          fi
+          echo "Toggle suppress cheatsheet"
+          echo
+          shift ;;
+        -A|--toggle-suppress-asciiart)
+          if [[ -f "${SUPPRESS_ASCIIART_FILE}" ]]; then
+            rm -f "${SUPPRESS_ASCIIART_FILE}"
+          else
+            touch "${SUPPRESS_ASCIIART_FILE}"
+          fi
+          echo "Toggle suppress asciiart"
+          echo
+          shift ;;
+        -r|--force-build-images)
+          echo "Force build images"
+          echo
+          export FORCE_BUILD_IMAGES="true"
+          # if you want to force  build an image - assume you want to build it :)
+          export FORCE_ANSWER_TO_QUESTIONS="yes"
+          shift ;;
+        -R|--force-clean-images)
+          echo "Clean build of images without cache"
+          echo
+          export USE_PULLED_IMAGES_AS_CACHE="false"
+          export FORCE_BUILD_IMAGES="true"
+          shift ;;
+        -L|--use-local-cache)
+          echo "Use local cache to build images"
+          echo
+          export USE_NO_CACHE="false"
+          export USE_PULLED_IMAGES_AS_CACHE="false"
+          shift ;;
+        -p|--force-pull-images)
+          echo "Force pulling images before build. Uses pulled images as cache."
+          echo
+          export FORCE_PULL_IMAGES="true"
+          export FORCE_BUILD_IMAGES="true"
+          # if you want to force  build an image - assume you want to build it :)
+          export FORCE_ANSWER_TO_QUESTIONS="yes"
+          shift ;;
+        -D|--dockerhub-user)
+          export DOCKERHUB_USER="${2}"
+          echo "Dockerhub user ${DOCKERHUB_USER}"
+          echo
+          shift 2 ;;
+        -H|--dockerhub-repo)
+          export DOCKERHUB_REPO="${2}"
+          echo "Dockerhub repo ${DOCKERHUB_REPO}"
+          echo
+          shift 2 ;;
+        -u|--push-images)
+          echo
+          echo "Pushing images to DockerHub"
+          echo
+          export PUSH_IMAGES="true"
+          export FORCE_BUILD_IMAGES="true"
+          shift ;;
+        -c|--cleanup-image)
+          echo "Cleanup the image"
+          echo
+          COMMAND_TO_RUN="cleanup_image"
+          shift ;;
+        -e|--initialize-local-virtualenv)
+          echo "Initializing local virtualenv"
+          echo
+          COMMAND_TO_RUN="perform_initialize_local_virtualenv"
+          shift ;;
+        -a|--setup-autocomplete)
+          echo "Setting up autocomplete"
+          echo
+          COMMAND_TO_RUN="perform_setup_autocomplete"
+          shift ;;
+        -t|--test-target)
+          if [[ "${TEST_TARGET}" == "." ]]; then
+              export TEST_TARGET=""
+          fi
+          COMMAND_TO_RUN="run_tests"
+          shift 2 ;;
+        -d|--docker-compose)
+          DOCKER_COMPOSE_COMMAND="${2}"
+          COMMAND_TO_RUN="run_docker_compose"
+          shift 2 ;;
+        -k|--stop-environment)
+          COMMAND_TO_RUN="run_docker_compose"
+          DOCKER_COMPOSE_COMMAND="down"
+          export EXTRA_DC_OPTIONS+=("--remove-orphans")
+          shift ;;
+        -x|--execute-command)
+          COMMAND_TO_RUN="run_in_bash"
+          shift 2 ;;
+        -S|--static-check )
+          COMMAND_TO_RUN="perform_static_checks"
+          export PYTHON_VERSION=${STATIC_CHECK_PYTHON_VERSION}
+          export STATIC_CHECK="${2}"
+          export STATIC_CHECK_ALL_FILES="false"
+          export EXTRA_STATIC_CHECK_OPTIONS=("--show-diff-on-failure")
+          shift 2 ;;
+        -F|--static-check-all-files)
+          COMMAND_TO_RUN="perform_static_checks"
+          export PYTHON_VERSION=${STATIC_CHECK_PYTHON_VERSION}
+          export STATIC_CHECK="${2}"
+          export STATIC_CHECK_ALL_FILES="true"
+          export EXTRA_STATIC_CHECK_OPTIONS=("--all-files" "--show-diff-on-failure")
+          shift 2 ;;
+        -O|--build-docs)
+          COMMAND_TO_RUN="build_docs"
+          shift 1 ;;
+        --)
+          shift ;
+          break ;;
+        *)
+          usage
+          echo >&2
+          echo >&2 "ERROR: Unknown argument ${1}"
+          echo >&2
+          exit 1
+          ;;
+      esac
+    done
+    REMAINING_ARGS+=("$@")
+}
 
-_BREEZE_DEFAULT_BACKEND="sqlite"
-_BREEZE_DEFAULT_KUBERNETES_MODE="git_mode"
-_BREEZE_DEFAULT_KUBERNETES_VERSION="v1.15.3"
 usage() {
       echo """
 
@@ -551,654 +931,293 @@ The swiss-knife-army tool for Airflow testings. It allows to perform various tes
 """
 }
 
-####################  Parsing options/arguments
-if ! PARAMS=$(getopt \
-    -o "${_BREEZE_GETOPT_SHORT_OPTIONS:=}" \
-    -l "${_BREEZE_GETOPT_LONG_OPTIONS:=}" \
-    --name "$CMDNAME" -- "$@")
-then
-    usage
-    exit 1
-fi
-
-eval set -- "${PARAMS}"
-unset PARAMS
-
-INTEGRATIONS=()
-
-# Parse Flags.
-# Please update short and long options in the breeze-complete script
-# This way autocomplete will work out-of-the-box
-while true
-do
-  case "${1}" in
-    -h|--help)
-      usage;
-      exit 0 ;;
-    -P|--python)
-      export PYTHON_VERSION="${2}";
-      echo "Python version: ${PYTHON_VERSION}"
-      echo
-      shift 2 ;;
-    -B|--backend)
-      export BACKEND="${2}";
-      echo "Backend: ${BACKEND}"
-      echo
-      shift 2 ;;
-    -I|--integration)
-      INTEGRATION=${2}
-      check_for_allowed_params "INTEGRATION"  "integration" "--integration"
-      echo "Integration: ${INTEGRATION}"
-      if [[ ${INTEGRATION} == "all" ]]; then
-         for _INT in ${_BREEZE_ALLOWED_INTEGRATIONS}
-         do
-             if [[ ${_INT} != "all" ]];  then
-                 echo "${_INT}"
-                 INTEGRATIONS+=("${_INT}")
-             fi
-         done
-      else
-          INTEGRATIONS+=("${INTEGRATION}");
-      fi
-      echo
-      shift 2 ;;
-    -K|--start-kind-cluster)
-      export RUNTIME=kubernetes
-      export ENABLE_KIND_CLUSTER="true"
-      export KIND_CLUSTER_OPERATION="start"
-      echo "Starting kubernetes cluster"
-      echo
-      shift ;;
-    -z|--recreate-kind-cluster)
-      export RUNTIME=kubernetes
-      export ENABLE_KIND_CLUSTER="true"
-      export KIND_CLUSTER_OPERATION="recreate"
-      echo "Recreating kind cluster"
-      echo
-      shift ;;
-    -X|--stop-kind-cluster)
-      export RUNTIME=kubernetes
-      export ENABLE_KIND_CLUSTER="true"
-      export KIND_CLUSTER_OPERATION="stop"
-      echo "Stop kind cluster"
-      echo
-      shift ;;
-    -M|--kubernetes-mode)
-      export KUBERNETES_MODE="${2}";
-      echo "Kubernetes mode: ${KUBERNETES_MODE}"
-      echo
-      shift 2 ;;
-    -V|--kubernetes-version)
-      export KUBERNETES_VERSION="${2}";
-      echo "Kubernetes version: ${KUBERNETES_VERSION}"
-      echo
-      shift 2 ;;
-    -s|--skip-mounting-local-sources)
-      SKIP_MOUNTING_LOCAL_SOURCES="true"
-      echo "Skip mounting local sources: ${SKIP_MOUNTING_LOCAL_SOURCES}"
-      echo
-      shift ;;
-    -b|--build-only)
-      ENTER_ENVIRONMENT="false"
-      # if you want to build an image - assume you want to build it :)
-      export FORCE_ANSWER_TO_QUESTIONS="yes"
-      # and assume you want to build it no matter if it is needed
-      export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-      echo "Only build. Do not enter airflow-testing container"
-      echo
-      shift ;;
-    -v|--verbose)
-      VERBOSE="true"
-      echo "Verbose output"
-      echo
-      shift ;;
-    -y|--assume-yes)
-      export FORCE_ANSWER_TO_QUESTIONS="yes"
-      echo "Assuming 'yes' answer to all questions."
-      echo
-      shift ;;
-    -n|--assume-no)
-      export FORCE_ANSWER_TO_QUESTIONS="no"
-      echo "Assuming 'no' answer to all questions."
-      echo
-      shift ;;
-    -C|--toggle-suppress-cheatsheet)
-      if [[ -f "${SUPPRESS_CHEATSHEET_FILE}" ]]; then
-        rm -f "${SUPPRESS_CHEATSHEET_FILE}"
-      else
-        touch "${SUPPRESS_CHEATSHEET_FILE}"
-      fi
-      echo "Toggle suppress cheatsheet"
-      echo
-      shift ;;
-    -A|--toggle-suppress-asciiart)
-      if [[ -f "${SUPPRESS_ASCIIART_FILE}" ]]; then
-        rm -f "${SUPPRESS_ASCIIART_FILE}"
-      else
-        touch "${SUPPRESS_ASCIIART_FILE}"
-      fi
-      echo "Toggle suppress asciiart"
-      echo
-      shift ;;
-    -r|--force-build-images)
-      echo "Force build images"
-      echo
-      export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-      # if you want to force  build an image - assume you want to build it :)
-      export FORCE_ANSWER_TO_QUESTIONS="yes"
-      shift ;;
-    -R|--force-clean-images)
-      echo "Clean build of images without cache"
-      echo
-      export AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE="false"
-      export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-      CLEANUP_IMAGES="true"
-      shift ;;
-    -L|--use-local-cache)
-      echo "Use local cache to build images"
-      echo
-      export AIRFLOW_CONTAINER_USE_NO_CACHE="false"
-      export AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE="false"
-      shift ;;
-    -p|--force-pull-images)
-      echo "Force pulling images before build. Uses pulled images as cache."
-      echo
-      export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES="true"
-      export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-      shift ;;
-    -u|--push-images)
-      echo
-      echo "Pushing images to DockerHub"
-      echo
-      export AIRFLOW_CONTAINER_PUSH_IMAGES="true"
-      export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-      shift ;;
-    -c|--cleanup-images)
-      echo "Cleanup the images"
-      echo
-      export CLEANUP_IMAGES=true
-      export RUN_BUILD="false"
-      shift ;;
-    -D|--dockerhub-user)
-      export DOCKERHUB_USER="${2}"
-      echo "Dockerhub user ${DOCKERHUB_USER}"
-      echo
-      shift 2 ;;
-    -H|--dockerhub-repo)
-      export DOCKERHUB_REPO="${2}"
-      echo "Dockerhub repo ${DOCKERHUB_REPO}"
-      echo
-      shift 2 ;;
-    -e|--initialize-local-virtualenv)
-      echo "Initializing local virtualenv"
-      echo
-      INITIALIZE_LOCAL_VIRTUALENV="true"
-      SETUP_AUTOCOMPLETE="false"
-      ENTER_ENVIRONMENT=:"false"
-      export RUN_BUILD="false"
-      shift ;;
-    -a|--setup-autocomplete)
-      echo "Setting up autocomplete"
-      echo
-      INITIALIZE_LOCAL_VIRTUALENV="false"
-      SETUP_AUTOCOMPLETE="true"
-      ENTER_ENVIRONMENT=:"false"
-      export RUN_BUILD="false"
-      shift ;;
-    -t|--test-target)
-      export TEST_TARGET="${2}"
-      export RUN_IN_BASH="false"
-      export RUN_TESTS="true"
-      export RUN_DOCKER_COMPOSE="false"
-      export RUN_STATIC_CHECKS="false"
-      export RUN_BUILD_DOCS="false"
-      shift 2 ;;
-    -d|--docker-compose)
-      export DOCKER_COMPOSE_COMMAND="${2}"
-      export RUN_IN_BASH="false"
-      export RUN_TESTS="false"
-      export RUN_DOCKER_COMPOSE="true"
-      export RUN_STATIC_CHECKS="false"
-      export RUN_BUILD_DOCS="false"
-      shift 2 ;;
-    -k|--stop-environment)
-      export DOCKER_COMPOSE_COMMAND="down"
-      export RUN_IN_BASH="false"
-      export RUN_TESTS="false"
-      export RUN_BUILD_DOCS="false"
-      export RUN_DOCKER_COMPOSE="true"
-      export RUN_STATIC_CHECKS="false"
-      export RUN_BUILD="false"
-      EXTRA_DC_OPTIONS+=("--remove-orphans")
-      shift ;;
-    -x|--execute-command)
-      export RUN_COMMAND="${2}"
-      export RUN_IN_BASH="true"
-      export RUN_TESTS="false"
-      export RUN_BUILD_DOCS="false"
-      export RUN_DOCKER_COMPOSE="false"
-      export RUN_STATIC_CHECKS="false"
-      shift 2 ;;
-    -S|--static-check )
-      export ENTER_ENVIRONMENT="false"
-      export RUN_TESTS="false"
-      export RUN_DOCKER_COMPOSE="false"
-      export RUN_STATIC_CHECKS="true"
-      export RUN_BUILD_DOCS="false"
-      export STATIC_CHECK="${2}"
-      export EXTRA_STATIC_CHECK_OPTIONS=("--show-diff-on-failure")
-      export STATIC_CHECK_ALL_FILES="false"
-      shift 2 ;;
-    -F|--static-check-all-files)
-      export ENTER_ENVIRONMENT="false"
-      export RUN_TESTS="false"
-      export RUN_DOCKER_COMPOSE="false"
-      export RUN_STATIC_CHECKS="true"
-      export RUN_BUILD_DOCS="false"
-      export STATIC_CHECK="${2}"
-      export STATIC_CHECK_ALL_FILES="true"
-      export EXTRA_STATIC_CHECK_OPTIONS=("--all-files" "--show-diff-on-failure")
-      shift 2 ;;
-    -O|--build-docs)
-      export ENTER_ENVIRONMENT="false"
-      export RUN_TESTS="false"
-      export RUN_DOCKER_COMPOSE="false"
-      export RUN_STATIC_CHECKS="false"
-      export RUN_BUILD_DOCS="true"
-      shift 1 ;;
-    --)
-      shift ;
-      break ;;
-    *)
-      usage
-      echo >&2
-      echo >&2 "ERROR: Unknown argument ${1}"
-      echo >&2
-      exit 1
-      ;;
-  esac
-done
+function print_header_line() {
+    echo
+    printf '=%.0s' $(seq "${SEPARATOR_WIDTH}")
+    echo
+}
 
-echo
-printf '=%.0s' $(seq "${SEPARATOR_WIDTH}")
-echo
 
-CMDNAME="$(basename -- "$0")"
+function print_line {
+    printf '#%.0s' $(seq "${SEPARATOR_WIDTH}")
+}
 
-# Cleans up the answer that was given last time, whether to force/
-forget_last_answer
+function read_saved_environment_variables {
+    export BACKEND="${BACKEND:=$(read_from_file BACKEND)}"
+    export BACKEND=${BACKEND:-${_BREEZE_DEFAULT_BACKEND}}
 
-export BACKEND="${BACKEND:=$(read_from_file BACKEND)}"
-export BACKEND=${BACKEND:-${_BREEZE_DEFAULT_BACKEND}}
+    export KUBERNETES_MODE="${KUBERNETES_MODE:=$(read_from_file KUBERNETES_MODE)}"
+    export KUBERNETES_MODE=${KUBERNETES_MODE:=${_BREEZE_DEFAULT_KUBERNETES_MODE}}
 
-export KUBERNETES_MODE="${KUBERNETES_MODE:=$(read_from_file KUBERNETES_MODE)}"
-export KUBERNETES_MODE=${KUBERNETES_MODE:=${_BREEZE_DEFAULT_KUBERNETES_MODE}}
+    export KUBERNETES_VERSION="${KUBERNETES_VERSION:=$(read_from_file KUBERNETES_VERSION)}"
+    export KUBERNETES_VERSION=${KUBERNETES_VERSION:=${_BREEZE_DEFAULT_KUBERNETES_VERSION}}
 
-export KUBERNETES_VERSION="${KUBERNETES_VERSION:=$(read_from_file KUBERNETES_VERSION)}"
-export KUBERNETES_VERSION=${KUBERNETES_VERSION:=${_BREEZE_DEFAULT_KUBERNETES_VERSION}}
+    # Here you read DockerHub user/account that you use
+    # You can populate your own images in DockerHub this way and work with the,
+    # You can override it with "-d" option and it will be stored in .build directory
+    export DOCKERHUB_USER="${DOCKERHUB_USER:=$(read_from_file DOCKERHUB_USER)}"
+    export DOCKERHUB_USER="${DOCKERHUB_USER:=${_BREEZE_DEFAULT_DOCKERHUB_USER}}"
 
-# Here you read DockerHub user/account that you use
-# You can populate your own images in DockerHub this way and work with the,
-# You can override it with "-d" option and it will be stored in .build directory
-export DOCKERHUB_USER="${DOCKERHUB_USER:=$(read_from_file DOCKERHUB_USER)}"
-export DOCKERHUB_USER="${DOCKERHUB_USER:=${_BREEZE_DEFAULT_DOCKERHUB_USER}}"
+    # Here you read DockerHub repo that you use
+    # You can populate your own images in DockerHub this way and work with them
+    # You can override it with "-d" option and it will be stored in .build directory
+    export DOCKERHUB_REPO="${DOCKERHUB_REPO:=$(read_from_file DOCKERHUB_REPO)}"
+    export DOCKERHUB_REPO="${DOCKERHUB_REPO:=${_BREEZE_DEFAULT_DOCKERHUB_REPO}}"
+}
 
-# Here you read DockerHub repo that you use
-# You can populate your own images in DockerHub this way and work with them
-# You can override it with "-d" option and it will be stored in .build directory
-export DOCKERHUB_REPO="${DOCKERHUB_REPO:=$(read_from_file DOCKERHUB_REPO)}"
-export DOCKERHUB_REPO="${DOCKERHUB_REPO:=${_BREEZE_DEFAULT_DOCKERHUB_REPO}}"
+function check_and_save_all_params() {
+    check_and_save_allowed_param "PYTHON_VERSION"  "Python version" "--python"
+    check_and_save_allowed_param "BACKEND"  "backend" "--backend"
+    check_and_save_allowed_param "KUBERNETES_MODE"  "Kubernetes mode" "--kubernetes-mode"
+    check_and_save_allowed_param "KUBERNETES_VERSION"  "Kubernetes version" "--kubernetes-version"
 
+    # Can't verify those
+    save_to_file DOCKERHUB_USER
+    save_to_file DOCKERHUB_REPO
+}
 
-check_for_allowed_params "PYTHON_VERSION"  "Python version" "--python"
-check_for_allowed_params "BACKEND"  "backend" "--backend"
-check_for_allowed_params "KUBERNETES_MODE"  "Kubernetes mode" "--kubernetes-mode"
-check_for_allowed_params "KUBERNETES_VERSION"  "Kubernetes version" "--kubernetes-version"
+function fix_local_file {
+    if [[ -d "${MY_DIR}/${1}" ]]; then
+        rm -rf "${MY_DIR:?}/${1}"
+    fi
+    touch "${MY_DIR}/${1}"
 
-save_to_file DOCKERHUB_USER
-save_to_file DOCKERHUB_REPO
+}
 
-# Those files are mounted into container when run locally
-# .bash_history is preserved and you can modify .bash_aliases and .inputrc
-# according to your liking
-if [[ -d "${MY_DIR}/.bash_history" ]]; then
-    rm -rf "${MY_DIR}/.bash_history"
-fi
-touch "${MY_DIR}/.bash_history"
-touch "${MY_DIR}/.bash_aliases"
-touch "${MY_DIR}/.inputrc"
-mkdir -pv "${MY_DIR}/.kube"
-
-#################### Cleanup image if requested ########################################
-if [[ "${CLEANUP_IMAGES}" == "true" ]]; then
-    export AIRFLOW_CONTAINER_CLEANUP_IMAGES=true
-    "${MY_DIR}/scripts/ci/ci_cleanup.sh"
-    exit 0
-fi
+function touch_local_files {
+    # Those files are mounted into container when run locally
+    # .bash_history is preserved and you can modify .bash_aliases and .inputrc
+    # according to your liking
+    fix_local_file ".bash_history"
+    fix_local_file ".bash_aliases"
+    fix_local_file ".inputrc"
+    # When kind cluster is created, the folder keeps authentication information
+    # across sessiosn
+    mkdir -pv "${MY_DIR}/.kube"
+}
 
-#################### Initializes local virtualenv ########################################
-if [[ ${INITIALIZE_LOCAL_VIRTUALENV} == "true" ]]; then
-   # Check if we are in virtualenv
-   set +e
-   echo -e "import sys\nif not hasattr(sys,'base_prefix'):\n  sys.exit(1)" | "python${PYTHON_VERSION}"
-   RES=$?
-   set -e
-   if [[ ${RES} != "0" ]]; then
-        echo >&2
-        echo >&2 "ERROR:  Initializing local virtualenv only works when you have virtualenv activated"
-        echo >&2
-        echo >&2 "Please enter your local virtualenv before (for example using 'workon') "
-        echo >&2
-        exit 1
-   else
-        # If no Airflow Home defined - fallback to ${HOME}/airflow
-        AIRFLOW_HOME_DIR=${AIRFLOW_HOME:=${HOME}/airflow}
+function print_cheatsheet() {
+    if [[ ! -f ${SUPPRESS_CHEATSHEET_FILE} ]]; then
         echo
-        echo "Initializing the virtualenv: $(command -v python)!"
         echo
-        echo "This will wipe out ${AIRFLOW_HOME_DIR} and reset all the databases!"
+        print_line
         echo
-        "${MY_DIR}/confirm" "Proceeding with the initialization"
+        echo "                                  Airflow Breeze CHEATSHEET"
         echo
-        pushd "${MY_DIR}"
-        SYSTEM=$(uname -s)
-        echo "#######################################################################"
-        echo "  If you have trouble installing all dependencies you might need to run:"
+        print_line
         echo
-        if [[ ${SYSTEM} == "Darwin" ]]; then
-            echo "  brew install sqlite mysql postgresql"
-        else
-            echo "  sudo apt-get install python3-dev python-dev openssl sqlite default-libmysqlclient-dev libmysqld-dev postgresql --confirm"
-        fi
         echo
-        echo "#######################################################################"
-        pip install -e ".[devel]"
-        popd
+        print_line
         echo
-        echo "Wiping and recreating ${AIRFLOW_HOME_DIR}"
+        echo " Quick scripts:"
+        echo "    * Enter the environm               : ${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}"
+        echo "    * Run command in the environment   : ${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE} "\
+                                                         "[command with args] [bash options]"
+        echo "    * Run tests in the environment     : ${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE} "\
+                                                         "[test target] [nosetest options]"
+        echo "    * Run Docker compose command       : ${BUILD_CACHE_DIR}/${LAST_DC_FILE} "\
+                                                         "[docker compose command] [docker-compose options]"
         echo
-        rm -rvf "${AIRFLOW_HOME_DIR}"
-        mkdir -p "${AIRFLOW_HOME_DIR}"
+
+        set +e
+        if ! command -v breeze; then
+            print_line
+            echo
+            echo " Adding breeze to your path:"
+            echo "    When you exit the environment, you can add sources of airflow to the path - you can"
+            echo "    run breeze or the scripts above from any directory by calling 'breeze' commands directly"
+            echo
+            echo "     export PATH=\${PATH}:\"${MY_DIR}\""
+            echo
+        fi
+        set -e
+        print_line
+
         echo
-        echo "Resetting AIRFLOW sqlite database"
+        echo " Port forwarding:"
         echo
-        unset AIRFLOW__CORE__UNIT_TEST_MODE
-        airflow db reset -y
+        echo "   Ports are forwarded to the running docker containers for webserver and database"
+        echo "     * ${WEBSERVER_HOST_PORT} -> forwarded to airflow webserver -> airflow-testing:8080"
+        echo "     * ${POSTGRES_HOST_PORT} -> forwarded to postgres database -> postgres:5432"
+        echo "     * ${MYSQL_HOST_PORT} -> forwarded to mysql database  -> mysql:3306"
         echo
-        echo "Resetting AIRFLOW sqlite unit test database"
+        echo "   Here are links to those services that you can use on host:"
+        echo "     * Webserver: http://127.0.0.1:28080"
+        echo "     * Postgres:  jdbc:postgresql://127.0.0.1:25433/airflow?user=postgres&password=airflow"
+        echo "     * Mysql:     jdbc:mysql://localhost:23306/airflow?user=root"
         echo
-        export AIRFLOW__CORE__UNIT_TEST_MODE=True
-        airflow db reset -y
-        exit 0
-   fi
-fi
-
+    else
+        echo
+    fi
+}
 
-#################### Sets up autocomplete for breeze commands ########################################
-if [[ ${SETUP_AUTOCOMPLETE} == "true" ]]; then
-    echo
-    echo "Installing bash/zsh completion for local user"
-    echo "Note that completion for zsh is just limited to flags - without their values"
-    echo
-    set +e
-    grep ".bash_completion.d" "${HOME}/.bashrc" >/dev/null 2>&1
-    RES=$?
-    set -e
-    if [[ "${RES}" == "0" ]]; then
-        echo >&2
-        echo >&2 "ERROR:  Bash completion already setup before."
-        echo >&2
-        exit 1
+function print_setup_instructions {
+    # shellcheck disable=SC2034  # Unused variables left for comp_breeze usage
+    if ! typeset -f "_comp_breeze" > /dev/null; then
+        print_line
+        echo
+        echo "  You can setup autocomplete by running '$0 --setup-autocomplete'"
+        echo
+        echo
     fi
-    "${MY_DIR}/confirm" "This will create ~/.bash_completion.d/ directory and modify ~/.bashrc and ~/.zshrc file"
+    print_line
     echo
+    echo "  You can toggle ascii/cheatsheet by adding this flag:"
+    echo "      * --toggle-suppress-cheatsheet"
+    echo "      * --toggle-suppress-asciiart"
     echo
-    mkdir -pv ~/.bash_completion.d
-    ln -sf "${MY_DIR}/breeze-complete" "${HOME}/.bash_completion.d/"
-    touch ~/.bashrc
-    cat >>~/.bashrc <<"EOF"
-for BCFILE in ~/.bash_completion.d/* ; do
-    . ${BCFILE}
-done
-EOF
-    cat >>~/.zshrc <<"EOF"
-autoload compinit && compinit
-autoload bashcompinit && bashcompinit
-source ~/.bash_completion.d/breeze-complete
-EOF
-    if [[ "${OSTYPE}" == "darwin"* ]]; then
-        #  For MacOS we have to handle the special case where terminal app DOES NOT run .bashrc by default
-        #  But re-runs .bash_profile :(
-        #  See https://scriptingosx.com/2017/04/about-bash_profile-and-bashrc-on-macos/
-        set +e
-        grep ".bashrc" "${HOME}/.bash_profile"
-        RES=$?
-        set -e
-        if [[ "${RES}" == "0" ]]; then
-            echo "  Seems you already source .bashrc in your .bash_profile so not adding it."
-        else
-            "${MY_DIR}/confirm" "This will modify  ~/.bash_profile and source .bashrc from it"
-            echo
-            echo
-            cat >>~/.bash_profile <<"EOF"
-if [ -r ~/.bashrc ]; then
-    source ~/.bashrc
-fi
-EOF
-        fi
-    fi
+    print_line
     echo
     echo
-    echo "Breeze bash completion installed to ~/.bash_completion.d/breeze-complete"
     echo
     echo
-    echo "Please re-enter bash or run '. ~/.bash_completion.d/breeze-complete'"
+}
+
+function make_sure_precommit_is_installed {
     echo
-    exit 0
-fi
+    echo "Making sure pre-commit is installed"
+    echo
+    if command -v pip3 >/dev/null; then
+      PIP_BIN=pip3
+    elif command -v pip >/dev/null; then
+      PIP_BIN=pip
+    else
+      echo >&2
+      echo >&2 "ERROR: You need to have pip or pip3 in your PATH"
+      echo >&2
+      S
+      exit 1
+    fi
+    "${PIP_BIN}" install --upgrade pre-commit >/dev/null 2>&1
+    # Add ~/.local/bin to the path in case pip is run outside of virtualenv
+    export PATH="${PATH}":~/.local/bin
+}
 
-MAIN_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/base.yml
-BACKEND_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/backend-${BACKEND}.yml
-LOCAL_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/local.yml
-KUBERNETES_DOCKER_COMPOSE_FILE=${SCRIPTS_CI_DIR}/docker-compose/runtime-kubernetes.yml
+function remove_image {
+    docker rmi "${PYTHON_BASE_IMAGE}" || true
+    docker rmi "${AIRFLOW_CI_IMAGE}" || true
+    rm -f "${BUILT_IMAGE_FLAG_FILE}"
+}
 
-COMPOSE_FILE=${MAIN_DOCKER_COMPOSE_FILE}:${BACKEND_DOCKER_COMPOSE_FILE}
+function run_static_checks {
+    if [[ ${STATIC_CHECK} == "all" ]]; then
+        echo
+        echo "Running: pre-commit run" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+        echo
+        pre-commit run "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+    elif [[ ${STATIC_CHECK} == "all-but-pylint" ]]; then
+        echo
+        echo "Setting SKIP=pylint. Running: pre-commit run" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+        echo
+        echo
+        SKIP=pylint pre-commit run "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+    else
+        echo
+        echo "Running: pre-commit run" "${STATIC_CHECK}" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+        echo
+        pre-commit run "${STATIC_CHECK}" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
+    fi
+}
 
-if [[ "${SKIP_MOUNTING_LOCAL_SOURCES}" != "true" ]]; then
-    COMPOSE_FILE=${COMPOSE_FILE}:${LOCAL_DOCKER_COMPOSE_FILE}
-fi
+function run_build_command {
+    case "${COMMAND_TO_RUN}" in
+        enter_breeze|build_docs|run_tests|run_docker_compose|run_in_bash)
+            rebuild_ci_image_if_needed
+            ;;
+        perform_static_checks|build_ci_images_only)
+            rebuild_ci_image_if_needed
+            ;;
+        cleanup_image)
+            ;;
+        perform_initialize_local_virtualenv|perform_setup_autocomplete)
+            ;;
+        *)
+          echo >&2
+          echo >&2 "ERROR: Unknown command to run ${COMMAND_TO_RUN}"
+          echo >&2
+          ;;
+    esac
+}
 
-if [[ ${RUNTIME} == "kubernetes" ]]; then
-    COMPOSE_FILE=${COMPOSE_FILE}:${KUBERNETES_DOCKER_COMPOSE_FILE}
-fi
+function run_breeze_command {
+    set -u
+    case "${COMMAND_TO_RUN}" in
+        enter_breeze)
+            "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}"
+            ;;
+        run_tests)
+            "${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE}" "\"${TEST_TARGET}\"" "$@"
+            ;;
+        run_docker_compose)
+            set +u
+            "${BUILD_CACHE_DIR}/${LAST_DC_FILE}" "${DOCKER_COMPOSE_COMMAND}" "${EXTRA_DC_OPTIONS[@]}" "$@"
+            set -u
+            ;;
+        run_in_bash)
+            "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}" "${RUN_COMMAND}" "$@"
+            ;;
+        perform_static_checks)
+            make_sure_precommit_is_installed
+            run_static_checks "$@"
+            ;;
+        build_ci_images_only)
+            if [[ ${PUSH_IMAGES} == "true" ]]; then
+                push_ci_image
+            fi
+            ;;
+        cleanup_image)
+            remove_image
+            ;;
+        perform_initialize_local_virtualenv)
+            initialize_virtualenv
+            ;;
+        perform_setup_autocomplete)
+            setup_autocomplete
+            ;;
+        build_docs)
+            run_docs
+            ;;
+        *)
+          echo >&2
+          echo >&2 "ERROR: Unknown command to run ${COMMAND_TO_RUN}"
+          echo >&2
+          ;;
+    esac
+}
 
-set +u
-# shellcheck disable=SC2207
-UNIQUE_INTEGRATIONS=($(echo "${INTEGRATIONS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
+setup_default_breeze_variables
 
-for _INT in "${UNIQUE_INTEGRATIONS[@]}"
-do
-    COMPOSE_FILE=${COMPOSE_FILE}:${SCRIPTS_CI_DIR}/docker-compose/integration-${_INT}.yml
-done
-set -u
+initialize_breeze_environment
 
-export COMPOSE_FILE
+basic_sanity_checks
 
-CI_ENTRYPOINT_FILE="/opt/airflow/scripts/ci/in_container/entrypoint_ci.sh"
+script_start
 
-export AIRFLOW_CI_IMAGE="${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${DEFAULT_BRANCH}-python${PYTHON_VERSION}-ci"
+trap script_end EXIT
 
-DC_RUN_COMMAND="run --service-ports --rm airflow-testing \"${CI_ENTRYPOINT_FILE} "
-DC_RUN_COMMAND_NO_DEPS="run --no-deps --service-ports --rm airflow-testing \"${CI_ENTRYPOINT_FILE} "
+parse_arguments "${@}"
 
-LAST_DC_RUN_FILE="cmd_run"
-LAST_DC_RUN_NO_DEPS_FILE="cmd_only_at_run"
-LAST_DC_TEST_FILE="test_run"
-LAST_DC_FILE="dc"
+print_header_line
 
-# Prepare script for "run command"
-prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}" "${DC_RUN_COMMAND}" "false" '*'
+forget_last_answer
 
-# Prepare script for "run command without dependencies"
-prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_RUN_NO_DEPS_FILE}" "${DC_RUN_COMMAND_NO_DEPS}" "false" '*'
+read_saved_environment_variables
 
-# Prepare script for "run test"
-prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE}" "${DC_RUN_COMMAND}" "true" '*'
+check_and_save_all_params
 
-# Prepare script for "run docker compose command"
-prepare_command_file "${BUILD_CACHE_DIR}/${LAST_DC_FILE}" '"' "false"
+touch_local_files
 
-if [[ ${RUN_BUILD} == "true" ]] ; then
-    echo
-    echo "Build image if needed"
-    echo
-    rebuild_ci_image_if_needed
-    echo
-    echo
-fi
-export AIRFLOW_CI_IMAGE=\
-${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CONTAINER_BRANCH_NAME}-python${PYTHON_VERSION}-ci
+prepare_command_files
 
-printf '=%.0s' $(seq "${SEPARATOR_WIDTH}")
+run_build_command
 
-if [[ "${TEST_TARGET}" == "." ]]; then
-    TEST_TARGET="tests/"
-fi
+print_header_line
 
 print_badge
 
-function print_line {
-    printf '#%.0s' $(seq "${SEPARATOR_WIDTH}")
-}
-
-if [[ ! -f ${SUPPRESS_CHEATSHEET_FILE} ]]; then
-    echo
-    echo
-    print_line
-    echo
-    echo "                                  Airflow Breeze CHEATSHEET"
-    echo
-    print_line
-    echo
-    echo
-    print_line
-    echo
-    echo " Quick scripts:"
-    echo "    * Enter the full environment        : ${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}"
-    echo "    * Run command in full environment   : ${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE} "\
-                                                     "[command with args] [bash options]"
-    echo "    * Run command without dependent images  : ${BUILD_CACHE_DIR}/${LAST_DC_RUN_NO_DEPS_FILE} "\
-                                                     "[command with args] [bash options]"
-    echo "    * Run tests in the full environment : ${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE} "\
-                                                     "[test target] [nosetest options]"
-    echo "    * Run Docker compose command        : ${BUILD_CACHE_DIR}/${LAST_DC_FILE} "\
-                                                     "[docker compose command] [docker-compose options]"
-    echo
-
-    set +e
-    if ! command -v breeze; then
-        print_line
-        echo
-        echo " Adding breeze to your path:"
-        echo "    When you exit the environment, you can add sources of airflow to the path - you can"
-        echo "    run breeze or the scripts above from any directory by calling 'breeze' commands directly"
-        echo
-        echo "     export PATH=\${PATH}:\"${MY_DIR}\""
-        echo
-    fi
-    set -e
-    print_line
+print_cheatsheet
 
-    echo
-    echo " Port forwarding:"
-    echo
-    echo "   Ports are forwarded to the running docker containers for webserver and database"
-    echo "     * ${WEBSERVER_HOST_PORT} -> forwarded to airflow webserver -> airflow-testing:8080"
-    echo "     * ${POSTGRES_HOST_PORT} -> forwarded to postgres database -> postgres:5432"
-    echo "     * ${MYSQL_HOST_PORT} -> forwarded to mysql database  -> mysql:3306"
-    echo
-    echo "   Here are links to those services that you can use on host:"
-    echo "     * Webserver: http://127.0.0.1:28080"
-    echo "     * Postgres:  jdbc:postgresql://127.0.0.1:25433/airflow?user=postgres&password=airflow"
-    echo "     * Mysql:     jdbc:mysql://localhost:23306/airflow?user=root"
-    echo
-else
-    echo
-fi
+print_setup_instructions
 
-# shellcheck disable=SC2034  # Unused variables left for comp_breeze usage
-if ! typeset -f "_comp_breeze" > /dev/null; then
-    print_line
-    echo
-    echo "  You can setup autocomplete by running '$0 --setup-autocomplete'"
-    echo
-    echo
-fi
-print_line
-echo
-echo "  You can toggle ascii/cheatsheet by adding this flag:"
-echo "      * --toggle-suppress-cheatsheet"
-echo "      * --toggle-suppress-asciiart"
-echo
-print_line
-echo
-echo
-echo
-echo
-
-if [[ ${ENTER_ENVIRONMENT} == "true" ]]; then
-    if [[ ${RUN_TESTS} == "true" ]]; then
-        "${BUILD_CACHE_DIR}/${LAST_DC_TEST_FILE}" "\"${TEST_TARGET}\"" "$@"
-    elif [[ ${RUN_DOCKER_COMPOSE} == "true" ]]; then
-        set +u
-        "${BUILD_CACHE_DIR}/${LAST_DC_FILE}" "${DOCKER_COMPOSE_COMMAND}" "${EXTRA_DC_OPTIONS[@]}" "$@"
-        set -u
-    elif [[ ${RUN_IN_BASH} == "true" ]]; then
-        "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}" "${RUN_COMMAND}" "$@"
-    else
-        if [[ ${AIRFLOW_CONTAINER_DEPS} == "true" ]]; then
-                 "${BUILD_CACHE_DIR}/${LAST_DC_RUN_FILE}"
-        else
-             "${BUILD_CACHE_DIR}/${LAST_DC_RUN_NO_DEPS_FILE}"
-        fi
-    fi
-else
-    if [[ ${RUN_STATIC_CHECKS} == "true" ]]; then
-        echo
-        echo "Making sure pre-commit is installed"
-        echo
-        if command -v pip3 >/dev/null; then
-          PIP_BIN=pip3
-        elif command -v pip >/dev/null; then
-          PIP_BIN=pip
-        else
-          echo >&2
-          echo >&2 "ERROR: You need to have pip or pip3 in your PATH"
-          echo >&2
-          S
-          exit 1
-        fi
-        "${PIP_BIN}" install --upgrade pre-commit >/dev/null 2>&1
-        # Add ~/.local/bin to the path in case pip is run outside of virtualenv
-        export PATH="${PATH}":~/.local/bin
-        if [[ ${STATIC_CHECK} == "all" ]]; then
-            echo
-            echo "Running: pre-commit run" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-            echo
-            pre-commit run "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-        elif [[ ${STATIC_CHECK} == "all-but-pylint" ]]; then
-            echo
-            echo "Setting SKIP=pylint. Running: pre-commit run" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-            echo
-            echo
-            SKIP=pylint pre-commit run "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-        else
-            echo
-            echo "Running: pre-commit run" "${STATIC_CHECK}" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-            echo
-            pre-commit run "${STATIC_CHECK}" "${EXTRA_STATIC_CHECK_OPTIONS[@]}" "$@"
-        fi
-    elif [[  ${RUN_BUILD_DOCS} == "true" ]]; then
-        run_docs
-    fi
-fi
+set +u  # Account for an empty array
+run_breeze_command "${REMAINING_ARGS[@]}"
diff --git a/breeze-complete b/breeze-complete
index 609c32625f719..a8382eb62d2ba 100644
--- a/breeze-complete
+++ b/breeze-complete
@@ -30,7 +30,7 @@ _BREEZE_SHORT_OPTIONS="
 h P: B: I: K Z X
 M: V:
 s b O N
-v y n C A
+v y n q C A
 r p R L u
 c D: H: e a
 t: d: k x: S: F:
@@ -40,9 +40,9 @@ _BREEZE_LONG_OPTIONS="
 help python: backend: integration: start-kind-cluster recreate-kind-cluster stop-kind-cluster
 kubernetes-mode: kubernetes-version:
 skip-mounting-local-sources build-only build-docs
-verbose assume-yes assume-no toggle-suppress-cheatsheet toggle-suppress-asciiart
+verbose assume-yes assume-no assume-quit toggle-suppress-cheatsheet toggle-suppress-asciiart
 force-build-images force-pull-images force-clean-images use-local-cache push-images
-cleanup-images dockerhub-user: dockerhub-repo: initialize-local-virtualenv setup-autocomplete
+cleanup-image dockerhub-user: dockerhub-repo: initialize-local-virtualenv setup-autocomplete
 test-target: docker-compose: stop-environment execute-command: static-check: static-check-all-files:
 "
 
diff --git a/common/_autodetect_variables.sh b/common/_autodetect_variables.sh
index 9e5b1da65857a..ecc24edf44d5b 100644
--- a/common/_autodetect_variables.sh
+++ b/common/_autodetect_variables.sh
@@ -53,11 +53,11 @@ export DOCKERHUB_USER=${DOCKERHUB_USER:="apache"}
 # own docker images. In this case you can build images locally and push them
 export DOCKERHUB_REPO=${DOCKERHUB_REPO:="airflow"}
 
-# if AIRFLOW_CONTAINER_BRANCH_NAME is not set it will be set to either SOURCE_BRANCH
+# if BRANCH_NAME is not set it will be set to either SOURCE_BRANCH
 # (if overridden by configuration) or default branch configured in /common/_default_branch.sh
 export SOURCE_BRANCH=${SOURCE_BRANCH:=${DEFAULT_BRANCH}}
 
-export AIRFLOW_CONTAINER_BRANCH_NAME=${AIRFLOW_CONTAINER_BRANCH_NAME:=${SOURCE_BRANCH}}
+export BRANCH_NAME=${BRANCH_NAME:=${SOURCE_BRANCH}}
 
 # IMAGE_NAME might come from DockerHub and we decide which PYTHON_VERSION to use based on it (see below)
 # In case IMAGE_NAME is not set we determine PYTHON_VERSION based on the default python on the path
@@ -65,7 +65,7 @@ export AIRFLOW_CONTAINER_BRANCH_NAME=${AIRFLOW_CONTAINER_BRANCH_NAME:=${SOURCE_B
 # PYTHON_VERSION from the IMAGE_NAME set in the DockerHub build.
 # See comment above in PYTHON_VERSION - we will be able to get rid of this cumbersomness when we switch
 # to a different CI system and start pushing images to DockerHub rather than build it there.
-export BASE_IMAGE_NAME=${IMAGE_NAME:=${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CONTAINER_BRANCH_NAME}-python${PYTHON_VERSION:-3.6}}
+export BASE_IMAGE_NAME=${IMAGE_NAME:=${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${BRANCH_NAME}-python${PYTHON_VERSION:-3.6}}
 
 # Remove index.docker.io/ prefix as it is added by default by DockerHub
 export LOCAL_BASE_IMAGE_NAME=${BASE_IMAGE_NAME#index.docker.io/}
diff --git a/hooks/build b/hooks/build
index b8ea1b61db9ba..ef2c6696614a4 100755
--- a/hooks/build
+++ b/hooks/build
@@ -110,7 +110,7 @@ function build_python_image {
         --build-arg PYTHON_BASE_IMAGE="${PYTHON_BASE_IMAGE}" \
         --build-arg AIRFLOW_VERSION="${AIRFLOW_VERSION}" \
         --build-arg AIRFLOW_EXTRAS="${AIRFLOW_EXTRAS}" \
-        --build-arg AIRFLOW_BRANCH="${AIRFLOW_CONTAINER_BRANCH_NAME}" \
+        --build-arg AIRFLOW_BRANCH="${BRANCH_NAME}" \
         --build-arg AIRFLOW_CONTAINER_CI_OPTIMISED_BUILD="${AIRFLOW_CONTAINER_CI_OPTIMISED_BUILD}" \
         --build-arg HOME="${HOME}" \
         "${DOCKER_CACHE_DIRECTIVE_CI[@]}" \
@@ -137,26 +137,26 @@ if [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
     echo
     echo "Disabling cache for CRON jobs"
     echo
-    AIRFLOW_CONTAINER_USE_NO_CACHE=${AIRFLOW_CONTAINER_USE_NO_CACHE:="true"}
+    USE_NO_CACHE=${USE_NO_CACHE:="true"}
 fi
 
-# You can set AIRFLOW_CONTAINER_USE_NO_CACHE to true if you want to use standard Docker cache during build
+# You can set USE_NO_CACHE to true if you want to use standard Docker cache during build
 # This way you can test building everything from the scratch
-AIRFLOW_CONTAINER_USE_NO_CACHE=${AIRFLOW_CONTAINER_USE_NO_CACHE:="false"}
+USE_NO_CACHE=${USE_NO_CACHE:="false"}
 
 # If cache is not used, there is no point in pulling images for cache
-if [[ "${AIRFLOW_CONTAINER_USE_NO_CACHE:=}" == "true" ]]; then
+if [[ "${USE_NO_CACHE:=}" == "true" ]]; then
     echo
     echo "Pulling images is disabled because cache is not used"
     echo
-    AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE="false"
+    USE_PULLED_IMAGES_AS_CACHE="false"
 fi
 
 
-# You can set AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE to false if you do not want to use pulled images
+# You can set USE_PULLED_IMAGES_AS_CACHE to false if you do not want to use pulled images
 # as cache during build
 # This way you can test building from the scratch
-AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE=${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE:="true"}
+USE_PULLED_IMAGES_AS_CACHE=${USE_PULLED_IMAGES_AS_CACHE:="true"}
 
 pwd
 # Determine version of the Airflow from version.py
@@ -187,19 +187,13 @@ echo
 
 # Whether to push images after build
 # This is set to false on CI builds
-export AIRFLOW_CONTAINER_PUSH_IMAGES=${AIRFLOW_CONTAINER_PUSH_IMAGES:=${NON_CI}}
+export PUSH_IMAGES=${PUSH_IMAGES:=${NON_CI}}
 
 # Whether to force pull images to populate cache
-export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES=${AIRFLOW_CONTAINER_FORCE_PULL_IMAGES:="false"}
+export FORCE_PULL_IMAGES=${FORCE_PULL_IMAGES:="false"}
 
 # In CI environment (and local force) we skip pulling latest python image
-export AIRFLOW_CONTAINER_SKIP_LATEST_PYTHON_PULL=${AIRFLOW_CONTAINER_SKIP_LATEST_PYTHON_PULL:=${CI}}
-
-# Skips downloading and building the CI image, full CI-enabled image of airflow
-# This is set to true for pre-tests which do not need the whole CI image
-export AIRFLOW_CONTAINER_SKIP_CI_IMAGE=${AIRFLOW_CONTAINER_SKIP_CI_IMAGE:="false"}
-echo "Skip CI image: ${AIRFLOW_CONTAINER_SKIP_CI_IMAGE}"
-
+export SKIP_PULLING_LATEST_PYTHON_IMAGE=${SKIP_PULLING_LATEST_PYTHON_IMAGE:=${CI}}
 
 export AIRFLOW_CONTAINER_CI_OPTIMISED_BUILD=${AIRFLOW_CONTAINER_CI_OPTIMISED_BUILD:="true"}
 echo "The build optimised for CI: ${AIRFLOW_CONTAINER_CI_OPTIMISED_BUILD}"
@@ -228,36 +222,17 @@ IMAGES_BUILT=""
 
 end_step
 
-AIRFLOW_CONTAINER_CLEANUP_IMAGES=${AIRFLOW_CONTAINER_CLEANUP_IMAGES:="false"}
-if [[ "${AIRFLOW_CONTAINER_CLEANUP_IMAGES}" == "true" ]]; then
-    echo
-    "${AIRFLOW_SOURCES}/confirm" "Removing all local images for that build."
-    echo
-    start_step "Removing images"
-    docker rmi "${PYTHON_BASE_IMAGE}" || true
-    docker rmi "${AIRFLOW_CI_IMAGE}" || true
-    echo
-    echo "###################################################################"
-    echo "NOTE!! Removed Airflow images for Python version ${PYTHON_VERSION}."
-    echo "       But the disk space in docker will be reclaimed only after"
-    echo "       running 'docker system prune' command."
-    echo "###################################################################"
-    echo
-    end_step
-    exit 0
-fi
-
 start_step "Populating cache"
 
 DOCKER_CACHE_DIRECTIVE_CI=()
 
-if [[ "${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE}" == "true" ]]; then
+if [[ "${USE_PULLED_IMAGES_AS_CACHE}" == "true" ]]; then
     echo
     echo "Pulling images to populate cache"
     echo
     echo
-    if [[ "${AIRFLOW_CONTAINER_FORCE_PULL_IMAGES}" == "true" ]]; then
-        if [[ ${AIRFLOW_CONTAINER_SKIP_LATEST_PYTHON_PULL} == "true" ]]; then
+    if [[ "${FORCE_PULL_IMAGES}" == "true" ]]; then
+        if [[ ${SKIP_PULLING_LATEST_PYTHON_IMAGE} == "true" ]]; then
             echo
             echo "Skip force-pulling the base images."
             echo
@@ -271,11 +246,7 @@ if [[ "${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE}" == "true" ]]; then
             set +x
         fi
     fi
-    IMAGES_TO_PULL=""
-    if [[ "${AIRFLOW_CONTAINER_SKIP_CI_IMAGE}" != "true" ]]; then
-        echo "Downloading the CI Airflow image"
-        IMAGES_TO_PULL="${IMAGES_TO_PULL} ${AIRFLOW_CI_IMAGE}"
-    fi
+    IMAGES_TO_PULL="${AIRFLOW_CI_IMAGE}"
 
     DOCKER_CACHE_DIRECTIVE_CI=()
     if [[ ${IMAGES_TO_PULL} == "" ]]; then
@@ -289,7 +260,7 @@ if [[ "${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE}" == "true" ]]; then
             echo "Checking whether image ${IMAGE} needs to be pulled."
             echo
             PULL_IMAGE="false"
-            if [[ "${AIRFLOW_CONTAINER_FORCE_PULL_IMAGES}" == "true" ]]; then
+            if [[ "${FORCE_PULL_IMAGES}" == "true" ]]; then
                 echo
                 echo "Pulling images is forced. Pulling ${IMAGE}"
                 echo
@@ -329,7 +300,7 @@ fi
 
 start_step "Setting cache options"
 
-if [[ "${AIRFLOW_CONTAINER_USE_NO_CACHE}" == "true" ]]; then
+if [[ "${USE_NO_CACHE}" == "true" ]]; then
     DOCKER_CACHE_DIRECTIVE_CI+=("--no-cache")
     echo
     echo "Skip cache for builds. Everything will be rebuilt from scratch."
@@ -337,7 +308,7 @@ if [[ "${AIRFLOW_CONTAINER_USE_NO_CACHE}" == "true" ]]; then
     echo "Cache directives used: "
     echo "CI build: ${DOCKER_CACHE_DIRECTIVE_CI[*]}"
     echo
-elif [[ "${AIRFLOW_CONTAINER_USE_PULLED_IMAGES_CACHE}" == "true" ]]; then
+elif [[ "${USE_PULLED_IMAGES_AS_CACHE}" == "true" ]]; then
     echo
     echo "This build uses Docker cache from pulled images"
     echo "Cache directives used: "
@@ -369,7 +340,7 @@ BUILD_ID=${BUILD_ID:="local"}
 
 
 # directory where "deployment" artifacts should be placed
-DEPLOY_DIR="${AIRFLOW_SOURCES}/dist/${AIRFLOW_CONTAINER_BRANCH_NAME}/$(date "+%Y-%m-%d")/${BUILD_ID}/${PYTHON_VERSION}"
+DEPLOY_DIR="${AIRFLOW_SOURCES}/dist/${BRANCH_NAME}/$(date "+%Y-%m-%d")/${BUILD_ID}/${PYTHON_VERSION}"
 
 mkdir -pv "${DEPLOY_DIR}"
 
@@ -397,38 +368,34 @@ function filterout_deleted_files {
 }
 
 # This deals with files
-git ls-files -z -- ./ ':!:airflow/www/static/docs' | filterout_deleted_files | xargs -0 chmod og-w
+git ls-files -z -- ./ | filterout_deleted_files | xargs -0 chmod og-w
 # and this deals with directories
 git ls-tree -z -r -d --name-only HEAD | filterout_deleted_files | xargs -0 chmod og-w,og+x
 
-if [[ "${AIRFLOW_CONTAINER_SKIP_CI_IMAGE}" == "true" ]]; then
-    echo "Skip building the CI full Airflow image"
-else
-    start_step "Build Airflow CI full image"
-    build_python_image "Airflow CI" \
-                "${AIRFLOW_CI_IMAGE}" \
-                "main" \
-                "devel_ci" \
-                "root" \
-                "/root"
-
+start_step "Build Airflow CI full image"
+build_python_image "Airflow CI" \
+            "${AIRFLOW_CI_IMAGE}" \
+            "main" \
+            "devel_ci" \
+            "root" \
+            "/root"
+
+if [[ "${PYTHON_VERSION_FOR_DEFAULT_IMAGE}" == "${PYTHON_VERSION}" ]]; then
+    docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_DEFAULT}"
+    add_image_to_push "${AIRFLOW_CI_IMAGE_DEFAULT}"
+fi
+if [[ "${AIRFLOW_RELEASE_BUILD}" == "true" ]]; then
+    docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_LATEST}"
+    add_image_to_push "${AIRFLOW_CI_IMAGE_LATEST}"
     if [[ "${PYTHON_VERSION_FOR_DEFAULT_IMAGE}" == "${PYTHON_VERSION}" ]]; then
-        docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_DEFAULT}"
-        add_image_to_push "${AIRFLOW_CI_IMAGE_DEFAULT}"
-    fi
-    if [[ "${AIRFLOW_RELEASE_BUILD}" == "true" ]]; then
-        docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_LATEST}"
-        add_image_to_push "${AIRFLOW_CI_IMAGE_LATEST}"
-        if [[ "${PYTHON_VERSION_FOR_DEFAULT_IMAGE}" == "${PYTHON_VERSION}" ]]; then
-            docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_LATEST_DEFAULT}"
-            add_image_to_push "${AIRFLOW_CI_IMAGE_LATEST_DEFAULT}"
-        fi
+        docker tag "${AIRFLOW_CI_IMAGE}" "${AIRFLOW_CI_IMAGE_LATEST_DEFAULT}"
+        add_image_to_push "${AIRFLOW_CI_IMAGE_LATEST_DEFAULT}"
     fi
 fi
 
 start_step "Pushing images"
 
-if [[ "${AIRFLOW_CONTAINER_PUSH_IMAGES}" != "false" ]]; then
+if [[ "${PUSH_IMAGES}" != "false" ]]; then
     echo
     echo "Pushing images: ${IMAGES_BUILT}"
     echo
diff --git a/scripts/ci/_utils.sh b/scripts/ci/_utils.sh
index aa5470450be4d..081d8f766b41e 100644
--- a/scripts/ci/_utils.sh
+++ b/scripts/ci/_utils.sh
@@ -19,7 +19,7 @@
 # Assume all the scripts are sourcing the _utils.sh from the scripts/ci directory
 # and MY_DIR variable is set to this directory. It can be overridden however
 
-declare -a AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS
+declare -a EXTRA_DOCKER_FLAGS
 
 function check_verbose_setup {
     if [[ ${VERBOSE:=} == "true" ]]; then
@@ -55,7 +55,7 @@ function initialize_breeze_environment {
     . "${AIRFLOW_SOURCES}/common/_files_for_rebuild_check.sh"
 
     # Default branch name for triggered builds is the one configured in default branch
-    export AIRFLOW_CONTAINER_BRANCH_NAME=${AIRFLOW_CONTAINER_BRANCH_NAME:=${DEFAULT_BRANCH}}
+    export BRANCH_NAME=${BRANCH_NAME:=${DEFAULT_BRANCH}}
 
     # Default port numbers for forwarded ports
     export WEBSERVER_HOST_PORT=${WEBSERVER_HOST_PORT:="28080"}
@@ -63,22 +63,22 @@ function initialize_breeze_environment {
     export MYSQL_HOST_PORT=${MYSQL_HOST_PORT:="23306"}
 
     # Do not push images from here by default (push them directly from the build script on Dockerhub)
-    export AIRFLOW_CONTAINER_PUSH_IMAGES=${AIRFLOW_CONTAINER_PUSH_IMAGES:="false"}
+    export PUSH_IMAGES=${PUSH_IMAGES:="false"}
 
     # Disable writing .pyc files - slightly slower imports but not messing around when switching
     # Python version and avoids problems with root-owned .pyc files in host
     export PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE:="true"}
 
     # By default we assume the kubernetes cluster is not being started
-    export ENABLE_KIND_CLUSTER=${ENABLE_KIND_CLUSTER:="false"}
+   export ENABLE_KIND_CLUSTER=${ENABLE_KIND_CLUSTER:="false"}
     #
     # Sets mounting of host volumes to container for static checks
-    # unless AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS is not true
+    # unless MOUNT_HOST_AIRFLOW_VOLUME is not true
     #
-    # Note that this cannot be function because we need the AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS array variable
+    # Note that this cannot be function because we need the EXTRA_DOCKER_FLAGS array variable
     #
-    AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS=${AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS:="true"}
-    export AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS
+    MOUNT_HOST_AIRFLOW_VOLUME=${MOUNT_HOST_AIRFLOW_VOLUME:="true"}
+    export MOUNT_HOST_AIRFLOW_VOLUME
 
     # If this variable is set, we mount the whole sources directory to the host rather than
     # selected volumes
@@ -97,30 +97,30 @@ function initialize_breeze_environment {
         print_info
         print_info "Mount whole airflow source directory for static checks (make sure all files are in container)"
         print_info
-        AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS=( \
+        EXTRA_DOCKER_FLAGS=( \
           "-v" "${AIRFLOW_SOURCES}:/opt/airflow" \
           "--env" "PYTHONDONTWRITEBYTECODE" \
         )
-    elif [[ ${AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS} == "true" ]]; then
+    elif [[ ${MOUNT_HOST_AIRFLOW_VOLUME} == "true" ]]; then
         print_info
         print_info "Mounting necessary host volumes to Docker"
         print_info
 
-        AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS=()
+        EXTRA_DOCKER_FLAGS=()
 
         while IFS= read -r LINE; do
-            AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS+=( "${LINE}")
+            EXTRA_DOCKER_FLAGS+=( "${LINE}")
         done < <(convert_docker_mounts_to_docker_params)
     else
         print_info
         print_info "Skip mounting host volumes to Docker"
         print_info
-        AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS=( \
+        EXTRA_DOCKER_FLAGS=( \
             "--env" "PYTHONDONTWRITEBYTECODE" \
         )
     fi
 
-    export AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS
+    export EXTRA_DOCKER_FLAGS
 }
 
 function print_info() {
@@ -284,12 +284,8 @@ function update_all_md5_files() {
     do
         move_file_md5sum "${AIRFLOW_SOURCES}/${FILE}"
     done
-    local SUFFIX=""
-    if [[ -n ${PYTHON_VERSION:=""} ]]; then
-        SUFFIX="_${PYTHON_VERSION}"
-    fi
     mkdir -pv "${BUILD_CACHE_DIR}/${DEFAULT_BRANCH}"
-    touch "${BUILD_CACHE_DIR}/${DEFAULT_BRANCH}/.built_${THE_IMAGE_TYPE}${SUFFIX}"
+    touch "${BUILT_IMAGE_FLAG_FILE}"
 }
 
 #
@@ -316,7 +312,7 @@ function check_if_docker_build_is_needed() {
     print_info "Checking if docker image build is needed for ${THE_IMAGE_TYPE} image."
     print_info
     local IMAGE_BUILD_NEEDED="false"
-    if [[ ${AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD:=""} == "true" ]]; then
+    if [[ ${FORCE_BUILD_IMAGES:=""} == "true" ]]; then
         print_info "Docker image build is forced for ${THE_IMAGE_TYPE} image"
         set +e
         for FILE in "${FILES_FOR_REBUILD_CHECK[@]}"
@@ -326,20 +322,20 @@ function check_if_docker_build_is_needed() {
         done
         set -e
         IMAGES_TO_REBUILD+=("${THE_IMAGE_TYPE}")
-        export AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="true"
+        export NEEDS_DOCKER_BUILD="true"
     else
         set +e
         for FILE in "${FILES_FOR_REBUILD_CHECK[@]}"
         do
             if ! check_file_md5sum "${AIRFLOW_SOURCES}/${FILE}"; then
-                export AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="true"
+                export NEEDS_DOCKER_BUILD="true"
                 IMAGE_BUILD_NEEDED=true
             fi
         done
         set -e
         if [[ ${IMAGE_BUILD_NEEDED} == "true" ]]; then
             IMAGES_TO_REBUILD+=("${THE_IMAGE_TYPE}")
-            export AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="true"
+            export NEEDS_DOCKER_BUILD="true"
             print_info "Docker image build is needed for ${THE_IMAGE_TYPE} image!"
         else
             print_info "Docker image build is not needed for ${THE_IMAGE_TYPE} image!"
@@ -462,17 +458,17 @@ function confirm_image_rebuild() {
     set +e
     if [[ ${CI:="false"} == "true" ]]; then
         print_info
-        print_info "CI environment - forcing ${ACTION} for ${THE_IMAGE_TYPE} image."
+        print_info "CI environment - forcing build for ${THE_IMAGE_TYPE} image."
         print_info
         RES="0"
     elif [[ -c /dev/tty ]]; then
         # Make sure to use /dev/tty first rather than stdin/stdout when available - this way confirm
         # will works also in case of pre-commits (git does not pass stdin/stdout to pre-commit hooks)
-        "${AIRFLOW_SOURCES}/confirm" "${ACTION} ${THE_IMAGE_TYPE}" </dev/tty >/dev/tty
+        "${AIRFLOW_SOURCES}/confirm" "build ${THE_IMAGE_TYPE}" </dev/tty >/dev/tty
         RES=$?
     elif [[ -t 0 ]]; then
         # Check if this script is run interactively with stdin open and terminal attached
-        "${AIRFLOW_SOURCES}/confirm" "${ACTION} ${THE_IMAGE_TYPE}"
+        "${AIRFLOW_SOURCES}/confirm" "build ${THE_IMAGE_TYPE}"
         RES=$?
     else
         # No terminal, no stdin - quitting!
@@ -481,7 +477,7 @@ function confirm_image_rebuild() {
     set -e
     if [[ ${RES} == "1" ]]; then
         print_info
-        print_info "Skipping ${ACTION} for ${THE_IMAGE_TYPE}"
+        print_info "Skipping build for ${THE_IMAGE_TYPE}"
         print_info
         SKIP_REBUILD="true"
         # Force "no" also to subsequent questions so that if you answer it once, you are not asked
@@ -490,8 +486,8 @@ function confirm_image_rebuild() {
         echo 'export FORCE_ANSWER_TO_QUESTIONS="no"' > "${LAST_FORCE_ANSWER_FILE}"
     elif [[ ${RES} == "2" ]]; then
         echo >&2
-        echo >&2 "ERROR: The image needs ${ACTION} for ${THE_IMAGE_TYPE} - it is outdated. "
-        echo >&2 "   Make sure you build the images bu running run one of:"
+        echo >&2 "ERROR: The image needs to be byilt for ${THE_IMAGE_TYPE} - it is outdated. "
+        echo >&2 "   Make sure you build the images by running run one of:"
         echo >&2 "         * ./breeze --build-only"
         echo >&2 "         * ./breeze --build-only --force-pull-images"
         echo >&2
@@ -513,14 +509,9 @@ print(version.replace("+",""))
 EOF
     )
     export AIRFLOW_VERSION
+    export BUILT_IMAGE_FLAG_FILE="${BUILD_CACHE_DIR}/${BRANCH_NAME}/.built_${PYTHON_VERSION}"
 
-    if [[ ${AIRFLOW_CONTAINER_CLEANUP_IMAGES:="false"} == "true" ]]; then
-        print_info
-        print_info "Clean up ${THE_IMAGE_TYPE} image. Just cleanup no pull of images happen."
-        print_info
-        export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES="false"
-        export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
-    elif [[ -f "${BUILD_CACHE_DIR}/${DEFAULT_BRANCH}/.built_${THE_IMAGE_TYPE}_${PYTHON_VERSION}" ]]; then
+    if [[ -f "${BUILT_IMAGE_FLAG_FILE}" ]]; then
         print_info
         print_info "${THE_IMAGE_TYPE} image already built locally."
         print_info
@@ -528,32 +519,27 @@ EOF
         print_info
         print_info "${THE_IMAGE_TYPE} image not built locally: pulling and building"
         print_info
-        export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES="true"
-        export AIRFLOW_CONTAINER_FORCE_DOCKER_BUILD="true"
+        export FORCE_PULL_IMAGES="true"
+        export FORCE_BUILD_IMAGES="true"
     fi
 
-    AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="false"
+    NEEDS_DOCKER_BUILD="false"
     IMAGES_TO_REBUILD=()
     check_if_docker_build_is_needed
-    if [[ "${AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED}" == "true" ]]; then
+    if [[ "${NEEDS_DOCKER_BUILD}" == "true" ]]; then
         SKIP_REBUILD="false"
-        if [[ ${AIRFLOW_CONTAINER_CLEANUP_IMAGES} == "true" ]]; then
-            export ACTION="clean"
-        else
-            export ACTION="rebuild"
-        fi
         if [[ ${CI:=} != "true" && "${FORCE_BUILD:=}" != "true" ]]; then
             confirm_image_rebuild
         fi
         if [[ ${SKIP_REBUILD} != "true" ]]; then
             print_info
-            print_info "${ACTION} start: ${THE_IMAGE_TYPE} image."
+            print_info "Build start: ${THE_IMAGE_TYPE} image."
             print_info
             # shellcheck source=hooks/build
             ./hooks/build | tee -a "${OUTPUT_LOG}"
             update_all_md5_files
             print_info
-            print_info "${ACTION} completed: ${THE_IMAGE_TYPE} image."
+            print_info "Build completed: ${THE_IMAGE_TYPE} image."
             print_info
         fi
     else
@@ -567,10 +553,7 @@ EOF
 # Rebuilds the image for tests if needed.
 #
 function rebuild_ci_image_if_needed() {
-    export AIRFLOW_CONTAINER_SKIP_CI_IMAGE="false"
-
     export THE_IMAGE_TYPE="CI"
-
     export AIRFLOW_CI_IMAGE="${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${DEFAULT_BRANCH}-python${PYTHON_VERSION}-ci"
 
     rebuild_image_if_needed
@@ -667,7 +650,7 @@ function filter_out_files_from_pylint_todo_list() {
 }
 
 function rebuild_all_images_if_needed_and_confirmed() {
-    AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED="false"
+    NEEDS_DOCKER_BUILD="false"
     IMAGES_TO_REBUILD=()
 
     for THE_IMAGE_TYPE in "${IMAGES_TO_CHECK[@]}"
@@ -675,7 +658,7 @@ function rebuild_all_images_if_needed_and_confirmed() {
         check_if_docker_build_is_needed
     done
 
-    if [[ ${AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED} == "true" ]]; then
+    if [[ ${NEEDS_DOCKER_BUILD} == "true" ]]; then
         print_info
         print_info "Docker image build is needed for ${IMAGES_TO_REBUILD[*]}!"
         print_info
@@ -685,7 +668,7 @@ function rebuild_all_images_if_needed_and_confirmed() {
         print_info
     fi
 
-    if [[ "${AIRFLOW_CONTAINER_DOCKER_BUILD_NEEDED}" == "true" ]]; then
+    if [[ "${NEEDS_DOCKER_BUILD}" == "true" ]]; then
         echo
         echo "Some of your images need to be rebuild because important files (like package list) has changed."
         echo
@@ -699,9 +682,6 @@ function rebuild_all_images_if_needed_and_confirmed() {
         echo "   The first command works incrementally from your last local build."
         echo "   The second command you use if you want to completely refresh your images from dockerhub."
         echo
-        export ACTION="rebuild"
-        export THE_IMAGE_TYPE="${IMAGES_TO_REBUILD[*]}"
-
         SKIP_REBUILD="false"
         confirm_image_rebuild
 
@@ -760,7 +740,7 @@ function build_image_on_ci() {
         echo
     fi
 
-    export AIRFLOW_CONTAINER_FORCE_PULL_IMAGES="true"
+    export FORCE_PULL_IMAGES="true"
     export FORCE_BUILD="true"
     export VERBOSE="${VERBOSE:="false"}"
 
@@ -806,7 +786,7 @@ function build_image_on_ci() {
     fi
 
     # Disable force pulling forced above
-    unset AIRFLOW_CONTAINER_FORCE_PULL_IMAGES
+    unset FORCE_PULL_IMAGES
     unset FORCE_BUILD
 }
 
@@ -819,7 +799,7 @@ function save_to_file {
     echo "$(eval echo "\$$1")" > "${BUILD_CACHE_DIR}/.$1"
 }
 
-function check_for_allowed_params {
+function check_and_save_allowed_param {
     _VARIABLE_NAME="${1}"
     _VARIABLE_DESCRIPTIVE_NAME="${2}"
     _FLAG="${3}"
diff --git a/scripts/ci/ci_check_license.sh b/scripts/ci/ci_check_license.sh
index 1b904db51a66b..b22e7ea45f61e 100755
--- a/scripts/ci/ci_check_license.sh
+++ b/scripts/ci/ci_check_license.sh
@@ -23,7 +23,7 @@ export PYTHON_VERSION=${PYTHON_VERSION:-3.6}
 . "$( dirname "${BASH_SOURCE[0]}" )/_script_init.sh"
 
 function run_check_license() {
-    docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" -t \
+    docker run "${EXTRA_DOCKER_FLAGS[@]}" -t \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
diff --git a/scripts/ci/ci_cleanup.sh b/scripts/ci/ci_cleanup.sh
deleted file mode 100755
index 064d47a6ad41a..0000000000000
--- a/scripts/ci/ci_cleanup.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env bash
-# 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.
-# shellcheck source=scripts/ci/_script_init.sh
-. "$( dirname "${BASH_SOURCE[0]}" )/_script_init.sh"
-
-#
-# Cleans up the CI image
-#
-function cleanup_ci_image() {
-    export AIRFLOW_CONTAINER_SKIP_CI_IMAGE="false"
-    export AIRFLOW_CONTAINER_CLEANUP_IMAGES="true"
-
-    export THE_IMAGE_TYPE="CI"
-
-    rebuild_image_if_needed
-}
-
-cleanup_ci_image
diff --git a/scripts/ci/ci_docs.sh b/scripts/ci/ci_docs.sh
index 6f055f6cf75f2..d7c92a72aa781 100755
--- a/scripts/ci/ci_docs.sh
+++ b/scripts/ci/ci_docs.sh
@@ -21,6 +21,20 @@ export PYTHON_VERSION=${PYTHON_VERSION:-3.6}
 # shellcheck source=scripts/ci/_script_init.sh
 . "$( dirname "${BASH_SOURCE[0]}" )/_script_init.sh"
 
+function run_docs() {
+    docker run "${EXTRA_DOCKER_FLAGS[@]}" -t \
+            --entrypoint "/usr/local/bin/dumb-init"  \
+            --env PYTHONDONTWRITEBYTECODE \
+            --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
+            --env AIRFLOW_CI_SILENT \
+            --env HOST_USER_ID="$(id -ur)" \
+            --env HOST_GROUP_ID="$(id -gr)" \
+            --rm \
+            "${AIRFLOW_CI_IMAGE}" \
+            "--" "/opt/airflow/docs/build.sh" \
+            | tee -a "${OUTPUT_LOG}"
+}
+
 rebuild_ci_image_if_needed
 
 run_docs
diff --git a/scripts/ci/ci_fix_ownership.sh b/scripts/ci/ci_fix_ownership.sh
index a57359de838bd..50999b31fc760 100755
--- a/scripts/ci/ci_fix_ownership.sh
+++ b/scripts/ci/ci_fix_ownership.sh
@@ -26,7 +26,7 @@ export PYTHON_VERSION=${PYTHON_VERSION:-3.6}
 . "$( dirname "${BASH_SOURCE[0]}" )/_script_init.sh"
 
 export AIRFLOW_CI_IMAGE=\
-${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CONTAINER_BRANCH_NAME}-python${PYTHON_VERSION}-ci
+${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${BRANCH_NAME}-python${PYTHON_VERSION}-ci
 
 docker-compose \
     -f "${MY_DIR}/docker-compose/base.yml" \
diff --git a/scripts/ci/ci_flake8.sh b/scripts/ci/ci_flake8.sh
index abdaf7c330993..6a1da70715f7a 100755
--- a/scripts/ci/ci_flake8.sh
+++ b/scripts/ci/ci_flake8.sh
@@ -25,7 +25,7 @@ function run_flake8() {
     FILES=("$@")
 
     if [[ "${#FILES[@]}" == "0" ]]; then
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
@@ -37,7 +37,7 @@ function run_flake8() {
             "--" "/opt/airflow/scripts/ci/in_container/run_flake8.sh" \
             | tee -a "${OUTPUT_LOG}"
     else
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
diff --git a/scripts/ci/ci_mypy.sh b/scripts/ci/ci_mypy.sh
index 58c50b62b9970..bb9dfbeae5a6d 100755
--- a/scripts/ci/ci_mypy.sh
+++ b/scripts/ci/ci_mypy.sh
@@ -29,7 +29,7 @@ function run_mypy() {
       FILES=(airflow tests docs)
     fi
 
-    docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+    docker run "${EXTRA_DOCKER_FLAGS[@]}" \
         --entrypoint "/usr/local/bin/dumb-init"  \
         --env PYTHONDONTWRITEBYTECODE \
         --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
diff --git a/scripts/ci/ci_pylint_main.sh b/scripts/ci/ci_pylint_main.sh
index 5d2397f65046f..e0ea79e176d2e 100755
--- a/scripts/ci/ci_pylint_main.sh
+++ b/scripts/ci/ci_pylint_main.sh
@@ -24,7 +24,7 @@ export PYTHON_VERSION=${PYTHON_VERSION:-3.6}
 function run_pylint_main() {
     FILES=("$@")
     if [[ "${#FILES[@]}" == "0" ]]; then
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
@@ -36,7 +36,7 @@ function run_pylint_main() {
             "--" "/opt/airflow/scripts/ci/in_container/run_pylint_main.sh" \
             | tee -a "${OUTPUT_LOG}"
     else
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init" \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
diff --git a/scripts/ci/ci_pylint_tests.sh b/scripts/ci/ci_pylint_tests.sh
index b16cf1278631a..d493c47a451c7 100755
--- a/scripts/ci/ci_pylint_tests.sh
+++ b/scripts/ci/ci_pylint_tests.sh
@@ -25,7 +25,7 @@ export PYTHON_VERSION=${PYTHON_VERSION:-3.6}
 function run_pylint_tests() {
     FILES=("$@")
     if [[ "${#FILES[@]}" == "0" ]]; then
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
@@ -37,7 +37,7 @@ function run_pylint_tests() {
             "--" "/opt/airflow/scripts/ci/in_container/run_pylint_tests.sh" \
             | tee -a "${OUTPUT_LOG}"
     else
-        docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+        docker run "${EXTRA_DOCKER_FLAGS[@]}" \
             --entrypoint "/usr/local/bin/dumb-init"  \
             --env PYTHONDONTWRITEBYTECODE \
             --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
diff --git a/scripts/ci/ci_refresh_pylint_todo.sh b/scripts/ci/ci_refresh_pylint_todo.sh
index 288146d143e48..fcea05d3307ce 100755
--- a/scripts/ci/ci_refresh_pylint_todo.sh
+++ b/scripts/ci/ci_refresh_pylint_todo.sh
@@ -22,7 +22,7 @@ export FORCE_ANSWER_TO_QUESTIONS=quit
 . "$( dirname "${BASH_SOURCE[0]}" )/_script_init.sh"
 
 function refresh_pylint_todo() {
-    docker run "${AIRFLOW_CONTAINER_EXTRA_DOCKER_FLAGS[@]}" \
+    docker run "${EXTRA_DOCKER_FLAGS[@]}" \
         --env PYTHONDONTWRITEBYTECODE \
         --env AIRFLOW_CI_VERBOSE="${VERBOSE}" \
         --env AIRFLOW_CI_SILENT \
diff --git a/scripts/ci/in_container/_in_container_utils.sh b/scripts/ci/in_container/_in_container_utils.sh
index c4b35f48d2dec..9651cf945e095 100644
--- a/scripts/ci/in_container/_in_container_utils.sh
+++ b/scripts/ci/in_container/_in_container_utils.sh
@@ -43,7 +43,7 @@ function in_container_script_end() {
         echo "###########################################################################################"
 
     fi
-    if [[ ${AIRFLOW_CI_VERBOSE:="false"} == "true" ]]; then
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
         set +x
     fi
 }
@@ -58,9 +58,11 @@ function print_in_container_info() {
 # Cleans up PYC files (in case they come in mounted folders)
 #
 function in_container_cleanup_pyc() {
-    print_in_container_info
-    print_in_container_info "Cleaning up .pyc files"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Cleaning up .pyc files"
+        print_in_container_info
+    fi
     set +o pipefail
     NUM_FILES=$(sudo find . \
         -path "./airflow/www/node_modules" -prune -o \
@@ -69,19 +71,23 @@ function in_container_cleanup_pyc() {
         -path "./docs/_build" -prune -o \
         -path "./build" -prune -o \
         -name "*.pyc" | grep ".pyc$" | sudo xargs rm -vf | wc -l)
-    print_in_container_info "Number of deleted .pyc files: ${NUM_FILES}"
     set -o pipefail
-    print_in_container_info
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info "Number of deleted .pyc files: ${NUM_FILES}"
+        print_in_container_info
+        print_in_container_info
+    fi
 }
 
 #
 # Cleans up __pycache__ directories (in case they come in mounted folders)
 #
 function in_container_cleanup_pycache() {
-    print_in_container_info
-    print_in_container_info "Cleaning up __pycache__ directories"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Cleaning up __pycache__ directories"
+        print_in_container_info
+    fi
     set +o pipefail
     NUM_FILES=$(find . \
         -path "./airflow/www/node_modules" -prune -o \
@@ -90,10 +96,12 @@ function in_container_cleanup_pycache() {
         -path "./docs/_build" -prune -o \
         -path "./build" -prune -o \
         -name "__pycache__" | grep "__pycache__" | sudo xargs rm -rvf | wc -l)
-    print_in_container_info "Number of deleted __pycache__ dirs (and files): ${NUM_FILES}"
     set -o pipefail
-    print_in_container_info
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info "Number of deleted __pycache__ dirs (and files): ${NUM_FILES}"
+        print_in_container_info
+        print_in_container_info
+    fi
 }
 
 #
@@ -101,22 +109,28 @@ function in_container_cleanup_pycache() {
 # The host user.
 #
 function in_container_fix_ownership() {
-    print_in_container_info
-    print_in_container_info "Changing ownership of root-owned files to ${HOST_USER_ID}.${HOST_GROUP_ID}"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Changing ownership of root-owned files to ${HOST_USER_ID}.${HOST_GROUP_ID}"
+        print_in_container_info
+    fi
     set +o pipefail
     sudo find . -user root | sudo xargs chown -v "${HOST_USER_ID}.${HOST_GROUP_ID}" | wc -l | \
         xargs -n 1 echo "Number of files with changed ownership:"
     set -o pipefail
-    print_in_container_info
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info
+    fi
 }
 
 function in_container_go_to_airflow_sources() {
     pushd "${AIRFLOW_SOURCES}"  &>/dev/null || exit 1
-    print_in_container_info
-    print_in_container_info "Running in $(pwd)"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Running in $(pwd)"
+        print_in_container_info
+    fi
 }
 
 function in_container_basic_sanity_check() {
@@ -127,14 +141,15 @@ function in_container_basic_sanity_check() {
 }
 
 function in_container_refresh_pylint_todo() {
-    print_in_container_info
-    print_in_container_info "Refreshing list of all  non-pylint compliant files. This can take some time."
-    print_in_container_info
-
-    print_in_container_info
-    print_in_container_info "Finding list  all non-pylint compliant files everywhere except 'tests' folder"
-    print_in_container_info
-
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Refreshing list of all  non-pylint compliant files. This can take some time."
+        print_in_container_info
+
+        print_in_container_info
+        print_in_container_info "Finding list  all non-pylint compliant files everywhere except 'tests' folder"
+        print_in_container_info
+    fi
     # Using path -prune is much better in the local environment on OSX because we have host
     # Files mounted and node_modules is a huge directory which takes many seconds to even scan
     # -prune works better than -not path because it skips traversing the whole directory. -not path traverses
@@ -157,14 +172,15 @@ function in_container_refresh_pylint_todo() {
        grep -v "^$" | grep -v "\-\-\-" | grep -v "^Your code has been" | \
        awk 'BEGIN{FS=":"}{print "./"$1}' | sort | uniq > "${MY_DIR}/../pylint_todo_new.txt"
 
-    print_in_container_info
-    print_in_container_info "So far found $(wc -l <"${MY_DIR}/../pylint_todo_new.txt") files"
-    print_in_container_info
-
-    print_in_container_info
-    print_in_container_info "Finding list of all non-pylint compliant files in 'tests' folder"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "So far found $(wc -l <"${MY_DIR}/../pylint_todo_new.txt") files"
+        print_in_container_info
 
+        print_in_container_info
+        print_in_container_info "Finding list of all non-pylint compliant files in 'tests' folder"
+        print_in_container_info
+    fi
     find "./tests" -name "*.py" -print0 | \
         xargs -0 pylint --disable="${DISABLE_CHECKS_FOR_TESTS}" | tee "${MY_DIR}/../pylint_todo_tests.txt"
 
@@ -175,9 +191,11 @@ function in_container_refresh_pylint_todo() {
     rm -fv "${MY_DIR}/../pylint_todo_main.txt" "${MY_DIR}/../pylint_todo_tests.txt"
     mv -v "${MY_DIR}/../pylint_todo_new.txt" "${MY_DIR}/../pylint_todo.txt"
 
-    print_in_container_info
-    print_in_container_info "Found $(wc -l <"${MY_DIR}/../pylint_todo.txt") files"
-    print_in_container_info
+    if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
+        print_in_container_info
+        print_in_container_info "Found $(wc -l <"${MY_DIR}/../pylint_todo.txt") files"
+        print_in_container_info
+    fi
 }
 
 export DISABLE_CHECKS_FOR_TESTS="missing-docstring,no-self-use,too-many-public-methods,protected-access,do-not-use-asserts"
diff --git a/scripts/ci/in_container/check_environment.sh b/scripts/ci/in_container/check_environment.sh
index ddb7090f07a2f..509d10e57dfb8 100755
--- a/scripts/ci/in_container/check_environment.sh
+++ b/scripts/ci/in_container/check_environment.sh
@@ -70,16 +70,10 @@ function check_integration {
     echo "-----------------------------------------------------------------------------------------------"
 }
 
-echo
-echo "Check CI environment sanity!"
-echo
-
 export EXIT_CODE=0
 
 if [[ -n ${BACKEND:=} ]]; then
-    echo "==============================================================================================="
-    echo "             Checking backend: ${BACKEND}"
-    echo "==============================================================================================="
+    echo "Checking backend: ${BACKEND}"
 
     set +e
     if [[ ${BACKEND} == "mysql" ]]; then
@@ -92,9 +86,7 @@ if [[ -n ${BACKEND:=} ]]; then
             exit 1
         fi
         MAX_CHECK=60
-        echo
         echo "Checking if MySQL is ready for connections (double restarts in the logs)"
-        echo
         while true
         do
             CONNECTION_READY_MESSAGES=$(docker logs "${MYSQL_CONTAINER}" 2>&1 | \
@@ -155,12 +147,6 @@ if [[ -n ${BACKEND:=} ]]; then
         fi
     done
     set -e
-    if [[ ${RES} == 0 ]]; then
-        echo "==============================================================================================="
-        echo "             Backend database is sane"
-        echo "==============================================================================================="
-        echo
-    fi
     export EXIT_CODE=${RES}
 else
     echo "==============================================================================================="
@@ -169,11 +155,6 @@ else
     echo
 fi
 
-echo "==============================================================================================="
-echo "             Checking integrations"
-echo "==============================================================================================="
-
-
 check_integration kerberos "nc -zvv kerberos 88" 30
 check_integration mongo "nc -zvv mongo 27017" 20
 check_integration redis "nc -zvv redis 6379" 20
@@ -181,13 +162,9 @@ check_integration rabbitmq "nc -zvv rabbitmq 5672" 20
 check_integration cassandra "nc -zvv cassandra 9042" 20
 check_integration openldap "nc -zvv openldap 389" 20
 
-echo "==============================================================================================="
-echo "             Finished checking integrations"
-echo "==============================================================================================="
-
 if [[ ${EXIT_CODE} != 0 ]]; then
     echo
-    echo "CI environment is not sane!"
+    echo "Error: some of the CI environment failed to initialize!"
     echo
     exit ${EXIT_CODE}
 fi
@@ -196,11 +173,6 @@ if [[ ${DISABLED_INTEGRATIONS} != "" ]]; then
     echo
     echo "Disabled integrations:${DISABLED_INTEGRATIONS}"
     echo
-    echo "You can enable an integration by adding --integration <INTEGRATION_NAME>"
-    echo "You can enable all integrations by adding --integration all"
+    echo "Enable them via --integration <INTEGRATION_NAME> flags (you can use 'all' for all)"
     echo
 fi
-
-echo
-echo "CI environment is sane!"
-echo
diff --git a/scripts/ci/in_container/entrypoint_ci.sh b/scripts/ci/in_container/entrypoint_ci.sh
index bf1cbbb1bbb59..825adc3d8a533 100755
--- a/scripts/ci/in_container/entrypoint_ci.sh
+++ b/scripts/ci/in_container/entrypoint_ci.sh
@@ -15,7 +15,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-if [[ ${AIRFLOW_CI_VERBOSE:="false"} == "true" ]]; then
+if [[ ${AIRFLOW_CI_VERBOSE} == "true" ]]; then
     set -x
 fi
 
@@ -30,7 +30,6 @@ PYTHON_VERSION=${PYTHON_VERSION:=3.6}
 BACKEND=${BACKEND:=sqlite}
 KUBERNETES_MODE=${KUBERNETES_MODE:=""}
 KUBERNETES_VERSION=${KUBERNETES_VERSION:=""}
-RECREATE_KIND_CLUSTER=${RECREATE_KIND_CLUSTER:="true"}
 ENABLE_KIND_CLUSTER=${ENABLE_KIND_CLUSTER:="false"}
 RUNTIME=${RUNTIME:=""}
 
diff --git a/scripts/ci/in_container/kubernetes/app/deploy_app.sh b/scripts/ci/in_container/kubernetes/app/deploy_app.sh
index 47385a960d353..cabded8abbb43 100755
--- a/scripts/ci/in_container/kubernetes/app/deploy_app.sh
+++ b/scripts/ci/in_container/kubernetes/app/deploy_app.sh
@@ -49,9 +49,9 @@ export BUILD_DIRNAME="${MY_DIR}/build"
 
 # Source branch will be set in DockerHub
 SOURCE_BRANCH=${SOURCE_BRANCH:=${DEFAULT_BRANCH}}
-# if AIRFLOW_CONTAINER_BRANCH_NAME is not set it will be set to either SOURCE_BRANCH (if overridden)
+# if BRANCH_NAME is not set it will be set to either SOURCE_BRANCH (if overridden)
 # or default branch for the sources
-AIRFLOW_CONTAINER_BRANCH_NAME=${AIRFLOW_CONTAINER_BRANCH_NAME:=${SOURCE_BRANCH}}
+BRANCH_NAME=${BRANCH_NAME:=${SOURCE_BRANCH}}
 
 if [[ ! -d "${BUILD_DIRNAME}" ]]; then
     mkdir -p "${BUILD_DIRNAME}"
@@ -73,7 +73,7 @@ else
     CONFIGMAP_DAGS_VOLUME_CLAIM=
 fi
 
-if [[ ${TRAVIS_PULL_REQUEST} != "" && ${TRAVIS_PULL_REQUEST} != "false" ]]; then
+if [[ ${TRAVIS_PULL_REQUEST:=} != "" && ${TRAVIS_PULL_REQUEST} != "false" ]]; then
     CONFIGMAP_GIT_REPO=${TRAVIS_PULL_REQUEST_SLUG}
     CONFIGMAP_BRANCH=${TRAVIS_PULL_REQUEST_BRANCH}
 else
diff --git a/scripts/ci/in_container/kubernetes/setup_kind_cluster.sh b/scripts/ci/in_container/kubernetes/setup_kind_cluster.sh
index 96189371b8177..b4bdf7632c531 100755
--- a/scripts/ci/in_container/kubernetes/setup_kind_cluster.sh
+++ b/scripts/ci/in_container/kubernetes/setup_kind_cluster.sh
@@ -23,8 +23,6 @@ AIRFLOW_SOURCES=$(
 )
 export AIRFLOW_SOURCES
 
-export RECREATE_KIND_CLUSTER=${RECREATE_KIND_CLUSTER:="true"}
-
 # We keep _utils here because we are not in the in_container directory
 # shellcheck source=scripts/ci/in_container/_in_container_utils.sh
 . "${MY_DIR}/../_in_container_utils.sh"
diff --git a/tests/bats/test_breeze_params.bats b/tests/bats/test_breeze_params.bats
index c16c86aae1ab4..574fabdbdc4b9 100644
--- a/tests/bats/test_breeze_params.bats
+++ b/tests/bats/test_breeze_params.bats
@@ -32,7 +32,7 @@ teardown() {
 @test "Test missing value for a parameter" {
   load bats_utils
   export _BREEZE_ALLOWED_TEST_PARAMS=" a b c "
-  run check_for_allowed_params "TEST_PARAM"  "Test Param" "--message"
+  run check_and_save_allowed_param "TEST_PARAM"  "Test Param" "--message"
   diff <(echo "${output}") - <<EOF
 
 ERROR:  Allowed Test Param: [ a b c ]. Is: ''.
@@ -50,7 +50,7 @@ EOF
   export _BREEZE_ALLOWED_TEST_PARAMS=" a b c "
   export TEST_PARAM=x
   echo "a" > "${AIRFLOW_SOURCES}/.build/.TEST_PARAM"
-  run check_for_allowed_params "TEST_PARAM"  "Test Param" "--message"
+  run check_and_save_allowed_param "TEST_PARAM"  "Test Param" "--message"
   diff <(echo "${output}") - <<EOF
 
 ERROR:  Allowed Test Param: [ a b c ]. Is: 'x'.
@@ -70,7 +70,7 @@ EOF
   export _BREEZE_ALLOWED_TEST_PARAMS=" a b c "
   export TEST_PARAM=x
   echo "x" > "${AIRFLOW_SOURCES}/.build/.TEST_PARAM"
-  run check_for_allowed_params "TEST_PARAM"  "Test Param" "--message"
+  run check_and_save_allowed_param "TEST_PARAM"  "Test Param" "--message"
   diff <(echo "${output}") - <<EOF
 
 ERROR:  Allowed Test Param: [ a b c ]. Is: 'x'.
@@ -91,7 +91,7 @@ EOF
 
   export _BREEZE_ALLOWED_TEST_PARAMS=" a b c "
   export TEST_PARAM=a
-  run check_for_allowed_params "TEST_PARAM"  "Test Param" "--message"
+  run check_and_save_allowed_param "TEST_PARAM"  "Test Param" "--message"
   diff <(echo "${output}") <(echo "")
   [ -f "${AIRFLOW_SOURCES}/.build/.TEST_PARAM" ]
   diff <(echo "a") <(cat "${AIRFLOW_SOURCES}/.build/.TEST_PARAM")
