From a6908852e07c364fb9afdf078f8a8031d1281bcb Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Fri, 5 Jul 2024 14:55:44 +0200 Subject: [PATCH] Drop references to auth-path and kubernetes_auth These are long gone, removed in 2016: * AuthPath removal: https://github.com/kubernetes/kubernetes/pull/29216 * Flag removal: https://github.com/kubernetes/kubernetes/pull/40048 This removes the remnants from clientcmd, mostly in the comments describing how the configuration is loaded. Since getServerIdentificationPartialConfig can no longer fail (it copies fields from one struct to another), this drops the error return, along with the error handling in the caller. Signed-off-by: Stephen Kitt --- .../tools/clientcmd/client_config.go | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/clientcmd/client_config.go b/staging/src/k8s.io/client-go/tools/clientcmd/client_config.go index 952f6d7eb6cd8..d7e95c5747e55 100644 --- a/staging/src/k8s.io/client-go/tools/clientcmd/client_config.go +++ b/staging/src/k8s.io/client-go/tools/clientcmd/client_config.go @@ -243,10 +243,7 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) { } mergo.Merge(clientConfig, userAuthPartialConfig, mergo.WithOverride) - serverAuthPartialConfig, err := getServerIdentificationPartialConfig(configAuthInfo, configClusterInfo) - if err != nil { - return nil, err - } + serverAuthPartialConfig := getServerIdentificationPartialConfig(configClusterInfo) mergo.Merge(clientConfig, serverAuthPartialConfig, mergo.WithOverride) } @@ -254,32 +251,24 @@ func (config *DirectClientConfig) ClientConfig() (*restclient.Config, error) { } // 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 -// 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 +// both, so we have to split the objects and merge them separately. +// configClusterInfo (the final result of command line flags and merged .kubeconfig files) is now the only source of +// service identification. +func getServerIdentificationPartialConfig(configClusterInfo clientcmdapi.Cluster) *restclient.Config { configClientConfig := &restclient.Config{} configClientConfig.CAFile = configClusterInfo.CertificateAuthority configClientConfig.CAData = configClusterInfo.CertificateAuthorityData configClientConfig.Insecure = configClusterInfo.InsecureSkipTLSVerify 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 -// both, so we have to split the objects and merge them separately -// we want this order of precedence for user identification -// 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 +// both, so we have to split the objects and merge them separately. +// We want this order of precedence for user identification: +// 1. configAuthInfo (the final result of command line flags and merged .kubeconfig files) +// 2. 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) { mergedConfig := &restclient.Config{}