-
Notifications
You must be signed in to change notification settings - Fork 546
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
Allow localhost repositories #979
Conversation
`crane ls localhost:5000/something` worked for me after this change. Also a `crane cp`.
@hasheddan was pinged in 840 so pinging him here |
This scares me a little bit but hopefully our tests are sufficient to make this change safely @dekkagaijin |
Okay excellent, the tests did fail. |
So just taking the first error above, when I run it w/o my change: so "sha256:" is inserted in the wrong place. |
@@ -21,7 +21,7 @@ import ( | |||
|
|||
const ( | |||
defaultNamespace = "library" | |||
repositoryChars = "abcdefghijklmnopqrstuvwxyz0123456789_-./" | |||
repositoryChars = "abcdefghijklmnopqrstuvwxyz0123456789_-./:" |
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.
We want the registry to allow :
not the repository right?
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.
Registry delegates the decision making on validity of the "repository" to Repository
This works already, but:
does not, right? |
Correct, but neither does |
There's zero authoritative way to decide if I could make a special case for localhost? |
I don't think that's actually valid, per the distribution spec. Do other tools work with this? |
I'm confused what you mean? I think I should be able to say |
The spec only seems to care about the HTTP request and not what we do on the command line, but I'm probably misunderstanding your statement. |
So we need to translate:
Into some http request to list tags (or anything). That http request looks like this:
And
I guess I'm wondering if you can just do something like:
And have that work? That would be somewhat equivalent to In theory, you may want to pull the tags that come out of that command, but how?
Does this work for anything? |
Looks like not:
|
|
(btw I'm still tracking down the bug and adding in some unit tests, I think I've isolated the problem to |
I think I understand the confusion -- this isn't about listing tags, you're expecting We could print a warning like:
Or even just default to running |
I've also run into a similar situation where I do something like:
Where I obviously mean to do:
But I'm not sure how many of these "do what I mean" niceties we could add before things get unwieldy... |
I assumed |
I'm really just trying to use crane as a library and copy from a registry server on |
It actually fails to parse:
You'd want to use
So unfortunately there's not really a standard way to enumerate repositories and images in a registry. Catalog + tag listing is one way that works for some registries, but only works for tags. GCR does its own thing, which I've tried to push on a standard for this, but it seems like a lost cause: opencontainers/distribution-spec#222 (comment) I think what you want to do, for copying from some registry that supports catalog (don't do this for GCR), is roughly this: srcRegistry := "localhost:5000"
dstRegistry := "localhost:5001"
catalog, err := crane.Catalog(srcRegistry)
if err != nil {
return err
}
for _, repo := range catalog {
tags, err := crane.ListTags(repo)
if err != nil {
return err
}
for _, tag := range tags {
src := fmt.Sprintf("%s/%s:%s", srcRegistry, repo, tag)
dst := fmt.Sprintf("%s/%s:%s", dstRegistry, repo, tag)
if err := crane.Copy(src, dst); err != nil {
return err
}
}
} The This is the best you can do in a "generic" way, unfortunately, and a lot of registries don't support catalog. |
Oh, I did get confused and the copy worked and when I went to verify with the CLI it broke and I wandered off without realizing the copy was successful. D'oh! I can still finish this though, I think I've found the bug and am building up the test cases to prove it. |
I'm not entirely sure if it makes sense. In my mind, a registry is just a hostname, and a repository includes a path component. This is an important distinction to make because listing tags requires a path component, and calling catalog forbids one. I think this already works, as intended, and the linked bug doesn't reproduce? |
...oh Well that's what I get for not updating my I think there's missing test cases in tag_test.go: Shouldn't we be checking EDIT: d'oh, then it's handled by the digest code |
(I still think there's a different subtle bug I'm working on fixing re: that test case, unless I misunderstood the format) EDIT: I did misunderstand tag vs digest handling code. |
FWIW you are probably right, and I'd like to rework this package entirely, but haven't had the time... though as long as you're not blocked, I'm happy. |
crane ls localhost:5000/something
worked for me after this change. Also a
crane cp
.Fixes #840