Story #2368
closedAs a user, I want to provide synced images with multiple "/" in them.
0%
Description
Note that docker/distribution and openshift/registry both now support more than two parts to images. In katello I would like to sync "openshift3/node" and then provide it at "examplecorp/myproduct/openshift3/node" (or any other name).
Updated by semyers over 6 years ago
- Tracker changed from Issue to Story
- % Done set to 0
Do you know of any documentation from docker (dockermentation) about this to help with the implementation?
Updated by amacdona@redhat.com over 6 years ago
Which Pulp field(s) needs to support multiple "/"'s? I can't tell if you mean the `repo_id`, the `upstream-name` or something else.
Updated by semyers over 6 years ago
Austin identified this as the limiting factor here:
https://github.com/pulp/pulp_docker/blob/0381e9ecd0a46c05f83bb20d4e584ad7fa81893e/plugins/pulp_docker/plugins/distributors/configuration.py#L317
This should allow for any number of 'slashed' components, while still validating each part:
all(re.match(r"^[a-z0-9-_.]*$", piece) for piece in docker_id.split('/'))
That said, it would (still) be helpful to see docker-docs about what may have change with regard to the validity/invalidity of repo names.
Updated by tomckay@redhat.com over 6 years ago
https://github.com/docker/distribution/blob/master/docs/spec/api.md#overview
- A repository name is broken up into path components. A component of a repository name must be at least one lowercase, alpha-numeric characters, optionally separated by periods, dashes or underscores. More strictly, it must match the regular expression [a-z0-9]+(?:[._-][a-z0-9]+)*.
- If a repository name has two or more path components, they must be separated by a forward slash ("/").
- The total length of a repository name, including slashes, must be less than 256 characters.
Updated by mhrivnak over 6 years ago
This may also requires changes to crane. Its v2 endpoints may also assume only one slash.
I'm surprised to see this ability, and I wonder if it gets much use in the wild, but sure enough it does work!
[mhrivnak@dhcp129-40 devel]$ sudo docker tag centos:7 foo/bar/baz
[mhrivnak@dhcp129-40 devel]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7 980e0e4c79ec 7 weeks ago 196.7 MB
foo/bar/baz latest 980e0e4c79ec 7 weeks ago 196.7 MB
Updated by semyers over 6 years ago
Given the rules in comment 4, this validation is insufficient:
semyers wrote:
all(re.match(r"^[a-z0-9-_.]*$", piece) for piece in docker_id.split('/'))
I put together this little script along with the regex provided in that comment to check "good" and "bad" docker repo names are correctly classified:
import re
good = (
'this-is-good',
'this/is/good',
'this-is/good',
)
bad = (
'bad' * 256, # 'bad' repeated 256 times, 768 chars total
'.bad',
'_bad',
'-bad',
)
component_re = re.compile('[a-z0-9]+(?:[._-][a-z0-9]+)*')
def validate(name):
# good names return True, bad names return False
if len(name) >= 256:
return False
for piece in name.split('/'):
if not re.match(component_re, piece):
return False
return True
# The one-liner version:
# return len(name) < 256 and all(re.match(component_re, piece) for piece in name.split('/'))
assert all(map(validate, good))
assert not any(map(validate, bad))
The provided regex along with the body of the validate function, appears to correctly validate according to those rules. Add more strings to the "good" and "bad" tuples as desired to prove the validation to your satisfaction.
Added by thomasmckay about 6 years ago
Updated by semyers about 6 years ago
- Status changed from NEW to MODIFIED
- Assignee set to tomckay@redhat.com
This fix was POSTed by Thomas Mckay, in PR https://github.com/pulp/pulp_docker/pull/189, which was then merged to docker master in https://github.com/pulp/pulp_docker/commit/4276534ca77e564a74f5a97374df629dfed61094
Updated by pcreech about 6 years ago
- Platform Release set to 2.13.0
- Target Release - Docker set to 2.4.0
Updated by Ichimonji10 about 6 years ago
Fully verified against Pulp 2.13 beta on F24. Partially verified against F25 and RHEL 7.
To verify, I created, synced and published three repositories. The three repositories had their repo_registry_id
options set to one, two and three-segment values. Crane successfully presented information about the three repositories. On F24, I also successfully executed docker pull localhost:5000/{repo_registry_id}
for all three repositories.
Updated by pcreech about 6 years ago
- Status changed from 5 to CLOSED - CURRENTRELEASE
provide synced images with multiple "/" in them.
https://pulp.plan.io/issues/2368