From d0c7c5ab3e908245b52ad7f6ecf1651578578376 Mon Sep 17 00:00:00 2001 From: Humair Khan Date: Tue, 15 Aug 2023 15:59:10 -0400 Subject: [PATCH] Add params --override feature. This feature is included to provide flexibility in overriding params.env with image digests instead of tags. Signed-off-by: Humair Khan --- config/base/params.env | 2 +- scripts/release/README.md | 3 ++- scripts/release/params.py | 32 ++++++++++++++++++++++++-------- scripts/release/release.py | 8 +++++++- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/config/base/params.env b/config/base/params.env index 4c353ea7..499233cb 100644 --- a/config/base/params.env +++ b/config/base/params.env @@ -9,4 +9,4 @@ IMAGES_DSPO=quay.io/opendatahub/data-science-pipelines-operator:latest IMAGES_CACHE=registry.access.redhat.com/ubi8/ubi-minimal:8.8 IMAGES_MOVERESULTSIMAGE=registry.access.redhat.com/ubi8/ubi-micro:8.8 IMAGES_MARIADB=registry.redhat.io/rhel8/mariadb-103:1 -IMAGES_OAUTHPROXY=registry.redhat.io/openshift4/ose-oauth-proxy:v4.10 +IMAGES_OAUTHPROXY=registry.redhat.io/openshift4/ose-oauth-proxy@sha256:ab112105ac37352a2a4916a39d6736f5db6ab4c29bad4467de8d613e80e9bb33 diff --git a/scripts/release/README.md b/scripts/release/README.md index 46da5bcf..869e8073 100644 --- a/scripts/release/README.md +++ b/scripts/release/README.md @@ -10,7 +10,8 @@ digests will be used. The following command will generate the `params.env`: **Pre-condition**: All DSP/DSPO images should have been build with tag ``` -python release.py params --tag --out_file params.env +python release.py params --tag v1.2.0 --out_file params.env \ + --override="IMAGES_OAUTHPROXY=registry.redhat.io/openshift4/ose-oauth-proxy@sha256:ab112105ac37352a2a4916a39d6736f5db6ab4c29bad4467de8d613e80e9bb33" ``` See `--help` for more options like specifying tags for images not tied to DSP (ubi, mariadb, oauth proxy, etc.) diff --git a/scripts/release/params.py b/scripts/release/params.py index 33acaf31..7d3f64f9 100644 --- a/scripts/release/params.py +++ b/scripts/release/params.py @@ -80,14 +80,27 @@ def generate_params(args): mariadb_tag = args.mariadb_tag oauth_proxy_tag = args.oauth_proxy_tag - images = [] + # Structure: { "ENV_VAR": "IMG_DIGEST",...} + overrides = {} + for override in args.overrides: + entry = override.split('=') + if len(entry) != 2: + print("--override values must be of the form var=digest,\n" + "e.g: IMAGES_OAUTHPROXY=registry.redhat.io/openshift4/ose-oauth-proxy" + "@sha256:ab112105ac37352a2a4916a39d6736f5db6ab4c29bad4467de8d613e80e9bb33", file=sys.stderr) + exit(1) + overrides[entry[0]] = entry[1] + images = [] # Fetch QUAY Images for image_env_var in QUAY_REPOS: - image_repo = QUAY_REPOS[image_env_var] - digest = fetch_quay_repo_tag_digest(image_repo, quay_org, tag) - image_repo_with_digest = f"{image_repo}:{digest}" - images.append(f"{image_env_var}=quay.io/opendatahub/{image_repo_with_digest}") + if image_env_var in overrides: + images.append(f"{image_env_var}={overrides[image_env_var]}") + else: + image_repo = QUAY_REPOS[image_env_var] + digest = fetch_quay_repo_tag_digest(image_repo, quay_org, tag) + image_repo_with_digest = f"{image_repo}@{digest}" + images.append(f"{image_env_var}=quay.io/opendatahub/{image_repo_with_digest}") # Fetch RH Registry images rh_registry_images = { @@ -118,9 +131,12 @@ def generate_params(args): } for registry in rh_registry_images: for img in rh_registry_images[registry]: - env, tag, repo = img['env'], img['tag'], img['repo'] - digest = fetch_rh_repo_tag_digest(repo, tag) - images.append(f"{env}={registry}/{repo}/{digest}") + image_env_var, tag, repo = img['env'], img['tag'], img['repo'] + if image_env_var in overrides: + images.append(f"{image_env_var}={overrides[image_env_var]}") + else: + digest = fetch_rh_repo_tag_digest(repo, tag) + images.append(f"{image_env_var}={registry}/{repo}@{digest}") with open(file_out, 'w') as f: for images in images: diff --git a/scripts/release/release.py b/scripts/release/release.py index 66a075bf..5f82a098 100755 --- a/scripts/release/release.py +++ b/scripts/release/release.py @@ -15,7 +15,7 @@ def main(): parser_params = subparsers.add_parser('params', help='Params.env generator inputs') parser_params.set_defaults(func=generate_params) parser_params.add_argument('--tag', type=str, required=True, help='Tag for which to fetch image digests for.') - parser_params.add_argument('--quay_org', default="opendatahub-io", type=str, + parser_params.add_argument('--quay_org', default="opendatahub", type=str, help='Tag for which to fetch image digests for.') parser_params.add_argument('--out_file', default='params.env', type=str, help='File path output for params.env') parser_params.add_argument("--ubi-minimal", dest="ubi_minimal_tag", default="8.8", @@ -27,6 +27,12 @@ def main(): parser_params.add_argument("--oauthproxy", dest="oauth_proxy_tag", default="v4.10", help="oauthproxy version tag in rh registry") + parser_params.add_argument("--override", dest="overrides", + help="Override an env var with a manually submitted digest " + "entry of the form --overide=\"ENV_VAR=DIGEST\". Can be " + "used for multiple entries by using --override multiple times.", + action='append') + # Version Compatibility Matrix doc generator parser_vd = subparsers.add_parser('version_doc', help='Version Compatibility Matrix doc generator') parser_vd.set_defaults(func=version_doc)