-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Search repository tags using --list-tags #7836
Conversation
@@ -65,6 +68,10 @@ Example if limit is 10 and two registries are being searched, the total | |||
number of results will be 20, 10 from each (if there are at least 10 matches in each). | |||
The order of the search results is the order in which the API endpoint returns the results. | |||
|
|||
**--list-tags** | |||
|
|||
Search tags available in the repository. Note: the result only contains the Image name and its tag. |
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.
As we can use search on registry.redhat.io/
and get all of the images in the repository:
Search tags available in the repository. Note: the result only contains the Image name and its tag. | |
List the available tags in the repository for each image found. Note: the result contains the Image name and its tag, one line for every tag associated with the image. |
libpod/image/search.go
Outdated
dockerPrefix := fmt.Sprintf("%s://", docker.Transport.Name()) | ||
imageRef, err := alltransports.ParseImageName(fmt.Sprintf("%s/%s", registry, term)) | ||
if err == nil && imageRef.Transport().Name() != docker.Transport.Name() { | ||
logrus.Errorf("reference %q must be a docker reference", term) |
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.
@rhatdan got a less Docker way to say this? Perhaps:
logrus.Errorf("reference %q must be a docker reference", term) | |
logrus.Errorf("reference %q must be a valid container image reference", term) |
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 think "docker" is more accurate in containers-transports(5) terms as all of the transports refer to a container image.
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.
@vrothberg sometimes I really don't like it when you're right... Let's leave it then, thx for the follow up.
search = podmanTest.Podman([]string{"search", "--filter=is-official", "--list-tags", "docker.io/library/alpine"}) | ||
search.WaitWithDefaultTimeout() | ||
Expect(search.ExitCode()).To(Not(Equal(0))) | ||
}) |
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.
need to add a search for a registry too with a backslash only, no image name. For that and for this test, add a test to make sure the returned lines are greater than 1 and perhaps greater than 2 or 3.
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 see you added the test with lines >2, ty! Could you also add a test that lists the tags for docker.io/library/
(no image, just a backslash). According to the doc, it's allowed: podman search registry.fedoraproject.org/
and if it is NOT allowed with the --list-tags
option, it would be good to test that.
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.
Test added. It's not allowed, no tags will be returned for docker.io/library/
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'm fine with not allowing it, but we really should add a note to the --list-tags
option in the man page saying that, and preferably raise some kind of error message telling the user that they need to specify an image or at least return an "image not found" kind of message.
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.
Hope I'm not being too painful @QiWang19 !
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.
the error would be "library/" must be a docker reference". Add to the doc "the search term should be repository name". Would this work?
$ bin/podman search --list-tags docker.io/library/
ERRO[0000] error listing registry tags "docker.io": reference "library/" must be a docker reference
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.
OK, first off, I'd still like to see a test for docker.io/library/
(or some other registry) and then test for the appropriate error message. I'm finding the man page to be very confusing at the moment, will try to suggest a rewrite.
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.
search does not return error, it logs errors to standard logger and returns the 0 entry of the result.
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.
Sounds good and it looks like you've added a test for that, TY!
libpod/image/search.go
Outdated
dockerPrefix := fmt.Sprintf("%s://", docker.Transport.Name()) | ||
imageRef, err := alltransports.ParseImageName(fmt.Sprintf("%s/%s", registry, term)) | ||
if err == nil && imageRef.Transport().Name() != docker.Transport.Name() { | ||
logrus.Errorf("reference %q must be a docker reference", term) |
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 think "docker" is more accurate in containers-transports(5) terms as all of the transports refer to a container image.
@@ -591,6 +591,7 @@ func SearchImages(w http.ResponseWriter, r *http.Request) { | |||
NoTrunc bool `json:"noTrunc"` | |||
Filters []string `json:"filters"` | |||
TLSVerify bool `json:"tlsVerify"` | |||
ListTags bool `json:"listTags"` |
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 also need to extend the swagger docs in pkg/api/server/register_images.go
00b21f1
to
a58c522
Compare
@containers/podman-maintainers PTAL |
cmd/podman/images/search.go
Outdated
@@ -86,6 +86,7 @@ func searchFlags(flags *pflag.FlagSet) { | |||
flags.BoolVar(&searchOptions.NoTrunc, "no-trunc", false, "Do not truncate the output") | |||
flags.StringVar(&searchOptions.Authfile, "authfile", auth.GetDefaultAuthFile(), "Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override") | |||
flags.BoolVar(&searchOptions.TLSVerifyCLI, "tls-verify", true, "Require HTTPS and verify certificates when contacting registries") | |||
flags.BoolVar(&searchOptions.ListTags, "list-tags", false, "Search the tags of the input registry") |
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.
List the tags ...
cmd/podman/images/search.go
Outdated
@@ -126,6 +127,19 @@ func imageSearch(cmd *cobra.Command, args []string) error { | |||
return err | |||
} | |||
|
|||
if searchOptions.ListTags { | |||
if len(searchOptions.Filters) != 0 { | |||
return errors.Errorf("filters are not applicable to search tags result") |
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.
applicable to list
tags result
libpod/image/search.go
Outdated
@@ -207,6 +217,45 @@ func searchImageInRegistry(term string, registry string, options SearchOptions) | |||
return paramsArr | |||
} | |||
|
|||
func searchRepositoryTags(registry, term string, sc *types.SystemContext, options SearchOptions) []SearchResult { |
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 should return real errors, and not just write them to the screen.
libpod/image/search.go
Outdated
dockerPrefix := fmt.Sprintf("%s://", docker.Transport.Name()) | ||
imageRef, err := alltransports.ParseImageName(fmt.Sprintf("%s/%s", registry, term)) | ||
if err == nil && imageRef.Transport().Name() != docker.Transport.Name() { | ||
logrus.Errorf("reference %q must be a docker reference", term) |
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.
Return this error
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.
fixed
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: QiWang19, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM |
@containers/podman-maintainers PTAL |
Looks like there are still comments from @vrothberg and me that have not yet been addressed.... |
fixed that in pkg/api/server/register_images.go |
39e8d00
to
600c1dd
Compare
|
||
List the available tags in the repository for each image found. Note: --list-tags requires the search term to be a full | ||
repository name. If not specified the registry server, default registries will be searched through (in /etc/containers/registries.conf). The result contains the Image name and its tag, one line for every tag associated with the image. | ||
|
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 is all very contradictory. You're saying at the start that you'll list all tags for each image found in the repository, and then that the full name must be used. I think from our conversations that the image name with the repository must be supplied. I.e. you must do docker.io/library/alpine
and you can't do docker.io/library/
or alpine
. Given that assumption:
List the available tags in the repository for the specified image. **Note:** --list-tags requires the search term to be a fully | |
specified image name. The result contains the Image name and its tag, one line for every tag associated with the image. |
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.
fixed
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 think the docker.io/library/alpine refer to a repository name, if append a tag to it, it will refer to an image?
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.
@QiWang19 yeah, it's confusing and I may not have helped matters. When you push a container image to a registry, it creates a repository from it. How's this?
List the available tags in the repository for the specified image. **Note:** --list-tags requires the search term to be a fully
specified image. The result contains the Image name and its tag, one line for every tag found in the repository.
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.
👍
nicely done @QiWang19
9b70587
to
b8c5af2
Compare
For fix of BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1684263 Add --list-tags to podman search to return a table the repository tags. Signed-off-by: Qi Wang <[email protected]>
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
/lgtm |
/hold cancel |
For fix of BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1684263
Add --list-tags to podman search to return a table the repository tags.
Signed-off-by: Qi Wang [email protected]