mirror of https://github.com/containers/podman.git
Merge pull request #2354 from rhatdan/varlink
Add registry name to fields returned by varlink image search
This commit is contained in:
commit
e738ef1622
9
API.md
9
API.md
|
|
@ -107,7 +107,7 @@ in the [API.md](https://github.com/containers/libpod/blob/master/API.md) file in
|
|||
|
||||
[func RestartPod(name: string) string](#RestartPod)
|
||||
|
||||
[func SearchImages(quety: string, limit: int, tlsVerify: ?bool) ImageSearchResult](#SearchImages)
|
||||
[func SearchImages(query: string, limit: int, tlsVerify: ?bool) ImageSearchResult](#SearchImages)
|
||||
|
||||
[func SendFile(type: string, length: int) string](#SendFile)
|
||||
|
||||
|
|
@ -780,8 +780,9 @@ ReceiveFile allows the host to send a remote client a file
|
|||
<div style="background-color: #E8E8E8; padding: 15px; margin: 10px; border-radius: 10px;">
|
||||
|
||||
method RemoveContainer(name: [string](https://godoc.org/builtin#string), force: [bool](https://godoc.org/builtin#bool), removeVolumes: [bool](https://godoc.org/builtin#bool)) [string](https://godoc.org/builtin#string)</div>
|
||||
RemoveContainer takes requires the name or ID of container as well a boolean representing whether a running
|
||||
container can be stopped and removed. It also takes a flag on whether or not to remove builtin volumes. Upon successful removal of the container, its ID is returned. If the
|
||||
RemoveContainer requires the name or ID of container as well a boolean representing whether a running container can be stopped and removed, and a boolean
|
||||
indicating whether to remove builtin volumes. Upon successful removal of the
|
||||
container, its ID is returned. If the
|
||||
container cannot be found by name or ID, a [ContainerNotFound](#ContainerNotFound) error will be returned.
|
||||
#### Example
|
||||
~~~
|
||||
|
|
@ -1423,6 +1424,8 @@ is_official [bool](https://godoc.org/builtin#bool)
|
|||
|
||||
is_automated [bool](https://godoc.org/builtin#bool)
|
||||
|
||||
registry [string](https://godoc.org/builtin#string)
|
||||
|
||||
name [string](https://godoc.org/builtin#string)
|
||||
|
||||
star_count [int](https://godoc.org/builtin#int)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/containers/libpod/cmd/podman/formats"
|
||||
"github.com/containers/libpod/libpod/common"
|
||||
sysreg "github.com/containers/libpod/pkg/registries"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -88,7 +87,7 @@ func searchCmd(c *cliconfig.SearchValues) error {
|
|||
term := args[0]
|
||||
|
||||
// Check if search term has a registry in it
|
||||
registry, err := getRegistry(term)
|
||||
registry, err := sysreg.GetRegistry(term)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting registry from %q", term)
|
||||
}
|
||||
|
|
@ -301,16 +300,3 @@ func matchesOfficialFilter(filter searchFilterParams, result docker.SearchResult
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getRegistry(image string) (string, error) {
|
||||
// It is possible to only have the registry name in the format "myregistry/"
|
||||
// if so, just trim the "/" from the end and return the registry name
|
||||
if strings.HasSuffix(image, "/") {
|
||||
return strings.TrimSuffix(image, "/"), nil
|
||||
}
|
||||
imgRef, err := reference.Parse(image)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return reference.Domain(imgRef.(reference.Named)), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ type ImageSearchResult (
|
|||
description: string,
|
||||
is_official: bool,
|
||||
is_automated: bool,
|
||||
registry: string,
|
||||
name: string,
|
||||
star_count: int
|
||||
)
|
||||
|
|
@ -600,8 +601,9 @@ method GetAttachSockets(name: string) -> (sockets: Sockets)
|
|||
# a [ContainerNotFound](#ContainerNotFound) error is returned.
|
||||
method WaitContainer(name: string) -> (exitcode: int)
|
||||
|
||||
# RemoveContainer takes requires the name or ID of container as well a boolean representing whether a running and a boolean indicating whether to remove builtin volumes
|
||||
# container can be stopped and removed. Upon successful removal of the container, its ID is returned. If the
|
||||
# RemoveContainer requires the name or ID of container as well a boolean representing whether a running container can be stopped and removed, and a boolean
|
||||
# indicating whether to remove builtin volumes. Upon successful removal of the
|
||||
# container, its ID is returned. If the
|
||||
# container cannot be found by name or ID, a [ContainerNotFound](#ContainerNotFound) error will be returned.
|
||||
# #### Example
|
||||
# ~~~
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ package registries
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/image/pkg/sysregistries"
|
||||
"github.com/containers/image/types"
|
||||
"github.com/containers/libpod/pkg/rootless"
|
||||
"github.com/docker/distribution/reference"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -49,3 +51,17 @@ func GetInsecureRegistries() ([]string, error) {
|
|||
}
|
||||
return registries, nil
|
||||
}
|
||||
|
||||
// GetRegistry returns the registry name from a string if specified
|
||||
func GetRegistry(image string) (string, error) {
|
||||
// It is possible to only have the registry name in the format "myregistry/"
|
||||
// if so, just trim the "/" from the end and return the registry name
|
||||
if strings.HasSuffix(image, "/") {
|
||||
return strings.TrimSuffix(image, "/"), nil
|
||||
}
|
||||
imgRef, err := reference.Parse(image)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return reference.Domain(imgRef.(reference.Named)), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,9 +446,21 @@ func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit
|
|||
if tlsVerify != nil {
|
||||
sc.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!*tlsVerify)
|
||||
}
|
||||
registries, err := sysreg.GetRegistries()
|
||||
var registries []string
|
||||
|
||||
// Check if search query has a registry in it
|
||||
registry, err := sysreg.GetRegistry(query)
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(fmt.Sprintf("unable to get system registries: %q", err))
|
||||
return call.ReplyErrorOccurred(fmt.Sprintf("error getting registry from %q: %q", query, err))
|
||||
}
|
||||
if registry != "" {
|
||||
registries = append(registries, registry)
|
||||
query = query[len(registry)+1:]
|
||||
} else {
|
||||
registries, err = sysreg.GetRegistries()
|
||||
if err != nil {
|
||||
return call.ReplyErrorOccurred(fmt.Sprintf("unable to get system registries: %q", err))
|
||||
}
|
||||
}
|
||||
var imageResults []iopodman.ImageSearchResult
|
||||
for _, reg := range registries {
|
||||
|
|
@ -468,6 +480,7 @@ func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit
|
|||
}
|
||||
for _, result := range results {
|
||||
i := iopodman.ImageSearchResult{
|
||||
Registry: reg,
|
||||
Description: result.Description,
|
||||
Is_official: result.IsOfficial,
|
||||
Is_automated: result.IsAutomated,
|
||||
|
|
|
|||
Loading…
Reference in New Issue