github.com/openshift/installer@v1.4.17/pkg/asset/kubeconfig/loopback.go (about) 1 package kubeconfig 2 3 import ( 4 "context" 5 "path/filepath" 6 7 "github.com/openshift/installer/pkg/asset" 8 "github.com/openshift/installer/pkg/asset/installconfig" 9 "github.com/openshift/installer/pkg/asset/tls" 10 ) 11 12 var ( 13 kubeconfigLoopbackPath = filepath.Join("auth", "kubeconfig-loopback") 14 ) 15 16 // LoopbackClient is the asset for the admin kubeconfig. 17 type LoopbackClient struct { 18 kubeconfig 19 } 20 21 var _ asset.WritableAsset = (*LoopbackClient)(nil) 22 23 // Dependencies returns the dependency of the kubeconfig. 24 func (k *LoopbackClient) Dependencies() []asset.Asset { 25 return []asset.Asset{ 26 &tls.AdminKubeConfigClientCertKey{}, 27 &tls.KubeAPIServerLocalhostCABundle{}, 28 &installconfig.InstallConfig{}, 29 } 30 } 31 32 // Generate generates the kubeconfig. 33 func (k *LoopbackClient) Generate(_ context.Context, parents asset.Parents) error { 34 ca := &tls.KubeAPIServerLocalhostCABundle{} 35 clientCertKey := &tls.AdminKubeConfigClientCertKey{} 36 installConfig := &installconfig.InstallConfig{} 37 parents.Get(ca, clientCertKey, installConfig) 38 39 return k.kubeconfig.generate( 40 ca, 41 clientCertKey, 42 getLoopbackAPIServerURL(installConfig.Config), 43 installConfig.Config.GetName(), 44 "loopback", 45 kubeconfigLoopbackPath, 46 ) 47 } 48 49 // Name returns the human-friendly name of the asset. 50 func (k *LoopbackClient) Name() string { 51 return "Kubeconfig Admin Client (Loopback)" 52 } 53 54 // Load returns the kubeconfig from disk. 55 func (k *LoopbackClient) Load(f asset.FileFetcher) (found bool, err error) { 56 return k.load(f, kubeconfigLoopbackPath) 57 }