2022-10-24 21:47:20 +03:00
|
|
|
package oci
|
|
|
|
|
|
|
|
import (
|
2024-01-29 13:55:52 +05:30
|
|
|
"io"
|
|
|
|
|
|
|
|
ecr "github.com/awslabs/amazon-ecr-credential-helper/ecr-login"
|
2022-10-24 21:47:20 +03:00
|
|
|
"github.com/google/go-containerregistry/pkg/authn"
|
|
|
|
"github.com/google/go-containerregistry/pkg/authn/github"
|
2024-01-29 13:55:52 +05:30
|
|
|
"github.com/google/go-containerregistry/pkg/v1/google"
|
2023-09-06 16:44:50 +02:00
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/command"
|
2023-09-04 17:15:55 +02:00
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/oci/pull"
|
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/oci/push"
|
2025-02-03 19:12:40 +05:30
|
|
|
"github.com/kyverno/kyverno/pkg/imagedataloader"
|
2022-10-24 21:47:20 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-09-04 00:30:18 +02:00
|
|
|
func Command() *cobra.Command {
|
|
|
|
keychain := authn.NewMultiKeychain(
|
2022-10-24 21:47:20 +03:00
|
|
|
authn.DefaultKeychain,
|
|
|
|
github.Keychain,
|
2024-01-29 13:55:52 +05:30
|
|
|
authn.NewKeychainFromHelper(ecr.NewECRHelper(ecr.WithLogger(io.Discard))),
|
|
|
|
google.Keychain,
|
2025-02-03 19:12:40 +05:30
|
|
|
imagedataloader.AzureKeychain,
|
2022-10-24 21:47:20 +03:00
|
|
|
)
|
|
|
|
cmd := &cobra.Command{
|
2023-09-13 11:53:19 +02:00
|
|
|
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,
|
2023-09-12 23:47:03 +02:00
|
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
2022-10-24 21:47:20 +03:00
|
|
|
return cmd.Help()
|
|
|
|
},
|
|
|
|
}
|
2023-09-03 23:21:40 +02:00
|
|
|
cmd.AddCommand(pull.Command(keychain))
|
|
|
|
cmd.AddCommand(push.Command(keychain))
|
2022-10-24 21:47:20 +03:00
|
|
|
return cmd
|
|
|
|
}
|