ods-jenkins-shared-library
ods-jenkins-shared-library copied to clipboard
odsComponentStageCopyImage fails for some sourceImageUrlIncludingRegistry strings
Describe the bug We import images from a private registry. Unfortunately some images are in the following format:
private-registry.com/kong:3.0.1
The component fails in this case because it prepends the internal registry:
skopeo copy --src-tls-verify=false --src-creds user@....:**** docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1 --dest-creds
If an image is provided in the following format, the component is successful:
private-registry.com/repo/kong:3.0.1
To Reproduce Steps to reproduce the behavior:
Use [REGISTRY/]IMAGE[:TAG]
Expected behavior
Allow [REGISTRY/]IMAGE[:TAG] and [REGISTRY/]REPO/IMAGE[:TAG]
Log Output (ensure to remove any confidential information like tokens, project names, etc.
+ skopeo copy --src-tls-verify=false --src-creds [email protected]:**** docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1 --dest-creds openshift:... docker://image-registry.openshift-image-registry.svc:5000/pames-cd/kong:3.0.1 --dest-tls-verify=false
time="2024-10-28T10:14:18Z" level=fatal msg="initializing source docker://image-registry.openshift-image-registry.svc:5000/private-registry.com/kong:3.0.1: unable to retrieve auth token: invalid username/password: authentication required"
Additional context https://github.com/opendevstack/ods-jenkins-shared-library/issues/1119
According to the parameter description this is not a bug.
sourceImageUrlIncludingRegistryString | Source image to importThis needs to be in the following format: [REGISTRY/]REPO/IMAGE[:TAG]
Nevertheless I'd agree that a source format of type [REGISTRY/]IMAGE[:TAG] might be possible.
Following code section builds the given string, derived from the requirement to use [REGISTRY/]REPO/IMAGE[:TAG].
This means a pattern of stringA/stringB is read as:
stringA => repo
stringB => image:tag
(and registry is set to the internal).
https://github.com/opendevstack/ods-jenkins-shared-library/blob/master/vars/odsComponentStageCopyImage.groovy#L21-L35
A possible solution could be to check if stringA consists of two elements if split by "." (dot).
I've created a demo code however I'm not sure if this is intended.
@tbugfinder thank you for taking care of this so quickly. Idea/question: wouldn't it make sense to provide registry, repo, image, tag individually for source and target instead of in a single string?
Well, most often I find myself just copy/paste those image strings from the registries.