feat: Add function that applies netmask to ip
Audit / cargo audit (push) Successful in 7m8s
Committed / committed (pull_request) Successful in 42s
CI / cargo shear (pull_request) Successful in 6m11s
CI / prek (pull_request) Successful in 7m43s
Release-plz / Release-plz Release (push) Successful in 9m20s
CI / prek (push) Successful in 9m22s
CI / cargo shear (push) Successful in 9m26s
Release-plz / Release-plz PR (push) Successful in 3m7s

This commit was merged in pull request #21.
This commit is contained in:
2026-04-21 04:46:31 +02:00
parent ca72d08cc1
commit f51746c5df
+9
View File
@@ -16,6 +16,13 @@ pub struct PathEnvironment<'a> {
path: PathBuf, path: PathBuf,
} }
fn apply_netmask(
ip: ViaDeserialize<Ipv4Addr>,
netmask: ViaDeserialize<Ipv4Addr>,
) -> Result<String, minijinja::Error> {
Ok((*ip & *netmask).to_string())
}
impl<'a> PathEnvironment<'a> { impl<'a> PathEnvironment<'a> {
pub fn new(path: &Path) -> Self { pub fn new(path: &Path) -> Self {
let mut env = Environment::new(); let mut env = Environment::new();
@@ -41,6 +48,8 @@ impl<'a> PathEnvironment<'a> {
} }
}); });
env.add_function("apply_netmask", apply_netmask);
// Helper function for getting the path to kubeconfig files // Helper function for getting the path to kubeconfig files
env.add_filter("kubeconfig", move |names: Vec<String>| { env.add_filter("kubeconfig", move |names: Vec<String>| {
names names