This repository has been archived by the owner on Feb 19, 2021. It is now read-only.
forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
breeze-complete
311 lines (284 loc) · 8.11 KB
/
breeze-complete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#!/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.
_BREEZE_ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS="2.7 3.5 3.6 3.7 3.8"
_BREEZE_ALLOWED_BACKENDS="sqlite mysql postgres"
_BREEZE_ALLOWED_INTEGRATIONS="cassandra kerberos mongo openldap presto rabbitmq redis all"
_BREEZE_ALLOWED_KUBERNETES_MODES="image git"
_BREEZE_ALLOWED_KUBERNETES_VERSIONS="v1.18.6 v1.17.5 v1.16.9"
_BREEZE_ALLOWED_HELM_VERSIONS="v3.2.4"
_BREEZE_ALLOWED_KIND_VERSIONS="v0.8.0"
_BREEZE_ALLOWED_MYSQL_VERSIONS="5.7 8"
_BREEZE_ALLOWED_POSTGRES_VERSIONS="9.6 10"
_BREEZE_ALLOWED_KIND_OPERATIONS="start stop restart status deploy test shell"
_BREEZE_ALLOWED_INSTALL_AIRFLOW_VERSIONS=$(cat <<-EOF
1.10.11
1.10.10
1.10.9
1.10.8
1.10.7
1.10.6
1.10.5
1.10.4
1.10.3
1.10.2
master
v1-10-test
EOF
)
_BREEZE_ALLOWED_STATIC_CHECKS=$(cat <<-EOF
all
all-but-pylint
airflow-config-yaml
base-operator
bat-tests
build
build-providers-dependencies
check-apache-license
check-builtin-literals
check-executables-have-shebangs
check-hooks-apply
check-integrations
check-merge-conflict
check-xml
consistent-pylint
daysago-import-check
debug-statements
detect-private-key
doctoc
dont-use-safe-filter
end-of-file-fixer
fix-encoding-pragma
flake8
forbid-tabs
incorrect-use-of-LoggingMixin
insert-license
isort
language-matters
lint-dockerfile
lint-openapi
mixed-line-ending
mypy
provide-create-sessions
pydevd
pydocstyle
pylint
pylint-tests
python-no-log-warn
rst-backticks
setup-order
shellcheck
stylelint
trailing-whitespace
update-breeze-file
update-extras
update-local-yml-file
update-setup-cfg-file
yamllint
EOF
)
_BREEZE_DEFAULT_DOCKERHUB_USER="apache"
_BREEZE_DEFAULT_DOCKERHUB_REPO="airflow"
_BREEZE_DEFAULT_GITHUB_ORGANISATION="apache"
_BREEZE_DEFAULT_GITHUB_REPO="airflow"
_BREEZE_SHORT_OPTIONS="
h p: b: i:
K: V:
l a: t: d:
v y n q f
F P I E: C
L U X
D: R: c g: G:
S: N:
"
_BREEZE_LONG_OPTIONS="
help python: backend: integration:
kubernetes-mode: kubernetes-version: helm-version: kind-version:
skip-mounting-local-sources install-airflow-version: install-airflow-reference: db-reset
verbose assume-yes assume-no assume-quit forward-credentials
force-build-images force-pull-images production-image extras: force-clean-images
build-cache-local build-cache-pulled build-cache-disabled
dockerhub-user: dockerhub-repo: github-registry github-organisation: github-repo:
postgres-version: mysql-version:
version-suffix-for-pypi: version-suffix-for-svn:
additional-extras: additional-python-deps: additional-dev-deps: additional-runtime-deps:
"
export BREEZE_COMMANDS="
shell
build-docs
build-image
cleanup-image
exec
generate-constraints
push-image
initialize-local-virtualenv
setup-autocomplete
stop
restart
toggle-suppress-cheatsheet
toggle-suppress-asciiart"
export BREEZE_EXTRA_ARG_COMMANDS="
docker-compose
kind-cluster
prepare-backport-readme
prepare-backport-packages
static-check
tests"
export BREEZE_HELP_COMMANDS="
flags
help
help-all"
export ALL_BREEZE_COMMANDS="${BREEZE_COMMANDS} ${BREEZE_EXTRA_ARG_COMMANDS} ${BREEZE_HELP_COMMANDS}"
# Note on OSX bash has no associative arrays (Bash 3.2) so we have to fake it
_BREEZE_KNOWN_VALUES=""
function _get_known_values_breeze() {
case "$1" in
-p | --python)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS}
;;
-b | --backend)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_BACKENDS}
;;
-i | --integration)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_INTEGRATIONS}
;;
-K | --kubernetes-mode)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_KUBERNETES_MODES}
;;
-V | --kubernetes-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_KUBERNETES_VERSIONS}
;;
--kind-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_KIND_VERSIONS}
;;
--helm-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_HELM_VERSIONS}
;;
static-check)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_STATIC_CHECKS}
;;
static-check-all-files)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_STATIC_CHECKS}
;;
-A | --install-airflow-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_INSTALL_AIRFLOW_VERSIONS}
;;
docker-compose)
# shellcheck disable=SC2034
if typeset -f "_docker_compose" >/dev/null; then
_docker_compose
fi
_BREEZE_KNOWN_VALUES=""
;;
--postgres-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_POSTGRES_VERSIONS}
;;
--mysql-version)
_BREEZE_KNOWN_VALUES=${_BREEZE_ALLOWED_MYSQL_VERSIONS}
;;
-D | --dockerhub-user)
_BREEZE_KNOWN_VALUES="${_BREEZE_DEFAULT_DOCKERHUB_USER}"
;;
-R | --dockerhub-repo)
_BREEZE_KNOWN_VALUES="${_BREEZE_DEFAULT_DOCKERHUB_REPO}"
;;
-G | --github-organisation)
_BREEZE_KNOWN_VALUES="${_BREEZE_DEFAULT_GITHUB_ORGANISATION}"
;;
-g | --github-repo)
_BREEZE_KNOWN_VALUES="${_BREEZE_DEFAULT_GITHUB_REPO}"
;;
kind-cluster)
_BREEZE_KNOWN_VALUES="${_BREEZE_ALLOWED_KIND_OPERATIONS}"
;;
*)
_BREEZE_KNOWN_VALUES=""
;;
esac
}
_BREEZE_GETOPT_SHORT_OPTIONS=""
_BREEZE_GETOPT_LONG_OPTIONS=""
function _build_options_breeze {
local SEPARATOR=""
local OPTION
for OPTION in ${_BREEZE_SHORT_OPTIONS}
do
_BREEZE_GETOPT_SHORT_OPTIONS="${_BREEZE_GETOPT_SHORT_OPTIONS}${SEPARATOR}${OPTION}"
SEPARATOR=","
done
SEPARATOR=""
for OPTION in ${_BREEZE_LONG_OPTIONS}
do
_BREEZE_GETOPT_LONG_OPTIONS="${_BREEZE_GETOPT_LONG_OPTIONS}${SEPARATOR}${OPTION}"
SEPARATOR=","
done
}
function _listcontains_breeze {
local WORD
for WORD in $1; do
[[ ${WORD} = "$2" ]] && return 0
done
return 1
}
# A completion function for breeze
function _comp_breeze {
local ALL_OPTIONS=""
local EXTRA_ARG_OPTIONS=""
local OPTION
local GETOPT_OPTION
local LAST_COMMAND_PREFIX
local PREVIOUS_COMMAND
for OPTION in ${_BREEZE_SHORT_OPTIONS}
do
LAST_CHAR="${OPTION:$((${#OPTION} - 1)):1}"
GETOPT_OPTION='-'${OPTION//:/}
if [[ "${LAST_CHAR}" == ":" ]]; then
EXTRA_ARG_OPTIONS="${EXTRA_ARG_OPTIONS} ${GETOPT_OPTION}"
fi
ALL_OPTIONS="${ALL_OPTIONS} ${GETOPT_OPTION}"
done
for OPTION in ${_BREEZE_LONG_OPTIONS}
do
LAST_CHAR="${OPTION:$((${#OPTION} - 1)):1}"
GETOPT_OPTION='--'${OPTION//:/}
ALL_OPTIONS="${ALL_OPTIONS} ${GETOPT_OPTION}"
if [[ "${LAST_CHAR}" == ":" ]]; then
EXTRA_ARG_OPTIONS="${EXTRA_ARG_OPTIONS} ${GETOPT_OPTION}"
fi
done
ALL_OPTIONS="${ALL_OPTIONS} ${ALL_BREEZE_COMMANDS}"
EXTRA_ARG_OPTIONS="${EXTRA_ARG_OPTIONS} ${BREEZE_EXTRA_ARG_COMMANDS}"
LAST_COMMAND_PREFIX="${COMP_WORDS[${COMP_CWORD}]}"
if [[ ${#COMP_WORDS[@]} -gt 1 ]]; then
PREVIOUS_COMMAND="${COMP_WORDS[${COMP_CWORD} - 1]}"
else
PREVIOUS_COMMAND=""
fi
if _listcontains_breeze "${EXTRA_ARG_OPTIONS}" "${PREVIOUS_COMMAND}"; then
COMPREPLY=()
_get_known_values_breeze "${PREVIOUS_COMMAND}"
while IFS='' read -r LINE; do COMPREPLY+=("$LINE"); done \
< <(compgen -W "${_BREEZE_KNOWN_VALUES}" -- "${LAST_COMMAND_PREFIX}")
else
COMPREPLY=()
while IFS='' read -r LINE; do COMPREPLY+=("$LINE"); done \
< <(compgen -W "${ALL_OPTIONS}" -- "${LAST_COMMAND_PREFIX}")
fi
}
_build_options_breeze
complete -F _comp_breeze breeze
complete -F _comp_breeze ./breeze