(config: KubernetesComputeConfig)
| 215 | |
| 216 | impl KubernetesComputeDriver { |
| 217 | pub async fn new(config: KubernetesComputeConfig) -> Result<Self, KubernetesDriverError> { |
| 218 | config |
| 219 | .validate_provider_spiffe_workload_api_socket_path() |
| 220 | .map_err(KubernetesDriverError::Precondition)?; |
| 221 | config |
| 222 | .validate_sandbox_identity_config() |
| 223 | .map_err(KubernetesDriverError::Precondition)?; |
| 224 | let base_config = match kube::Config::incluster() { |
| 225 | Ok(c) => c, |
| 226 | Err(_) => kube::Config::infer() |
| 227 | .await |
| 228 | .map_err(kube::Error::InferConfig) |
| 229 | .map_err(KubernetesDriverError::from_kube)?, |
| 230 | }; |
| 231 | |
| 232 | let mut kube_config = base_config.clone(); |
| 233 | kube_config.connect_timeout = Some(Duration::from_secs(10)); |
| 234 | kube_config.read_timeout = Some(Duration::from_secs(30)); |
| 235 | kube_config.write_timeout = Some(Duration::from_secs(30)); |
| 236 | let client = Client::try_from(kube_config).map_err(KubernetesDriverError::from_kube)?; |
| 237 | |
| 238 | let mut watch_kube_config = base_config; |
| 239 | watch_kube_config.connect_timeout = Some(Duration::from_secs(10)); |
| 240 | watch_kube_config.read_timeout = None; |
| 241 | watch_kube_config.write_timeout = Some(Duration::from_secs(30)); |
| 242 | let watch_client = |
| 243 | Client::try_from(watch_kube_config).map_err(KubernetesDriverError::from_kube)?; |
| 244 | |
| 245 | Ok(Self { |
| 246 | client, |
| 247 | watch_client, |
| 248 | sandbox_api_version: Arc::new(OnceCell::new()), |
| 249 | config, |
| 250 | }) |
| 251 | } |
| 252 | |
| 253 | pub fn capabilities(&self) -> Result<GetCapabilitiesResponse, String> { |
| 254 | Ok(openshell_core::driver_utils::build_capabilities_response( |
nothing calls this directly
no test coverage detected