Skip to content

Commit

Permalink
Add params --override feature.
Browse files Browse the repository at this point in the history
This feature is included to provide flexibility in overriding params.env
with image digests instead of tags.

Signed-off-by: Humair Khan <HumairAK@users.noreply.github.com>
  • Loading branch information
HumairAK committed Aug 15, 2023
1 parent e19cab9 commit d0c7c5a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/base/params.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion scripts/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <DSP_TAG>
```
python release.py params --tag <DSP_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.)
Expand Down
32 changes: 24 additions & 8 deletions scripts/release/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion scripts/release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)
Expand Down

0 comments on commit d0c7c5a

Please sign in to comment.