Skip to content

Commit a82d3c0

Browse files
chore: change behavior of filtered versions for restricted env. (#1480)
* chore: change filtered versions for restricted env. behaviour * Fix ShellCheck * Resolve review comments Co-Authored-By: Fortune Ndlovu <fndlovu@redhat.com> --------- Co-authored-by: Fortune Ndlovu <fndlovu@redhat.com>
1 parent 3758eb7 commit a82d3c0

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.rhdh/scripts/prepare-restricted-environment.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ IS_HOSTED_CONTROL_PLANE=""
1515

1616
NAMESPACE_OPERATOR="rhdh-operator"
1717
INDEX_IMAGE="registry.redhat.io/redhat/redhat-operator-index:v4.18"
18-
FILTERED_VERSIONS=(1.4 1.5)
18+
FILTERED_VERSIONS=(*)
1919

2020
# assume mikefarah version of yq is already available on the path; if 1, then install the version shown
2121
INSTALL_YQ=0
@@ -77,8 +77,9 @@ Options:
7777
--index-image <operator-index-image> : Operator index image (default: $INDEX_IMAGE)
7878
--ci-index <true|false> : Indicates that the index image is a CI build. Unsupported.
7979
Setting this to 'true' causes the script to replace all references to the internal RH registries
80-
with quay.io when mirroring images. Relevant only if '--use-oc-mirror' is 'false'. Default: false
81-
--filter-versions <list> : Comma-separated list of operator minor versions to keep in the catalog (default: $FILTERED_VERSIONS_CSV).
80+
with quay.io when mirroring images. Relevant only if '--use-oc-mirror' is 'false'.
81+
When set to 'true', --filter-versions must be explicitly specified. Default: false
82+
--filter-versions <list> : Comma-separated list of operator minor versions to keep in the catalog (default: * (all versions)).
8283
Specify '*' to disable version filtering and include all channels and all versions.
8384
Useful for CI index images for example.
8485
--to-registry <registry_url> : Mirror the images into the specified registry, assuming you are already logged into it.
@@ -131,7 +132,8 @@ Examples:
131132
# because it detected that it is connected to an OCP cluster.
132133
# It will automatically replace all references to the internal RH registries with quay.io
133134
$0 \\
134-
--ci-index true
135+
--ci-index true \\
136+
--filter-versions '1.4,1.5'
135137
"
136138
}
137139

@@ -147,6 +149,7 @@ OC_MIRROR_PATH="oc-mirror"
147149
OC_MIRROR_FLAGS=""
148150

149151
NO_VERSION_FILTER="false"
152+
FILTER_VERSIONS_PROVIDED="false"
150153

151154
# example usage:
152155
# ./prepare-restricted-environment.sh \
@@ -181,6 +184,7 @@ while [[ "$#" -gt 0 ]]; do
181184
shift 1
182185
;;
183186
'--prod_operator_version')
187+
FILTER_VERSIONS_PROVIDED="true"
184188
input="${2#v}"
185189
IFS='.' read -ra parts <<<"$input"
186190
length=${#parts[@]}
@@ -203,6 +207,7 @@ while [[ "$#" -gt 0 ]]; do
203207
shift 1
204208
;;
205209
'--filter-versions')
210+
FILTER_VERSIONS_PROVIDED="true"
206211
if [[ "$2" == "*" ]]; then
207212
NO_VERSION_FILTER="true"
208213
else
@@ -349,6 +354,12 @@ if [[ -n "${FROM_DIR}" && -z "${TO_REGISTRY}" ]]; then
349354
errorf "--to-registry is needed when --from-dir is specified."
350355
exit 1
351356
fi
357+
if [[ "${IS_CI_INDEX_IMAGE}" == "true" ]]; then
358+
if [[ "${FILTER_VERSIONS_PROVIDED}" == "false" ]]; then
359+
errorf "When --ci-index is true, --filter-versions must be specified."
360+
exit 1
361+
fi
362+
fi
352363

353364
if [[ -n "${TO_DIR}" ]]; then
354365
mkdir -p "${TO_DIR}"

0 commit comments

Comments
 (0)