Skip to content

Commit a32e90a

Browse files
authored
Update github flags for Breeze (#10384)
Part of #10368
1 parent b28ea7a commit a32e90a

File tree

5 files changed

+171
-57
lines changed

5 files changed

+171
-57
lines changed

BREEZE.rst

Lines changed: 82 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,22 @@ This is the current syntax for `./breeze <./breeze>`_:
10991099
especially useful to pass bash options, for example -c to execute command:
11001100
11011101
'breeze shell -- -c "ls -la"'
1102+
'breeze -- -c "ls -la"'
1103+
1104+
For DockerHub pull --dockerhub-user and --dockerhub-repo flags can be used to specify
1105+
the repository to pull from. For GitHub repository, the --github-repository
1106+
flag can be used for the same purpose. You can also use
1107+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to pull the image
1108+
with specific COMMIT_SHA tag or RUN_ID.
1109+
1110+
'breeze shell \
1111+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - pull/use image with SHA
1112+
'breeze \
1113+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - pull/use image with SHA
1114+
'breeze shell \
1115+
--github-image-id 209845560' - pull/use image with RUN_ID
1116+
'breeze \
1117+
--github-image-id 209845560' - pull/use image with RUN_ID
11021118
11031119
Flags:
11041120
@@ -1137,6 +1153,12 @@ This is the current syntax for `./breeze <./breeze>`_:
11371153
11381154
You can also pass '--production-image' flag to build production image rather than CI image.
11391155
1156+
For DockerHub pull --dockerhub-user and --dockerhub-repo flags can be used to specify
1157+
the repository to pull from. For GitHub repository, the --github-repository
1158+
flag can be used for the same purpose. You can also use
1159+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to pull the image with
1160+
specific COMMIT_SHA tag or RUN_ID.
1161+
11401162
Flags:
11411163
11421164
-p, --python <PYTHON_MAJOR_MINOR_VERSION>
@@ -1234,14 +1256,25 @@ This is the current syntax for `./breeze <./breeze>`_:
12341256
12351257
-c, --github-registry
12361258
If GitHub registry is enabled, pulls and pushes are done from the GitHub registry not
1237-
DockerHub. You need to be logged in to the registry in order to be able to pull/push from it
1259+
DockerHub. You need to be logged in to the registry in order to be able to pull/push from
12381260
and you need to be committer to push to Apache Airflow' GitHub registry.
12391261
1240-
-G, --github-organisation
1241-
GitHub organisation used to pull, push images when cache is used. Default: apache.
1262+
-g, --github-repository
1263+
GitHub repository used to pull, push images when cache is used.
1264+
Default: apache/airflow.
1265+
1266+
If you use this flag, automatically --github-registry flag is enabled.
1267+
1268+
-s, --github-image-id <COMMIT_SHA>|<RUN_ID>
1269+
<RUN_ID> or <COMMIT_SHA> of the image. Images in GitHub registry are stored with those
1270+
to be able to easily find the image for particular CI runs. Once you know the
1271+
<RUN_ID> or <COMMIT_SHA>, you can specify it in github-image-id flag and Breeze will
1272+
automatically pull and use that image so that you can easily reproduce a problem
1273+
that occurred in CI.
12421274
1243-
-g, --github-repo
1244-
GitHub repository used to pull, push images when cache is used. Default: airflow.
1275+
If you use this flag, automatically --github-registry is enabled.
1276+
1277+
Default: latest.
12451278
12461279
-v, --verbose
12471280
Show verbose information about executed docker, kind, kubectl, helm commands. Useful for
@@ -1351,8 +1384,11 @@ This is the current syntax for `./breeze <./breeze>`_:
13511384
or to the GitHub registry (if --github-registry flag is used).
13521385
13531386
For DockerHub pushes --dockerhub-user and --dockerhub-repo flags can be used to specify
1354-
the repository to push to. For GitHub repository --github-organisation and --github-repo
1355-
flags can be used for the same purpose.
1387+
the repository to push to. For GitHub repository, the --github-repository
1388+
flag can be used for the same purpose. You can also add
1389+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to push image with specific
1390+
SHA tag or run id. In case you specify --github-repository or --github-image-id, you
1391+
do not need to specify --github-registry flag.
13561392
13571393
You can also add --production-image flag to switch to production image (default is CI one)
13581394
@@ -1362,7 +1398,12 @@ This is the current syntax for `./breeze <./breeze>`_:
13621398
'breeze push-image --dockerhub-user user' to push to your private registry or
13631399
'breeze push-image --production-image' - to push production image or
13641400
'breeze push-image --github-registry' - to push to GitHub image registry or
1365-
'breeze push-image --github-registry --github-organisation org' - for other organisation
1401+
'breeze push-image \
1402+
--github-repository user/airflow' - to push to your user's fork
1403+
'breeze push-image \
1404+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - to push with COMMIT_SHA
1405+
'breeze push-image \
1406+
--github-image-id 209845560' - to push with RUN_ID
13661407
13671408
Flags:
13681409
@@ -1374,14 +1415,25 @@ This is the current syntax for `./breeze <./breeze>`_:
13741415
13751416
-c, --github-registry
13761417
If GitHub registry is enabled, pulls and pushes are done from the GitHub registry not
1377-
DockerHub. You need to be logged in to the registry in order to be able to pull/push from it
1418+
DockerHub. You need to be logged in to the registry in order to be able to pull/push from
13781419
and you need to be committer to push to Apache Airflow' GitHub registry.
13791420
1380-
-G, --github-organisation
1381-
GitHub organisation used to pull, push images when cache is used. Default: apache.
1421+
-g, --github-repository
1422+
GitHub repository used to pull, push images when cache is used.
1423+
Default: apache/airflow.
1424+
1425+
If you use this flag, automatically --github-registry flag is enabled.
13821426
1383-
-g, --github-repo
1384-
GitHub repository used to pull, push images when cache is used. Default: airflow.
1427+
-s, --github-image-id <COMMIT_SHA>|<RUN_ID>
1428+
<RUN_ID> or <COMMIT_SHA> of the image. Images in GitHub registry are stored with those
1429+
to be able to easily find the image for particular CI runs. Once you know the
1430+
<RUN_ID> or <COMMIT_SHA>, you can specify it in github-image-id flag and Breeze will
1431+
automatically pull and use that image so that you can easily reproduce a problem
1432+
that occurred in CI.
1433+
1434+
If you use this flag, automatically --github-registry is enabled.
1435+
1436+
Default: latest.
13851437
13861438
-v, --verbose
13871439
Show verbose information about executed docker, kind, kubectl, helm commands. Useful for
@@ -1547,7 +1599,7 @@ This is the current syntax for `./breeze <./breeze>`_:
15471599
15481600
Manages host-side Kind Kubernetes cluster that is used to run Kubernetes integration tests.
15491601
It allows to start/stop/restart/status the Kind Kubernetes cluster and deploy Airflow to it.
1550-
This enables you to run tests inside the breeze environment with latest airflow images loaded.
1602+
This enables you to run tests inside the breeze environment with latest airflow images.
15511603
Note that in case of deploying airflow, the first step is to rebuild the image and loading it
15521604
to the cluster so you can also pass appropriate build image flags that will influence
15531605
rebuilding the production image. Operation is one of:
@@ -2027,14 +2079,25 @@ This is the current syntax for `./breeze <./breeze>`_:
20272079
20282080
-c, --github-registry
20292081
If GitHub registry is enabled, pulls and pushes are done from the GitHub registry not
2030-
DockerHub. You need to be logged in to the registry in order to be able to pull/push from it
2082+
DockerHub. You need to be logged in to the registry in order to be able to pull/push from
20312083
and you need to be committer to push to Apache Airflow' GitHub registry.
20322084
2033-
-G, --github-organisation
2034-
GitHub organisation used to pull, push images when cache is used. Default: apache.
2085+
-g, --github-repository
2086+
GitHub repository used to pull, push images when cache is used.
2087+
Default: apache/airflow.
2088+
2089+
If you use this flag, automatically --github-registry flag is enabled.
2090+
2091+
-s, --github-image-id <COMMIT_SHA>|<RUN_ID>
2092+
<RUN_ID> or <COMMIT_SHA> of the image. Images in GitHub registry are stored with those
2093+
to be able to easily find the image for particular CI runs. Once you know the
2094+
<RUN_ID> or <COMMIT_SHA>, you can specify it in github-image-id flag and Breeze will
2095+
automatically pull and use that image so that you can easily reproduce a problem
2096+
that occurred in CI.
2097+
2098+
If you use this flag, automatically --github-registry is enabled.
20352099
2036-
-g, --github-repo
2037-
GitHub repository used to pull, push images when cache is used. Default: airflow.
2100+
Default: latest.
20382101
20392102
****************************************************************************************************
20402103
Flags for generation of the backport packages

breeze

Lines changed: 78 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function setup_default_breeze_variables() {
4141
export BREEZE=true
4242
# Maximum screen width to print the lines spanning the whole terminal width
4343
export MAX_SCREEN_WIDTH=100
44-
44+
# By default we build CI images but when we specify `--production-image` we switch to production image
45+
export PRODUCTION_IMAGE="false"
4546
# Directory where all CI scripts are located
4647
export SCRIPTS_CI_DIR="${AIRFLOW_SOURCES}/scripts/ci"
4748

@@ -88,26 +89,27 @@ function setup_default_breeze_variables() {
8889

8990
# Name of the script is kept in this variable
9091
CMDNAME="$(basename -- "$0")"
92+
export CMDNAME
9193

9294
# Update short and long options in the breeze-complete script
9395
# This way autocomplete will work automatically with all options available
9496
# shellcheck source=breeze-complete
9597
. "${AIRFLOW_SOURCES}/breeze-complete"
9698

9799
# By default we mount local Airflow sources
98-
MOUNT_LOCAL_SOURCES="true"
100+
export MOUNT_LOCAL_SOURCES="true"
99101

100102
# By default we mount files folder
101-
MOUNT_FILES="true"
103+
export MOUNT_FILES="true"
102104

103105
# Holds last sub-command used - this is used by --help flag to print help for the command entered
104-
LAST_SUBCOMMAND=""
106+
export LAST_SUBCOMMAND=""
105107

106108
# Determines if help should be run (set to true by --help flag)
107-
RUN_HELP="false"
109+
export RUN_HELP="false"
108110

109111
# Holds docker compose command if the `docker-compose` command is used.
110-
DOCKER_COMPOSE_COMMAND=""
112+
export DOCKER_COMPOSE_COMMAND=""
111113

112114
# If set to true, the docker images are rebuilt locally. By default we assume we do not need to
113115
# rebuild the image but if we find we do, this variable will be set to "true"
@@ -120,9 +122,6 @@ function setup_default_breeze_variables() {
120122
# Do not enable Kind Kubernetes cluster by default
121123
export ENABLE_KIND_CLUSTER="false"
122124

123-
# By default we do not push images. This can be overridden by -u flag.
124-
export PUSH_IMAGES=${PUSH_IMAGES:="false"}
125-
126125
# Forward common host credentials to docker (gcloud, aws etc.).
127126
export FORWARD_CREDENTIALS="false"
128127

@@ -554,7 +553,7 @@ function prepare_command_files() {
554553
"\"\${@}\"" "${COMPOSE_PROD_FILE}" "${AIRFLOW_PROD_IMAGE}"
555554
}
556555

557-
# Prints detailed help for all commands and flgas. Used to generate documentation added to BREEZE.rst
556+
# Prints detailed help for all commands and flags. Used to generate documentation added to BREEZE.rst
558557
# automatically.
559558
function do_help_all() {
560559
echo
@@ -786,17 +785,29 @@ function parse_arguments() {
786785
echo
787786
export USE_GITHUB_REGISTRY="true"
788787
shift ;;
789-
-G|--github-organisation)
788+
-g|--github-repository)
790789
echo
791-
echo "GitHub organisation"
790+
echo "GitHub repository: ${2}"
792791
echo
793-
export GITHUB_ORGANISATION="${2}"
792+
echo "Using github registry."
793+
echo
794+
export GITHUB_REPOSITORY="${2}"
795+
export USE_GITHUB_REGISTRY="true"
794796
shift 2;;
795-
-g|--github-repo)
797+
-s|--github-image-id)
796798
echo
797-
echo "GitHub repository"
799+
echo "GitHub image id: ${2}}"
798800
echo
799-
export GITHUB_REPOSITORY="${2}"
801+
echo "Force pulling the image, using github registry and skip mounting local sources."
802+
echo "This is in order to get the exact same version as used in CI environment for SHA/RUN_ID!."
803+
echo
804+
export FORCE_PULL_IMAGES="true"
805+
export USE_GITHUB_REGISTRY="true"
806+
export GITHUB_REGISTRY_PULL_IMAGE_TAG="${2}"
807+
export GITHUB_REGISTRY_PUSH_IMAGE_TAG="${2}"
808+
export CHECK_IMAGE_FOR_REBUILD="false"
809+
export MOUNT_LOCAL_SOURCES="false"
810+
export SKIP_CHECK_REMOTE_IMAGE="true"
800811
shift 2;;
801812
-S|--version-suffix-for-pypi)
802813
if [[ ${VERSION_SUFFIX_FOR_SVN} != "" ]]; then
@@ -1111,6 +1122,22 @@ ${CMDNAME} shell [FLAGS] [-- <EXTRA_ARGS>]
11111122
especially useful to pass bash options, for example -c to execute command:
11121123
11131124
'${CMDNAME} shell -- -c \"ls -la\"'
1125+
'${CMDNAME} -- -c \"ls -la\"'
1126+
1127+
For DockerHub pull --dockerhub-user and --dockerhub-repo flags can be used to specify
1128+
the repository to pull from. For GitHub repository, the --github-repository
1129+
flag can be used for the same purpose. You can also use
1130+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to pull the image
1131+
with specific COMMIT_SHA tag or RUN_ID.
1132+
1133+
'${CMDNAME} shell \\
1134+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - pull/use image with SHA
1135+
'${CMDNAME} \\
1136+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - pull/use image with SHA
1137+
'${CMDNAME} shell \\
1138+
--github-image-id 209845560' - pull/use image with RUN_ID
1139+
'${CMDNAME} \\
1140+
--github-image-id 209845560' - pull/use image with RUN_ID
11141141
11151142
Flags:
11161143
$(flag_footer)
@@ -1147,6 +1174,12 @@ ${CMDNAME} build-image [FLAGS]
11471174
11481175
You can also pass '--production-image' flag to build production image rather than CI image.
11491176
1177+
For DockerHub pull --dockerhub-user and --dockerhub-repo flags can be used to specify
1178+
the repository to pull from. For GitHub repository, the --github-repository
1179+
flag can be used for the same purpose. You can also use
1180+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to pull the image with
1181+
specific COMMIT_SHA tag or RUN_ID.
1182+
11501183
Flags:
11511184
$(flag_airflow_variants)
11521185
$(flag_choose_different_airflow_version)
@@ -1295,8 +1328,11 @@ ${CMDNAME} push_image [FLAGS]
12951328
or to the GitHub registry (if --github-registry flag is used).
12961329
12971330
For DockerHub pushes --dockerhub-user and --dockerhub-repo flags can be used to specify
1298-
the repository to push to. For GitHub repository --github-organisation and --github-repo
1299-
flags can be used for the same purpose.
1331+
the repository to push to. For GitHub repository, the --github-repository
1332+
flag can be used for the same purpose. You can also add
1333+
--github-image-id <COMMIT_SHA>|<RUN_ID> in case you want to push image with specific
1334+
SHA tag or run id. In case you specify --github-repository or --github-image-id, you
1335+
do not need to specify --github-registry flag.
13001336
13011337
You can also add --production-image flag to switch to production image (default is CI one)
13021338
@@ -1306,7 +1342,12 @@ ${CMDNAME} push_image [FLAGS]
13061342
'${CMDNAME} push-image --dockerhub-user user' to push to your private registry or
13071343
'${CMDNAME} push-image --production-image' - to push production image or
13081344
'${CMDNAME} push-image --github-registry' - to push to GitHub image registry or
1309-
'${CMDNAME} push-image --github-registry --github-organisation org' - for other organisation
1345+
'${CMDNAME} push-image \\
1346+
--github-repository user/airflow' - to push to your user's fork
1347+
'${CMDNAME} push-image \\
1348+
--github-image-id 9a621eaa394c0a0a336f8e1b31b35eff4e4ee86e' - to push with COMMIT_SHA
1349+
'${CMDNAME} push-image \\
1350+
--github-image-id 209845560' - to push with RUN_ID
13101351
13111352
Flags:
13121353
$(flag_pull_push_docker_images)
@@ -1319,7 +1360,7 @@ ${CMDNAME} kind-cluster [FLAGS] OPERATION
13191360
13201361
Manages host-side Kind Kubernetes cluster that is used to run Kubernetes integration tests.
13211362
It allows to start/stop/restart/status the Kind Kubernetes cluster and deploy Airflow to it.
1322-
This enables you to run tests inside the breeze environment with latest airflow images loaded.
1363+
This enables you to run tests inside the breeze environment with latest airflow images.
13231364
Note that in case of deploying airflow, the first step is to rebuild the image and loading it
13241365
to the cluster so you can also pass appropriate build image flags that will influence
13251366
rebuilding the production image. Operation is one of:
@@ -1523,7 +1564,7 @@ ${FORMATTED_MYSQL_VERSIONS}
15231564
"
15241565
}
15251566

1526-
# Prints production image flgas
1567+
# Prints production image flags
15271568
function flag_production_image() {
15281569
echo "
15291570
-I, --production-image
@@ -1737,14 +1778,25 @@ function flag_pull_push_docker_images() {
17371778
17381779
-c, --github-registry
17391780
If GitHub registry is enabled, pulls and pushes are done from the GitHub registry not
1740-
DockerHub. You need to be logged in to the registry in order to be able to pull/push from it
1781+
DockerHub. You need to be logged in to the registry in order to be able to pull/push from
17411782
and you need to be committer to push to Apache Airflow' GitHub registry.
17421783
1743-
-G, --github-organisation
1744-
GitHub organisation used to pull, push images when cache is used. Default: ${_BREEZE_DEFAULT_GITHUB_ORGANISATION:=}.
1784+
-g, --github-repository
1785+
GitHub repository used to pull, push images when cache is used.
1786+
Default: ${_BREEZE_DEFAULT_GITHUB_REPOSITORY:=}.
1787+
1788+
If you use this flag, automatically --github-registry flag is enabled.
1789+
1790+
-s, --github-image-id <COMMIT_SHA>|<RUN_ID>
1791+
<RUN_ID> or <COMMIT_SHA> of the image. Images in GitHub registry are stored with those
1792+
to be able to easily find the image for particular CI runs. Once you know the
1793+
<RUN_ID> or <COMMIT_SHA>, you can specify it in github-image-id flag and Breeze will
1794+
automatically pull and use that image so that you can easily reproduce a problem
1795+
that occurred in CI.
1796+
1797+
If you use this flag, automatically --github-registry is enabled.
17451798
1746-
-g, --github-repo
1747-
GitHub repository used to pull, push images when cache is used. Default: ${_BREEZE_DEFAULT_GITHUB_REPO:=}.
1799+
Default: ${_BREEZE_DEFAULT_GITHUB_IMAGE_ID:=}.
17481800
17491801
"
17501802
}

0 commit comments

Comments
 (0)