Add function to apply netmask to ip #21
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user