|
|
|
@ -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)
|
|
|
|
|
}
|
|
|
|
|