github.com/openshift/installer@v1.4.17/pkg/asset/kubeconfig/admin.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  	kubeconfigAdminPath = filepath.Join("auth", "kubeconfig")
    14  )
    15  
    16  // AdminClient is the asset for the admin kubeconfig.
    17  type AdminClient struct {
    18  	kubeconfig
    19  }
    20  
    21  var _ asset.WritableAsset = (*AdminClient)(nil)
    22  
    23  // Dependencies returns the dependency of the kubeconfig.
    24  func (k *AdminClient) Dependencies() []asset.Asset {
    25  	return []asset.Asset{
    26  		&tls.AdminKubeConfigClientCertKey{},
    27  		&tls.KubeAPIServerCompleteCABundle{},
    28  		&installconfig.InstallConfig{},
    29  	}
    30  }
    31  
    32  // Generate generates the kubeconfig.
    33  func (k *AdminClient) Generate(_ context.Context, parents asset.Parents) error {
    34  	ca := &tls.KubeAPIServerCompleteCABundle{}
    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  		getExtAPIServerURL(installConfig.Config),
    43  		installConfig.Config.GetName(),
    44  		"admin",
    45  		kubeconfigAdminPath,
    46  	)
    47  }
    48  
    49  // Name returns the human-friendly name of the asset.
    50  func (k *AdminClient) Name() string {
    51  	return "Kubeconfig Admin Client"
    52  }
    53  
    54  // Load returns the kubeconfig from disk.
    55  func (k *AdminClient) Load(f asset.FileFetcher) (found bool, err error) {
    56  	return k.load(f, kubeconfigAdminPath)
    57  }