forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
41 lines (35 loc) · 1.03 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package util
import (
"path/filepath"
kclient "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/openshift/origin/pkg/client"
configapi "github.com/openshift/origin/pkg/cmd/server/api"
)
func KubeConfigPath() string {
return filepath.Join(GetBaseDir(), "openshift.local.config", "master", "admin.kubeconfig")
}
func GetClusterAdminKubeClient(adminKubeConfigFile string) (*kclient.Client, error) {
if c, _, err := configapi.GetKubeClient(adminKubeConfigFile); err != nil {
return nil, err
} else {
return c, nil
}
}
func GetClusterAdminClient(adminKubeConfigFile string) (*client.Client, error) {
clientConfig, err := GetClusterAdminClientConfig(adminKubeConfigFile)
if err != nil {
return nil, err
}
osClient, err := client.New(clientConfig)
if err != nil {
return nil, err
}
return osClient, nil
}
func GetClusterAdminClientConfig(adminKubeConfigFile string) (*kclient.Config, error) {
_, conf, err := configapi.GetKubeClient(adminKubeConfigFile)
if err != nil {
return nil, err
}
return conf, nil
}