File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,12 +83,21 @@ impl ConfigLoader {
8383 . ok_or_else ( || KubeconfigError :: LoadClusterOfContext ( cluster_name. clone ( ) ) ) ?;
8484
8585 let user_name = user. unwrap_or ( & current_context. user ) ;
86+
87+ // client-go doesn't fail on empty/missing user, so we don't either
88+ // see https://github.com/kube-rs/kube/issues/1594
8689 let mut user = config
8790 . auth_infos
8891 . iter ( )
8992 . find ( |named_user| & named_user. name == user_name)
9093 . and_then ( |named_user| named_user. auth_info . clone ( ) )
91- . ok_or_else ( || KubeconfigError :: FindUser ( user_name. clone ( ) ) ) ?;
94+ . unwrap_or_else ( || {
95+ // assuming that empty user is ok but if it's not empty user we should warn
96+ if !user_name. is_empty ( ) {
97+ tracing:: warn!( "User {user_name} wasn't found in kubeconfig, using null auth" ) ;
98+ }
99+ AuthInfo :: default ( )
100+ } ) ;
92101
93102 if let Some ( exec_config) = & mut user. exec {
94103 if exec_config. provide_cluster_info {
Original file line number Diff line number Diff line change @@ -53,10 +53,6 @@ pub enum KubeconfigError {
5353 #[ error( "failed to load the cluster of context: {0}" ) ]
5454 LoadClusterOfContext ( String ) ,
5555
56- /// Failed to find named user
57- #[ error( "failed to find named user: {0}" ) ]
58- FindUser ( String ) ,
59-
6056 /// Failed to find the path of kubeconfig
6157 #[ error( "failed to find the path of kubeconfig" ) ]
6258 FindPath ,
You can’t perform that action at this time.
0 commit comments