chore: rename things to be more to my liking
All checks were successful
/ build (push) Successful in 8m18s

This commit is contained in:
Tamipes 2026-06-15 22:00:44 +02:00
parent 0439f362dd
commit 1e281cf61f
3 changed files with 33 additions and 22 deletions

View file

@ -18,12 +18,13 @@ use crate::{
};
const MAIN_LABEL: &str = "tami.moe/minecraft";
const PORT_LABEL: &str = "tami.moe/minecraft-port";
const URL_ANNOTATION: &str = "tami.moe/minecraft-url";
/// This is the layer who is respinsible for caching requests.
///
/// TODO:
/// It should be also clone-able freely, because it deals with
/// the underlying async data access.
// A heads-up:
// It should be also clone-able freely, because it deals with
// the underlying async data access.
#[derive(Debug, Clone)]
pub struct KubeCache {
// When the store gets copied, it points to the same backing store
@ -40,6 +41,11 @@ impl KubeCache {
///
/// It also returns a JoinHandle which is tied to the api watcher
/// and if it returns that means that the kubecache is not responsive now.
///
/// # Example:
/// ```no_run
/// let (kube_cache, api_task) = kube_cache::KubeCache::create().await.unwrap();
/// ```
pub async fn create() -> Option<(KubeCache, JoinHandle<()>)> {
let in_cluster = match std::env::var("KUBERNETES_SERVICE_HOST") {
Ok(_) => true,
@ -60,7 +66,7 @@ impl KubeCache {
.for_each(|_o| std::future::ready(()));
let _res = infinite_watch.await;
tracing::error!(
"Deployments watcher ended. This should not happen. (Program should exit now)"
"deployments watcher ended; this should not happen; (program should exit now)"
);
});
@ -77,6 +83,9 @@ impl KubeCache {
));
}
fn get_dep(&self, name: &str) -> Option<Arc<Deployment>> {
// dep.name_any() has the caveat of returning "" if it can't query for
// a name, resulting in unexpected behaviour if that happens and also
// a query for "" comes as well.
self.dep_cache.find(|x| x.name_any() == name)
}
async fn get_srv(&self, name: &str) -> Result<Service, kube::Error> {
@ -298,13 +307,16 @@ impl MinecraftServerHandle for Server {
fn get_internal_address(&self) -> &str {
self.internal_address.as_str()
}
fn get_addr(&self) -> String {
self.server_addr.clone()
fn get_internal_id(&self) -> &str {
self.internal_id.as_str()
}
fn get_port(&self) -> String {
self.server_port.clone()
fn get_join_addr(&self) -> &str {
self.server_addr.as_ref()
}
fn get_join_port(&self) -> &str {
self.server_port.as_ref()
}
fn get_motd(&self) -> Option<String> {