-
Notifications
You must be signed in to change notification settings - Fork 950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: support set default registry #617
feature: support set default registry #617
Conversation
Signed-off-by: zeppp <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #617 +/- ##
==========================================
- Coverage 13.36% 12.87% -0.49%
==========================================
Files 65 64 -1
Lines 3599 3564 -35
==========================================
- Hits 481 459 -22
+ Misses 3068 3055 -13
Partials 50 50
Continue to review full report at Codecov.
|
LGTM |
Hi, @zeppp Could you make DefaultRegistry as a flag in pouchd's to support this, and pass this configuration when initializing the image manager in daemon side? |
ae2f873
to
c2a0213
Compare
597ac68
to
0c50b7f
Compare
0c50b7f
to
7967e6f
Compare
Thanks a lot for the change.
|
7967e6f
to
6ed4c29
Compare
Updated @allencloud |
// FIXME: need refactor this function. | ||
// addRegistry add default registry if needed. | ||
func (mgr *ImageManager) addRegistry(input string) string { | ||
if strings.Contains(input, "/") || isNumericID(input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I am afraid we can improve this part. Let me introduce one example, pouch pull allencloud/mysql; if I set the registry to be 12.12.12.12:4567
, then I suppose to pull 12.12.12.12:4567/allencloud/mysql
. But code here would ignore this, I think. @zeppp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should be improved indeed, i agree. But, in fact, when you pull allencloud/mysql
, it will not add a registry because the input contains "/". So, you will get allencloud/mysql
. Only when you pull image by RepoName like mysql
, it will add the registry you set. @allencloud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact, when you pull allencloud/mysql, it will not add a registry because the input contains "/". So, you will get allencloud/mysql
My point is that allencloud/mysql
does not include a default registry, if we add a function addRegistry
, maybe we should add default registry for allencloud/mysql
, right?
If you agree with this, this is a part of work we need to finish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I got it. This function addRegistry
need be refactored while I have no idea about that. @allencloud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zeppp , could we follow the routine like this?
if isNumberID(ref) {
return ref
}
host, remainder := splitDomainHost(ref)
if host.PrefixContain(registry) {
return ref
} else {
return registry + ":" + ref
}
I checked the oci-image-spec and found that there is no definition about host....
Maybe we need to make rule in splitDomainHost
to define what is host.....
how do you think?
cc @allencloud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a better way. I will update soon. @0x04C2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the oci-image-spec and found that there is no definition about host....
@0x04C2 @zeppp I agree with that we should split the host thing. In addition, could we refactor reference package to define:
type Ref struct{
Registry string
Namespace string
ImageName string
Tag string
}
for example:
input | registry | namespace | name | tag |
---|---|---|---|---|
docker.io/library/nginx:alpine | docker.io | library | nginx | latest |
localhost:80/nginx:alpine | localhost:80 | nginx | alpine | |
mysql | mysql | latest |
If we make it, in every place we can use this Ref
, and we use the same standard definition when communicating in different modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that, could you help to refactor pkg reference? @0x04C2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. will do
Signed-off-by: zeppp <[email protected]>
6ed4c29
to
6f0d2f0
Compare
Could you share more with us the reason why refactoring reference package? @zeppp |
Currently, we use reference package to parse a string into reference. Users may pull or remove image by its full name, repo name,ID,digest like"sha256:2a56...", but the funcion |
Sorry for the late reply. I followed the oci-image-spec and our backend containerd to implement The
@zeppp and @allencloud what do you think? One more question, the |
This flag |
OK. @allencloud For pouchd, it's easy to handle this. If handle this in pouch, we may involve something like So Let's go ahead. please forget it. haha. |
Hi, @0x04C2 I have seen your PR. That is a really good one we need. While I have some information to share with you. This PR is blocking lots of CRI implementation developing. Currently, we have tested this pr, although it still needs improvement, it works fine for the CRI related thing. So, I am afraid we will first merge this PR to make CRI related things move on. After that, you have to rebase to the latest master if it is. Sorry for the bothering brought to you. |
LGTM |
No problem. Will do |
Signed-off-by: zeppp [email protected]
1.Describe what this PR did
Now,pouch support setting default registry and pulling image without registry.
If the image has no prefix,pouch will add a default prefix "registry.hub.docker.com/library/".
2.Does this pull request fix one issue?
fixes part of #589
3.Describe how you did it
4.Describe how to verify it
5.Special notes for reviews
The reference package need to be refactored in the future since it has weak function.
@allencloud