feat: added fn get_ca_cert to trait certificateManagement
All checks were successful
Run Check Script / check (pull_request) Successful in 1m40s
All checks were successful
Run Check Script / check (pull_request) Successful in 1m40s
This commit is contained in:
@@ -453,6 +453,39 @@ impl CertificateManagement for K8sAnywhereTopology {
|
||||
details: format!("Created cert into ns: {:#?}", config.namespace.clone()),
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_ca_certificate(
|
||||
&self,
|
||||
cert_name: String,
|
||||
config: &CertificateManagementConfig,
|
||||
) -> Result<String, PreparationError> {
|
||||
let namespace = config.namespace.clone().unwrap();
|
||||
|
||||
let client = self.k8s_client().await.unwrap();
|
||||
|
||||
let secret = client
|
||||
.get_secret_json_value(&cert_name, Some(&namespace))
|
||||
.await?
|
||||
.data;
|
||||
|
||||
let ca_cert = secret
|
||||
.get("data")
|
||||
.ok_or_else(|| PreparationError {
|
||||
msg: format!("failed to get data from secret {}", cert_name),
|
||||
})?
|
||||
.get("ca.crt")
|
||||
.ok_or_else(|| PreparationError {
|
||||
msg: format!("failed to get ca.crt from secret {}", cert_name),
|
||||
})?;
|
||||
|
||||
trace!("{:#?}", ca_cert.clone());
|
||||
|
||||
let cert: String = serde_json::from_value(ca_cert.clone())
|
||||
.map_err(|e| PreparationError { msg: e.to_string() })?;
|
||||
|
||||
trace!("{:#?}", cert.clone());
|
||||
Ok(cert)
|
||||
}
|
||||
}
|
||||
|
||||
impl K8sAnywhereTopology {
|
||||
|
||||
@@ -28,6 +28,12 @@ pub trait CertificateManagement: Send + Sync {
|
||||
issuer_name: String,
|
||||
config: &CertificateManagementConfig,
|
||||
) -> Result<PreparationOutcome, PreparationError>;
|
||||
|
||||
async fn get_ca_certificate(
|
||||
&self,
|
||||
cert_name: String,
|
||||
config: &CertificateManagementConfig,
|
||||
) -> Result<String, PreparationError>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
|
||||
Reference in New Issue
Block a user