File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,15 @@ impl Config {
114
114
}
115
115
116
116
impl Cluster {
117
- pub fn load_certificate_authority ( & self ) -> Result < Vec < u8 > , Error > {
118
- utils:: data_or_file_with_base64 (
119
- & self . certificate_authority_data ,
120
- & self . certificate_authority ,
121
- )
117
+ pub fn load_certificate_authority ( & self ) -> Option < Result < Vec < u8 > , Error > > {
118
+ if self . certificate_authority_data . is_some ( ) || self . certificate_authority . is_some ( ) {
119
+ Some ( utils:: data_or_file_with_base64 (
120
+ & self . certificate_authority_data ,
121
+ & self . certificate_authority ,
122
+ ) )
123
+ } else {
124
+ None
125
+ }
122
126
}
123
127
}
124
128
Original file line number Diff line number Diff line change @@ -55,8 +55,8 @@ impl KubeConfigLoader {
55
55
. map_err ( Error :: from)
56
56
}
57
57
58
- pub fn ca ( & self ) -> Result < X509 , Error > {
59
- let ca = & self . cluster . load_certificate_authority ( ) ?;
60
- X509 :: from_pem ( & ca) . map_err ( Error :: from)
58
+ pub fn ca ( & self ) -> Option < Result < X509 , Error > > {
59
+ let ca = self . cluster . load_certificate_authority ( ) ?;
60
+ Some ( ca . and_then ( |ca| X509 :: from_pem ( & ca) . map_err ( Error :: from) ) )
61
61
}
62
62
}
Original file line number Diff line number Diff line change @@ -41,10 +41,10 @@ pub fn load_kube_config() -> Result<Configuration, Error> {
41
41
let loader = KubeConfigLoader :: load ( kubeconfig) ?;
42
42
let mut client_builder = Client :: builder ( ) ;
43
43
44
- let ca = loader. ca ( ) ? ;
45
- let req_ca = Certificate :: from_der ( & ca. to_der ( ) ?) ?;
46
- client_builder = client_builder. add_root_certificate ( req_ca) ;
47
-
44
+ if let Some ( ca ) = loader. ca ( ) {
45
+ let req_ca = Certificate :: from_der ( & ca? . to_der ( ) ?) ?;
46
+ client_builder = client_builder. add_root_certificate ( req_ca) ;
47
+ }
48
48
match loader. p12 ( " " ) {
49
49
Ok ( p12) => {
50
50
let req_p12 = Identity :: from_pkcs12_der ( & p12. to_der ( ) ?, " " ) ?;
You can’t perform that action at this time.
0 commit comments