mirror of https://github.com/containers/podman.git
Merge pull request #6039 from vrothberg/enable-search-tests
Enable search tests
This commit is contained in:
commit
27aa3a7837
|
@ -93,23 +93,22 @@ func pullFlags(flags *pflag.FlagSet) {
|
||||||
|
|
||||||
// imagePull is implement the command for pulling images.
|
// imagePull is implement the command for pulling images.
|
||||||
func imagePull(cmd *cobra.Command, args []string) error {
|
func imagePull(cmd *cobra.Command, args []string) error {
|
||||||
pullOptsAPI := pullOptions.ImagePullOptions
|
|
||||||
// TLS verification in c/image is controlled via a `types.OptionalBool`
|
// TLS verification in c/image is controlled via a `types.OptionalBool`
|
||||||
// which allows for distinguishing among set-true, set-false, unspecified
|
// which allows for distinguishing among set-true, set-false, unspecified
|
||||||
// which is important to implement a sane way of dealing with defaults of
|
// which is important to implement a sane way of dealing with defaults of
|
||||||
// boolean CLI flags.
|
// boolean CLI flags.
|
||||||
if cmd.Flags().Changed("tls-verify") {
|
if cmd.Flags().Changed("tls-verify") {
|
||||||
pullOptsAPI.TLSVerify = types.NewOptionalBool(pullOptions.TLSVerifyCLI)
|
pullOptions.SkipTLSVerify = types.NewOptionalBool(!pullOptions.TLSVerifyCLI)
|
||||||
}
|
}
|
||||||
if pullOptsAPI.Authfile != "" {
|
if pullOptions.Authfile != "" {
|
||||||
if _, err := os.Stat(pullOptsAPI.Authfile); err != nil {
|
if _, err := os.Stat(pullOptions.Authfile); err != nil {
|
||||||
return errors.Wrapf(err, "error getting authfile %s", pullOptsAPI.Authfile)
|
return errors.Wrapf(err, "error getting authfile %s", pullOptions.Authfile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's do all the remaining Yoga in the API to prevent us from
|
// Let's do all the remaining Yoga in the API to prevent us from
|
||||||
// scattering logic across (too) many parts of the code.
|
// scattering logic across (too) many parts of the code.
|
||||||
pullReport, err := registry.ImageEngine().Pull(registry.GetContext(), args[0], pullOptsAPI)
|
pullReport, err := registry.ImageEngine().Pull(registry.GetContext(), args[0], pullOptions.ImagePullOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ var (
|
||||||
Long: searchCmd.Long,
|
Long: searchCmd.Long,
|
||||||
RunE: searchCmd.RunE,
|
RunE: searchCmd.RunE,
|
||||||
Args: searchCmd.Args,
|
Args: searchCmd.Args,
|
||||||
|
Annotations: searchCmd.Annotations,
|
||||||
Example: `podman image search --filter=is-official --limit 3 alpine
|
Example: `podman image search --filter=is-official --limit 3 alpine
|
||||||
podman image search registry.fedoraproject.org/ # only works with v2 registries
|
podman image search registry.fedoraproject.org/ # only works with v2 registries
|
||||||
podman image search --format "table {{.Index}} {{.Name}}" registry.fedoraproject.org/fedora`,
|
podman image search --format "table {{.Index}} {{.Name}}" registry.fedoraproject.org/fedora`,
|
||||||
|
@ -103,16 +105,21 @@ func imageSearch(cmd *cobra.Command, args []string) error {
|
||||||
return errors.Errorf("search requires exactly one argument")
|
return errors.Errorf("search requires exactly one argument")
|
||||||
}
|
}
|
||||||
|
|
||||||
sarchOptsAPI := searchOptions.ImageSearchOptions
|
|
||||||
// TLS verification in c/image is controlled via a `types.OptionalBool`
|
// TLS verification in c/image is controlled via a `types.OptionalBool`
|
||||||
// which allows for distinguishing among set-true, set-false, unspecified
|
// which allows for distinguishing among set-true, set-false, unspecified
|
||||||
// which is important to implement a sane way of dealing with defaults of
|
// which is important to implement a sane way of dealing with defaults of
|
||||||
// boolean CLI flags.
|
// boolean CLI flags.
|
||||||
if cmd.Flags().Changed("tls-verify") {
|
if cmd.Flags().Changed("tls-verify") {
|
||||||
sarchOptsAPI.TLSVerify = types.NewOptionalBool(pullOptions.TLSVerifyCLI)
|
searchOptions.SkipTLSVerify = types.NewOptionalBool(!searchOptions.TLSVerifyCLI)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchReport, err := registry.ImageEngine().Search(registry.GetContext(), searchTerm, sarchOptsAPI)
|
if searchOptions.Authfile != "" {
|
||||||
|
if _, err := os.Stat(searchOptions.Authfile); err != nil {
|
||||||
|
return errors.Wrapf(err, "error getting authfile %s", searchOptions.Authfile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
searchReport, err := registry.ImageEngine().Search(registry.GetContext(), searchTerm, searchOptions.ImageSearchOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,9 +273,10 @@ func Pull(ctx context.Context, rawImage string, options entities.ImagePullOption
|
||||||
params.Set("credentials", options.Credentials)
|
params.Set("credentials", options.Credentials)
|
||||||
params.Set("overrideArch", options.OverrideArch)
|
params.Set("overrideArch", options.OverrideArch)
|
||||||
params.Set("overrideOS", options.OverrideOS)
|
params.Set("overrideOS", options.OverrideOS)
|
||||||
if options.TLSVerify != types.OptionalBoolUndefined {
|
if options.SkipTLSVerify != types.OptionalBoolUndefined {
|
||||||
val := bool(options.TLSVerify == types.OptionalBoolTrue)
|
// Note: we have to verify if skipped is false.
|
||||||
params.Set("tlsVerify", strconv.FormatBool(val))
|
verifyTLS := bool(options.SkipTLSVerify == types.OptionalBoolFalse)
|
||||||
|
params.Set("tlsVerify", strconv.FormatBool(verifyTLS))
|
||||||
}
|
}
|
||||||
params.Set("allTags", strconv.FormatBool(options.AllTags))
|
params.Set("allTags", strconv.FormatBool(options.AllTags))
|
||||||
|
|
||||||
|
@ -334,9 +335,10 @@ func Search(ctx context.Context, term string, opts entities.ImageSearchOptions)
|
||||||
params.Set("filters", f)
|
params.Set("filters", f)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.TLSVerify != types.OptionalBoolUndefined {
|
if opts.SkipTLSVerify != types.OptionalBoolUndefined {
|
||||||
val := bool(opts.TLSVerify == types.OptionalBoolTrue)
|
// Note: we have to verify if skipped is false.
|
||||||
params.Set("tlsVerify", strconv.FormatBool(val))
|
verifyTLS := bool(opts.SkipTLSVerify == types.OptionalBoolFalse)
|
||||||
|
params.Set("tlsVerify", strconv.FormatBool(verifyTLS))
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := conn.DoRequest(nil, http.MethodGet, "/images/search", params)
|
response, err := conn.DoRequest(nil, http.MethodGet, "/images/search", params)
|
||||||
|
|
|
@ -141,8 +141,8 @@ type ImagePullOptions struct {
|
||||||
Quiet bool
|
Quiet bool
|
||||||
// SignaturePolicy to use when pulling. Ignored for remote calls.
|
// SignaturePolicy to use when pulling. Ignored for remote calls.
|
||||||
SignaturePolicy string
|
SignaturePolicy string
|
||||||
// TLSVerify to enable/disable HTTPS and certificate verification.
|
// SkipTLSVerify to skip HTTPS and certificate verification.
|
||||||
TLSVerify types.OptionalBool
|
SkipTLSVerify types.OptionalBool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImagePullReport is the response from pulling one or more images.
|
// ImagePullReport is the response from pulling one or more images.
|
||||||
|
@ -198,8 +198,8 @@ type ImageSearchOptions struct {
|
||||||
Limit int
|
Limit int
|
||||||
// NoTrunc will not truncate the output.
|
// NoTrunc will not truncate the output.
|
||||||
NoTrunc bool
|
NoTrunc bool
|
||||||
// TLSVerify to enable/disable HTTPS and certificate verification.
|
// SkipTLSVerify to skip HTTPS and certificate verification.
|
||||||
TLSVerify types.OptionalBool
|
SkipTLSVerify types.OptionalBool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageSearchReport is the response from searching images.
|
// ImageSearchReport is the response from searching images.
|
||||||
|
|
|
@ -118,7 +118,7 @@ func (ir *ImageEngine) Pull(ctx context.Context, rawImage string, options entiti
|
||||||
DockerCertPath: options.CertDir,
|
DockerCertPath: options.CertDir,
|
||||||
OSChoice: options.OverrideOS,
|
OSChoice: options.OverrideOS,
|
||||||
ArchitectureChoice: options.OverrideArch,
|
ArchitectureChoice: options.OverrideArch,
|
||||||
DockerInsecureSkipTLSVerify: options.TLSVerify,
|
DockerInsecureSkipTLSVerify: options.SkipTLSVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !options.AllTags {
|
if !options.AllTags {
|
||||||
|
@ -370,7 +370,7 @@ func (ir *ImageEngine) Search(ctx context.Context, term string, opts entities.Im
|
||||||
Filter: *filter,
|
Filter: *filter,
|
||||||
Limit: opts.Limit,
|
Limit: opts.Limit,
|
||||||
NoTrunc: opts.NoTrunc,
|
NoTrunc: opts.NoTrunc,
|
||||||
InsecureSkipTLSVerify: opts.TLSVerify,
|
InsecureSkipTLSVerify: opts.SkipTLSVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResults, err := image.SearchImages(term, searchOpts)
|
searchResults, err := image.SearchImages(term, searchOpts)
|
||||||
|
|
|
@ -68,7 +68,6 @@ registries = ['{{.Host}}:{{.Port}}']`
|
||||||
registryFileTwoTmpl := template.Must(template.New("registryFileTwo").Parse(regFileContents2))
|
registryFileTwoTmpl := template.Must(template.New("registryFileTwo").Parse(regFileContents2))
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue