-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(kube): begin implementation of api discovery
- Loading branch information
Showing
4 changed files
with
99 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,3 @@ | ||
pub mod api; | ||
pub mod client; | ||
pub mod hooks; | ||
|
||
// use anyhow::{anyhow, bail, Result}; | ||
// use inflector::Inflector; | ||
// use kube::{ | ||
// api::DynamicObject, | ||
// discovery::{self, ApiGroup, Scope}, | ||
// Api, Client, | ||
// }; | ||
// use tracing::{instrument, Level}; | ||
|
||
// pub async fn init_client() -> Result<Client> { | ||
// Client::try_default() | ||
// .await | ||
// .map_err(|error| anyhow!("failed to init kubernetes client: {error}")) | ||
// } | ||
|
||
// #[instrument(level = Level::INFO, skip(kube))] | ||
// pub async fn get_api( | ||
// kube: Client, | ||
// namespace: Option<&str>, | ||
// api_group: Option<&str>, | ||
// version: Option<&str>, | ||
// kind: &str, | ||
// ) -> Result<Api<DynamicObject>> { | ||
// let api_group = api_group.unwrap_or(ApiGroup::CORE_GROUP); | ||
// let kind_pascal = kind.to_pascal_case(); | ||
|
||
// // Discover most stable version variant of document | ||
// let apigroup = discovery::group(&kube, api_group).await?; | ||
// let (ar, caps) = match match version { | ||
// Some(version) => apigroup.versioned_resources(version), | ||
// None => apigroup.recommended_resources(), | ||
// } | ||
// .into_iter() | ||
// .find(|(ar, _)| ar.kind == kind_pascal) | ||
// { | ||
// Some((ar, caps)) => (ar, caps), | ||
// None => bail!( | ||
// "Cannot find resource: {kind}.{api_group}/{version}", | ||
// api_group = if api_group.is_empty() { | ||
// "core" | ||
// } else { | ||
// api_group | ||
// }, | ||
// version = version.unwrap_or("auto"), | ||
// ), | ||
// }; | ||
|
||
// // Use the discovered kind in an Api, and Controller with the ApiResource as its DynamicType | ||
// Ok(match caps.scope { | ||
// Scope::Cluster => Api::all_with(kube, &ar), | ||
// Scope::Namespaced => match namespace { | ||
// Some(namespace) => Api::namespaced_with(kube, namespace, &ar), | ||
// None => Api::default_namespaced_with(kube, &ar), | ||
// }, | ||
// }) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters