Merge pull request #125917 from skitt/drop-auth-path-kubernetes-auth

Drop references to auth-path and kubernetes_auth

Kubernetes-commit: 61c408a7d90ecceed0687644f17c220e0eb946f0
This commit is contained in:
Kubernetes Publisher 2024-09-25 21:02:02 +01:00
commit dfbc1c7fb1

View File

@ -243,10 +243,7 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) {
} }
mergo.Merge(clientConfig, userAuthPartialConfig, mergo.WithOverride) mergo.Merge(clientConfig, userAuthPartialConfig, mergo.WithOverride)
serverAuthPartialConfig, err := getServerIdentificationPartialConfig(configAuthInfo, configClusterInfo) serverAuthPartialConfig := getServerIdentificationPartialConfig(configClusterInfo)
if err != nil {
return nil, err
}
mergo.Merge(clientConfig, serverAuthPartialConfig, mergo.WithOverride) mergo.Merge(clientConfig, serverAuthPartialConfig, mergo.WithOverride)
} }
@ -254,32 +251,23 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) {
} }
// clientauth.Info object contain both user identification and server identification. We want different precedence orders for // clientauth.Info object contain both user identification and server identification. We want different precedence orders for
// both, so we have to split the objects and merge them separately // both, so we have to split the objects and merge them separately.
// we want this order of precedence for the server identification
// 1. configClusterInfo (the final result of command line flags and merged .kubeconfig files)
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
// 3. load the ~/.kubernetes_auth file as a default
func getServerIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, configClusterInfo clientcmdapi.Cluster) (*restclient.Config, error) {
mergedConfig := &restclient.Config{}
// configClusterInfo holds the information identify the server provided by .kubeconfig // getServerIdentificationPartialConfig extracts server identification information from configClusterInfo
// (the final result of command line flags and merged .kubeconfig files).
func getServerIdentificationPartialConfig(configClusterInfo clientcmdapi.Cluster) *restclient.Config {
configClientConfig := &restclient.Config{} configClientConfig := &restclient.Config{}
configClientConfig.CAFile = configClusterInfo.CertificateAuthority configClientConfig.CAFile = configClusterInfo.CertificateAuthority
configClientConfig.CAData = configClusterInfo.CertificateAuthorityData configClientConfig.CAData = configClusterInfo.CertificateAuthorityData
configClientConfig.Insecure = configClusterInfo.InsecureSkipTLSVerify configClientConfig.Insecure = configClusterInfo.InsecureSkipTLSVerify
configClientConfig.ServerName = configClusterInfo.TLSServerName configClientConfig.ServerName = configClusterInfo.TLSServerName
mergo.Merge(mergedConfig, configClientConfig, mergo.WithOverride)
return mergedConfig, nil return configClientConfig
} }
// clientauth.Info object contain both user identification and server identification. We want different precedence orders for // getUserIdentificationPartialConfig extracts user identification information from configAuthInfo
// both, so we have to split the objects and merge them separately // (the final result of command line flags and merged .kubeconfig files);
// we want this order of precedence for user identification // if the information available there is insufficient, it prompts (if possible) for additional information.
// 1. configAuthInfo minus auth-path (the final result of command line flags and merged .kubeconfig files)
// 2. configAuthInfo.auth-path (this file can contain information that conflicts with #1, and we want #1 to win the priority)
// 3. if there is not enough information to identify the user, load try the ~/.kubernetes_auth file
// 4. if there is not enough information to identify the user, prompt if possible
func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, fallbackReader io.Reader, persistAuthConfig restclient.AuthProviderConfigPersister, configClusterInfo clientcmdapi.Cluster) (*restclient.Config, error) { func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthInfo clientcmdapi.AuthInfo, fallbackReader io.Reader, persistAuthConfig restclient.AuthProviderConfigPersister, configClusterInfo clientcmdapi.Cluster) (*restclient.Config, error) {
mergedConfig := &restclient.Config{} mergedConfig := &restclient.Config{}