-
Notifications
You must be signed in to change notification settings - Fork 185
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
oci: Use default registry for Inspektor Gadget #2307
Conversation
87f8289
to
8b0a502
Compare
8b0a502
to
584de27
Compare
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 tested it and works fine. It will simplify running official gadgets.
I have only one question regarding UX with list
command. I am wondering if it makes sense to not show the default domain / default repo prefix when list the images. This should be similar to what docker does:
→ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
→ docker pull docker.io/library/alpine
Using default tag: latest
latest: Pulling from library/alpine
661ff4d9561e: Pull complete
Digest: sha256:51b67269f354137895d43f3b3d810bfacd3945438e94dc5ac55fdac340352f48
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
→ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest f8c20f8bbcb6 5 weeks ago 7.38MB
Also, it will encourage to use names like trace_open
for official gadget (after I just listed them using list
). What do you think?
// needs to be already validated before. | ||
func splitIGDomain(name string) (domain, remainder string) { | ||
i := strings.IndexRune(name, '/') | ||
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != localhost && strings.ToLower(name[:i]) == name[:i]) { |
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.
Just for my understanding, for strings.ToLower(name[:i]) == name[:i])
we assume it it a domain name since it contains capital letters?
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.
TBH I took this from https://github.com/distribution/reference/blob/v0.5.0/normalize.go#L126 without studying it in depth. I think your analysis is correct, it assumes it's a domain if there are capital letters, but domains are supported to be lower case, aren't they?
It was introduced in distribution/reference@ca2a562, the tests cases added parse the domain with upper case, not sure what this is for and the commit doesn't contain anymore information.
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.
domains are supported to be lower case, aren't they?
IIUC, domains are case insensitive, https://serverfault.com/a/261344
It was introduced in distribution/reference@ ca2a562, the tests cases added parse the domain with upper case, not sure what this is for and the commit doesn't contain anymore
information.
I found more information here, distribution/distribution#2979 and it gives more context why they did it.
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.
Apart from the naming this looks good. I also added a unit test for the split function since it seems important :D
90b0934
584de27
to
b46259a
Compare
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.
What do you think?
I agree. Updated the PR to trim the prefix when listing images.
// needs to be already validated before. | ||
func splitIGDomain(name string) (domain, remainder string) { | ||
i := strings.IndexRune(name, '/') | ||
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != localhost && strings.ToLower(name[:i]) == name[:i]) { |
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.
TBH I took this from https://github.com/distribution/reference/blob/v0.5.0/normalize.go#L126 without studying it in depth. I think your analysis is correct, it assumes it's a domain if there are capital letters, but domains are supported to be lower case, aren't they?
It was introduced in distribution/reference@ca2a562, the tests cases added parse the domain with upper case, not sure what this is for and the commit doesn't contain anymore information.
if named, ok := parsed.(reference.Named); ok { | ||
repository = named.Name() | ||
} | ||
repository = strings.TrimPrefix(repository, defaultDomain+"/"+officialRepoPrefix) |
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.
nit: Perhaps we can also trim the defaultDomain
for cases like ghcr.io/foo/bar
to be foo/bar
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 prefer to trim it only when the full thing matches. I'm don't think we should be treating any other think than "ghcr.io/inspektor-gadget/gadgets" in a special way.
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.
LGTM! I tested it and it works as described in the PR description.
- Don't export it as there is not any reason to export this function as users interact through other functions that don't require it. - Make it receive a "image reference.Named" to avoid calling getRepositoryFromImage that is somehow duplicated. Signed-off-by: Mauricio Vásquez <mauriciov@microsoft.com>
Move logic of getTagFromImage() and getRepositoryFromImage() directly to ListGadgetImages. Signed-off-by: Mauricio Vásquez <mauriciov@microsoft.com>
Signed-off-by: Burak Ok <burakok@microsoft.com>
b46259a
to
5301680
Compare
See #2190
Testing
Before
It's not possible to run a gadget by just specifying their name:
$ sudo -E ig image list INFO[0000] Experimental features enabled REPOSITORY TAG DIGEST $ sudo -E ig run trace_exec INFO[0000] Experimental features enabled Error: getting gadget info: getting gadget image: pulling image "trace_exec": creating remote repository: creating remote repository: invalid reference: missing repository
After
Now it's possible
Fixes #2190