1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/cmd/cli/kubectl-kyverno/commands/oci/pull/command.go
Charles-Edouard Brétéché dc71610df7
refactor: cli commands tests and error handling (#8367)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-13 09:53:19 +00:00

33 lines
995 B
Go

package pull
import (
"log"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/command"
"github.com/spf13/cobra"
)
func Command(keychain authn.Keychain) *cobra.Command {
var options options
cmd := &cobra.Command{
Use: "pull [dir]",
Short: command.FormatDescription(true, websiteUrl, true, description...),
Long: command.FormatDescription(false, websiteUrl, true, description...),
Example: command.FormatExamples(examples...),
Args: cobra.ExactArgs(1),
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
dir := args[0]
if err := options.validate(dir); err != nil {
return err
}
return options.execute(cmd.Context(), dir, keychain)
},
}
cmd.Flags().StringVarP(&options.imageRef, "image", "i", "", "image reference to push to or pull from")
if err := cmd.MarkFlagRequired("image"); err != nil {
log.Println("WARNING", err)
}
return cmd
}