2022-10-24 21:47:20 +03:00
|
|
|
package oci
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/awslabs/amazon-ecr-credential-helper/ecr-login"
|
|
|
|
"github.com/chrismellard/docker-credential-acr-env/pkg/credhelper"
|
|
|
|
"github.com/google/go-containerregistry/pkg/authn"
|
|
|
|
"github.com/google/go-containerregistry/pkg/authn/github"
|
|
|
|
"github.com/google/go-containerregistry/pkg/v1/google"
|
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"
|
2023-09-05 04:14:28 +02:00
|
|
|
cobrautils "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/utils/cobra"
|
2022-10-24 21:47:20 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2023-09-04 00:30:18 +02:00
|
|
|
func Command() *cobra.Command {
|
|
|
|
amazonKeychain := authn.NewKeychainFromHelper(ecr.NewECRHelper(ecr.WithLogger(io.Discard)))
|
|
|
|
azureKeychain := authn.NewKeychainFromHelper(credhelper.NewACRCredentialsHelper())
|
|
|
|
keychain := authn.NewMultiKeychain(
|
2022-10-24 21:47:20 +03:00
|
|
|
authn.DefaultKeychain,
|
|
|
|
google.Keychain,
|
|
|
|
github.Keychain,
|
|
|
|
amazonKeychain,
|
|
|
|
azureKeychain,
|
|
|
|
)
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "oci",
|
2023-09-05 04:14:28 +02:00
|
|
|
Short: cobrautils.FormatDescription(true, websiteUrl, true, description...),
|
|
|
|
Long: cobrautils.FormatDescription(false, websiteUrl, true, description...),
|
|
|
|
Example: cobrautils.FormatExamples(examples...),
|
2022-10-24 21:47:20 +03:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
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
|
|
|
|
}
|