mirror of
https://github.com/containers/podman.git
synced 2025-11-01 10:45:52 +08:00
autocomplete podman search --filter
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
13
vendor/github.com/containers/common/libimage/define/search.go
generated
vendored
Normal file
13
vendor/github.com/containers/common/libimage/define/search.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
package define
|
||||
|
||||
const (
|
||||
// SearchFilterAutomated is the key for filtering images by their automated attribute.
|
||||
SearchFilterAutomated = "is-automated"
|
||||
// SearchFilterOfficial is the key for filtering images by their official attribute.
|
||||
SearchFilterOfficial = "is-official"
|
||||
// SearchFilterStars is the key for filtering images by stars.
|
||||
SearchFilterStars = "stars"
|
||||
)
|
||||
|
||||
// SearchFilters includes all supported search filters.
|
||||
var SearchFilters = []string{SearchFilterAutomated, SearchFilterOfficial, SearchFilterStars}
|
||||
5
vendor/github.com/containers/common/libimage/load.go
generated
vendored
5
vendor/github.com/containers/common/libimage/load.go
generated
vendored
@ -114,6 +114,11 @@ func (r *Runtime) loadMultiImageDockerArchive(ctx context.Context, ref types.Ima
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if err := reader.Close(); err != nil {
|
||||
logrus.Errorf("Closing reader of docker archive: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
refLists, err := reader.List()
|
||||
if err != nil {
|
||||
|
||||
5
vendor/github.com/containers/common/libimage/pull.go
generated
vendored
5
vendor/github.com/containers/common/libimage/pull.go
generated
vendored
@ -315,6 +315,11 @@ func (r *Runtime) copyFromDockerArchive(ctx context.Context, ref types.ImageRefe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if err := reader.Close(); err != nil {
|
||||
logrus.Errorf("Closing reader of docker archive: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return r.copyFromDockerArchiveReaderReference(ctx, reader, readerRef, options)
|
||||
}
|
||||
|
||||
9
vendor/github.com/containers/common/libimage/search.go
generated
vendored
9
vendor/github.com/containers/common/libimage/search.go
generated
vendored
@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/containers/common/libimage/define"
|
||||
registryTransport "github.com/containers/image/v5/docker"
|
||||
"github.com/containers/image/v5/pkg/sysregistriesv2"
|
||||
"github.com/containers/image/v5/transports/alltransports"
|
||||
@ -81,22 +82,22 @@ func ParseSearchFilter(filter []string) (*SearchFilter, error) {
|
||||
for _, f := range filter {
|
||||
arr := strings.SplitN(f, "=", 2)
|
||||
switch arr[0] {
|
||||
case "stars":
|
||||
case define.SearchFilterStars:
|
||||
if len(arr) < 2 {
|
||||
return nil, errors.Errorf("invalid `stars` filter %q, should be stars=<value>", filter)
|
||||
return nil, errors.Errorf("invalid filter %q, should be stars=<value>", filter)
|
||||
}
|
||||
stars, err := strconv.Atoi(arr[1])
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "incorrect value type for stars filter")
|
||||
}
|
||||
sFilter.Stars = stars
|
||||
case "is-automated":
|
||||
case define.SearchFilterAutomated:
|
||||
if len(arr) == 2 && arr[1] == "false" {
|
||||
sFilter.IsAutomated = types.OptionalBoolFalse
|
||||
} else {
|
||||
sFilter.IsAutomated = types.OptionalBoolTrue
|
||||
}
|
||||
case "is-official":
|
||||
case define.SearchFilterOfficial:
|
||||
if len(arr) == 2 && arr[1] == "false" {
|
||||
sFilter.IsOfficial = types.OptionalBoolFalse
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user