Skip to content

Commit

Permalink
[AIRFLOW-7015] Detect Dockerhub repo/user when building on Dockerhub (#…
Browse files Browse the repository at this point in the history
…7673)

(cherry picked from commit e2711af)
  • Loading branch information
potiuk authored and kaxil committed Mar 19, 2020
1 parent 1636165 commit 509fa1d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 109 deletions.
104 changes: 0 additions & 104 deletions common/_autodetect_variables.sh

This file was deleted.

35 changes: 35 additions & 0 deletions common/_image_variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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=common/_default_branch.sh
. "${AIRFLOW_SOURCES}/common/_default_branch.sh"

# You can override DOCKERHUB_USER to use your own DockerHub account and play with your
# own docker images. In this case you can build images locally and push them
export DOCKERHUB_USER=${DOCKERHUB_USER:="apache"}

# You can override DOCKERHUB_REPO to use your own DockerHub repository and play with your
# own docker images. In this case you can build images locally and push them
export DOCKERHUB_REPO=${DOCKERHUB_REPO:="airflow"}

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

# read branch name from what has been set from sources (It can also be overridden)
export BRANCH_NAME=${BRANCH_NAME:=${SOURCE_BRANCH}}
4 changes: 2 additions & 2 deletions scripts/ci/_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function initialize_breeze_environment {
mkdir -p "${AIRFLOW_SOURCES}/files"
mkdir -p "${AIRFLOW_SOURCES}/dist"

# shellcheck source=common/_autodetect_variables.sh
. "${AIRFLOW_SOURCES}/common/_autodetect_variables.sh"
# shellcheck source=common/_image_variables.sh
. "${AIRFLOW_SOURCES}/common/_image_variables.sh"
# shellcheck source=common/_files_for_rebuild_check.sh
. "${AIRFLOW_SOURCES}/common/_files_for_rebuild_check.sh"

Expand Down
23 changes: 22 additions & 1 deletion scripts/ci/ci_build_dockerhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,36 @@ if [[ "${TRAVIS_EVENT_TYPE:=}" == "cron" ]]; then
export PULL_BASE_IMAGES="true"
fi

if [[ -z ${DOCKER_REPO} ]]; then
echo
echo "Error! Missing DOCKER_REPO environment variable"
echo "Please specify DOCKER_REPO variable following the pattern HOST/DOCKERHUB_USER/DOCKERHUB_REPO"
echo
exit 1
else
echo "DOCKER_REPO=${DOCKER_REPO}"
fi

[[ ${DOCKER_REPO:=} =~ [^/]*/([^/]*)/([^/]*) ]] && \
export DOCKERHUB_USER=${BASH_REMATCH[1]} &&
export DOCKERHUB_REPO=${BASH_REMATCH[2]}

echo
echo "DOCKERHUB_USER=${DOCKERHUB_USER}"
echo "DOCKERHUB_REPO=${DOCKERHUB_REPO}"
echo

if [[ -z ${DOCKER_TAG:=} ]]; then
echo
echo "Error! Missing DOCKER_TAG environment variable"
echo "Please specify DOCKER_TAG variable following the pattern BRANCH-pythonX.Y[-ci]"
echo
exit 1
else
echo "DOCKER_TAG=${DOCKER_TAG}"
fi

[[ ${DOCKER_TAG:=} =~ ${DEFAULT_BRANCH}-python([0-9.]*) ]] && export PYTHON_VERSION=${BASH_REMATCH[1]}
[[ ${DOCKER_TAG:=} =~ ${DEFAULT_BRANCH}-python([0-9.]*)(.*) ]] && export PYTHON_VERSION=${BASH_REMATCH[1]}

if [[ -z ${PYTHON_VERSION:=} ]]; then
echo
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/in_container/kubernetes/app/deploy_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ trap in_container_script_end EXIT
export TEMPLATE_DIRNAME="${MY_DIR}/templates"
export BUILD_DIRNAME="${MY_DIR}/build"

# shellcheck source=common/_autodetect_variables.sh
. "${AIRFLOW_SOURCES}/common/_autodetect_variables.sh"
# shellcheck source=common/_image_variables.sh
. "${AIRFLOW_SOURCES}/common/_image_variables.sh"

# Source branch will be set in DockerHub
SOURCE_BRANCH=${SOURCE_BRANCH:=${DEFAULT_BRANCH}}
Expand Down

0 comments on commit 509fa1d

Please sign in to comment.