1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00
kyverno/cmd/cli/kubectl-kyverno/commands/oci/command.go
Vishal Choudhary c056321cba
chore(refactor): refactor image verification packages (#12220)
Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
2025-02-23 08:55:32 +00:00

39 lines
1.3 KiB
Go

package oci
import (
"io"
ecr "github.com/awslabs/amazon-ecr-credential-helper/ecr-login"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/authn/github"
"github.com/google/go-containerregistry/pkg/v1/google"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/command"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/oci/pull"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/oci/push"
"github.com/kyverno/kyverno/pkg/imageverification/imagedataloader"
"github.com/spf13/cobra"
)
func Command() *cobra.Command {
keychain := authn.NewMultiKeychain(
authn.DefaultKeychain,
github.Keychain,
authn.NewKeychainFromHelper(ecr.NewECRHelper(ecr.WithLogger(io.Discard))),
google.Keychain,
imagedataloader.AzureKeychain,
)
cmd := &cobra.Command{
Use: "oci",
Short: command.FormatDescription(true, websiteUrl, true, description...),
Long: command.FormatDescription(false, websiteUrl, true, description...),
Example: command.FormatExamples(examples...),
Args: cobra.NoArgs,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Help()
},
}
cmd.AddCommand(pull.Command(keychain))
cmd.AddCommand(push.Command(keychain))
return cmd
}