2023-06-22 12:43:01 -05:00
|
|
|
//go:build search
|
|
|
|
// +build search
|
|
|
|
|
2023-09-15 17:17:01 -05:00
|
|
|
package client
|
2023-06-22 12:43:01 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2023-08-30 12:12:24 -05:00
|
|
|
"zotregistry.io/zot/pkg/cli/cmdflags"
|
2023-06-22 12:43:01 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewSearchCommand(searchService SearchService) *cobra.Command {
|
2023-08-30 12:12:24 -05:00
|
|
|
searchCmd := &cobra.Command{
|
2023-09-14 12:51:17 -05:00
|
|
|
Use: "search [command]",
|
2023-06-22 12:43:01 -05:00
|
|
|
Short: "Search images and their tags",
|
2023-09-08 07:12:47 -05:00
|
|
|
Long: `Search repos or images`,
|
2023-09-14 12:51:17 -05:00
|
|
|
RunE: ShowSuggestionsIfUnknownCommand,
|
2023-06-22 12:43:01 -05:00
|
|
|
}
|
|
|
|
|
2023-08-30 12:12:24 -05:00
|
|
|
searchCmd.SetUsageTemplate(searchCmd.UsageTemplate() + usageFooter)
|
2023-06-22 12:43:01 -05:00
|
|
|
|
2023-09-08 07:12:47 -05:00
|
|
|
searchCmd.PersistentFlags().String(cmdflags.URLFlag, "",
|
|
|
|
"Specify zot server URL if config-name is not mentioned")
|
|
|
|
searchCmd.PersistentFlags().String(cmdflags.ConfigFlag, "",
|
|
|
|
"Specify the registry configuration to use for connection")
|
|
|
|
searchCmd.PersistentFlags().StringP(cmdflags.UserFlag, "u", "",
|
|
|
|
`User Credentials of zot server in "username:password" format`)
|
|
|
|
searchCmd.PersistentFlags().StringP(cmdflags.OutputFormatFlag, "f", "", "Specify output format [text/json/yaml]")
|
|
|
|
searchCmd.PersistentFlags().Bool(cmdflags.VerboseFlag, false, "Show verbose output")
|
|
|
|
searchCmd.PersistentFlags().Bool(cmdflags.DebugFlag, false, "Show debug output")
|
|
|
|
|
2023-08-30 12:12:24 -05:00
|
|
|
searchCmd.AddCommand(NewSearchQueryCommand(searchService))
|
|
|
|
searchCmd.AddCommand(NewSearchSubjectCommand(searchService))
|
|
|
|
|
|
|
|
return searchCmd
|
2023-06-22 12:43:01 -05:00
|
|
|
}
|