1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/cmd/cli/kubectl-kyverno/commands/oci/push/command.go
Charles-Edouard Brétéché d24b0848a6
chore: add cli commands unit tests (#8366)
* chore: add cli unit tests

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* chore: add cli commands unit tests

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-12 21:47:03 +00:00

34 lines
997 B
Go

package push
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: "push",
Short: command.FormatDescription(true, websiteUrl, true, description...),
Long: command.FormatDescription(false, websiteUrl, true, description...),
Example: command.FormatExamples(examples...),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
dir := args[0]
if err := options.validate(dir); err != nil {
return err
}
cmd.SilenceUsage = true
cmd.SilenceErrors = true
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
}