Skip to content

Commit 59690bc

Browse files
John ZakrzewskiJohn Zakrzewski
authored andcommitted
resolving comments
Signed-off-by: John Zakrzewski <[email protected]>
1 parent d94524e commit 59690bc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

control-plane/csi-driver/src/bin/controller/client.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,13 @@ impl RestApiClient {
126126
let ca_certificate_path = cfg.ca_certificate_path();
127127
let cert = match ca_certificate_path {
128128
Some(path) => {
129-
let cert = std::fs::read(path).expect("Failed to read certificate file");
129+
let cert = std::fs::read(path)
130+
.map_err(|error| {
131+
anyhow::anyhow!(
132+
"Failed to create openapi configuration, Error: '{:?}'",
133+
error
134+
)
135+
})?;
130136
Some(cert)
131137
},
132138
None => None,

control-plane/csi-driver/src/bin/controller/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Context;
22
use clap::ArgMatches;
33
use once_cell::sync::OnceCell;
4-
use std::{collections::HashMap, time::Duration};
4+
use std::{collections::HashMap, path::{PathBuf, Path}, time::Duration};
55

66
static CONFIG: OnceCell<CsiControllerConfig> = OnceCell::new();
77

@@ -18,7 +18,7 @@ pub(crate) struct CsiControllerConfig {
1818
/// Force unstage volume.
1919
force_unstage_volume: bool,
2020
/// Path to the CA certificate file.
21-
ca_certificate_path: Option<String>,
21+
ca_certificate_path: Option<PathBuf>,
2222
}
2323

2424
impl CsiControllerConfig {
@@ -54,7 +54,7 @@ impl CsiControllerConfig {
5454
);
5555
};
5656

57-
let ca_certificate_path = args.get_one::<String>("tls-client-ca-path");
57+
let ca_certificate_path: Option<&PathBuf> = args.get_one::<PathBuf>("tls-client-ca-path");
5858

5959
CONFIG.get_or_init(|| Self {
6060
rest_endpoint: rest_endpoint.into(),
@@ -99,7 +99,7 @@ impl CsiControllerConfig {
9999
}
100100

101101
/// Path to the CA certificate file.
102-
pub(crate) fn ca_certificate_path(&self) -> Option<&str> {
102+
pub(crate) fn ca_certificate_path(&self) -> Option<&Path> {
103103
self.ca_certificate_path.as_deref()
104104
}
105105
}

control-plane/csi-driver/src/bin/controller/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async fn main() -> anyhow::Result<()> {
134134
.arg(
135135
Arg::new("tls-client-ca-path")
136136
.long("tls-client-ca-path")
137-
.help("path to the CA certificate file"),
137+
.help("path to the CA certificate file")
138138
)
139139
.get_matches();
140140

0 commit comments

Comments
 (0)