1
0
mirror of synced 2026-02-06 10:55:56 +00:00

Support check command with multiple config files

Resolves: #472
Signed-off-by: Alexei Ledenev <alexei.led@gmail.com>
This commit is contained in:
Alexei Ledenev
2020-12-17 15:00:13 +02:00
parent 12a0ebe3ba
commit 69387fd2a4
2 changed files with 12 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/kustomize/api/filesys"
@@ -134,7 +135,7 @@ func ExecTemplate(obj interface{}, tmpl, filename string) error {
return file.Sync()
}
func KubeClient(kubeConfigPath string, kubeContext string) (client.Client, error) {
func KubeConfig(kubeConfigPath string, kubeContext string) (*rest.Config, error) {
configFiles := SplitKubeConfigPath(kubeConfigPath)
configOverrides := clientcmd.ConfigOverrides{}
@@ -147,6 +148,15 @@ func KubeClient(kubeConfigPath string, kubeContext string) (client.Client, error
&configOverrides,
).ClientConfig()
if err != nil {
return nil, fmt.Errorf("kubernetes configuration load failed: %w", err)
}
return cfg, nil
}
func KubeClient(kubeConfigPath string, kubeContext string) (client.Client, error) {
cfg, err := KubeConfig(kubeConfigPath, kubeContext)
if err != nil {
return nil, fmt.Errorf("kubernetes client initialization failed: %w", err)
}