2022-10-10 07:05:55 -05:00
|
|
|
//go:build search
|
|
|
|
// +build search
|
2020-10-14 16:47:20 -05:00
|
|
|
|
2023-09-15 17:17:01 -05:00
|
|
|
package client
|
2020-06-16 20:52:40 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-09-08 07:12:47 -05:00
|
|
|
const (
|
|
|
|
spinnerDuration = 150 * time.Millisecond
|
|
|
|
usageFooter = `
|
|
|
|
Run 'zli config -h' for details on [config-name] argument
|
|
|
|
`
|
|
|
|
)
|
2020-06-16 20:52:40 -05:00
|
|
|
|
2023-09-08 07:12:47 -05:00
|
|
|
func NewImageCommand(searchService SearchService) *cobra.Command {
|
2021-12-13 14:23:31 -05:00
|
|
|
imageCmd := &cobra.Command{
|
2023-09-08 07:12:47 -05:00
|
|
|
Use: "image [command]",
|
|
|
|
Short: "List images hosted on the zot registry",
|
|
|
|
Long: `List images hosted on the zot registry`,
|
2023-09-14 12:51:17 -05:00
|
|
|
RunE: ShowSuggestionsIfUnknownCommand,
|
2020-06-16 20:52:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
imageCmd.SetUsageTemplate(imageCmd.UsageTemplate() + usageFooter)
|
|
|
|
|
2023-09-22 08:33:18 -05:00
|
|
|
imageCmd.PersistentFlags().String(URLFlag, "",
|
2023-09-08 07:12:47 -05:00
|
|
|
"Specify zot server URL if config-name is not mentioned")
|
2023-09-22 08:33:18 -05:00
|
|
|
imageCmd.PersistentFlags().String(ConfigFlag, "",
|
2023-09-08 07:12:47 -05:00
|
|
|
"Specify the registry configuration to use for connection")
|
2023-09-22 08:33:18 -05:00
|
|
|
imageCmd.PersistentFlags().StringP(UserFlag, "u", "",
|
2023-09-08 07:12:47 -05:00
|
|
|
`User Credentials of zot server in "username:password" format`)
|
2023-09-22 08:33:18 -05:00
|
|
|
imageCmd.PersistentFlags().StringP(OutputFormatFlag, "f", "", "Specify output format [text/json/yaml]")
|
|
|
|
imageCmd.PersistentFlags().Bool(VerboseFlag, false, "Show verbose output")
|
|
|
|
imageCmd.PersistentFlags().Bool(DebugFlag, false, "Show debug output")
|
2023-09-08 07:12:47 -05:00
|
|
|
|
|
|
|
imageCmd.AddCommand(NewImageListCommand(searchService))
|
|
|
|
imageCmd.AddCommand(NewImageCVEListCommand(searchService))
|
|
|
|
imageCmd.AddCommand(NewImageBaseCommand(searchService))
|
|
|
|
imageCmd.AddCommand(NewImageDerivedCommand(searchService))
|
|
|
|
imageCmd.AddCommand(NewImageDigestCommand(searchService))
|
|
|
|
imageCmd.AddCommand(NewImageNameCommand(searchService))
|
|
|
|
|
2020-06-16 20:52:40 -05:00
|
|
|
return imageCmd
|
|
|
|
}
|
|
|
|
|
2020-07-17 14:42:22 -05:00
|
|
|
func parseBooleanConfig(configPath, configName, configParam string) (bool, error) {
|
|
|
|
config, err := getConfigValue(configPath, configName, configParam)
|
2020-06-16 20:52:40 -05:00
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
2020-07-17 14:42:22 -05:00
|
|
|
val, err := strconv.ParseBool(config)
|
2020-06-16 20:52:40 -05:00
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
2020-07-17 14:42:22 -05:00
|
|
|
return val, nil
|
2020-06-16 20:52:40 -05:00
|
|
|
}
|