Added lua function to get the current hostname
All checks were successful
Build and deploy automation_rs / Build automation_rs (push) Successful in 4m30s
Build and deploy automation_rs / Build Docker image (push) Successful in 39s
Build and deploy automation_rs / Deploy Docker container (push) Has been skipped

This makes it possible to set options depending on what machine we are
running
This commit is contained in:
2024-05-03 19:37:16 +02:00
parent 7e152599a1
commit 808549bcba
4 changed files with 58 additions and 8 deletions

View File

@@ -84,6 +84,12 @@ async fn app() -> anyhow::Result<()> {
std::env::var(name).map_err(mlua::ExternalError::into_lua_err)
})?;
util.set("get_env", get_env)?;
let get_hostname = lua.create_function(|_lua, ()| {
hostname::get()
.map(|name| name.to_str().unwrap_or("unknown").to_owned())
.map_err(mlua::ExternalError::into_lua_err)
})?;
util.set("get_hostname", get_hostname)?;
automation.set("util", util)?;
lua.globals().set("automation", automation)?;