-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
admin.go
55 lines (45 loc) · 1.33 KB
/
admin.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package kubeconfig
import (
"path/filepath"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/tls"
)
var (
kubeconfigAdminPath = filepath.Join("auth", "kubeconfig")
)
// AdminClient is the asset for the admin kubeconfig.
type AdminClient struct {
kubeconfig
}
var _ asset.WritableAsset = (*AdminClient)(nil)
// Dependencies returns the dependency of the kubeconfig.
func (k *AdminClient) Dependencies() []asset.Asset {
return []asset.Asset{
&tls.AdminKubeConfigClientCertKey{},
&tls.KubeAPIServerCompleteCABundle{},
&installconfig.InstallConfig{},
}
}
// Generate generates the kubeconfig.
func (k *AdminClient) Generate(parents asset.Parents) error {
ca := &tls.KubeAPIServerCompleteCABundle{}
clientCertKey := &tls.AdminKubeConfigClientCertKey{}
installConfig := &installconfig.InstallConfig{}
parents.Get(ca, clientCertKey, installConfig)
return k.kubeconfig.generate(
ca,
clientCertKey,
installConfig.Config,
"admin",
kubeconfigAdminPath,
)
}
// Name returns the human-friendly name of the asset.
func (k *AdminClient) Name() string {
return "Kubeconfig Admin Client"
}
// Load returns the kubeconfig from disk.
func (k *AdminClient) Load(f asset.FileFetcher) (found bool, err error) {
return k.load(f, kubeconfigAdminPath)
}