feat: enable checking if it should actually run
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2025-01-04 01:52:05 +01:00
parent 83294306a4
commit 03e23c7d9d
4 changed files with 36 additions and 3 deletions

15
Cargo.lock generated
View File

@ -382,6 +382,7 @@ dependencies = [
"futures", "futures",
"nodrift", "nodrift",
"notmad", "notmad",
"petname",
"prost", "prost",
"prost-types", "prost-types",
"reqwest", "reqwest",
@ -1781,6 +1782,20 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "petname"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cd31dcfdbbd7431a807ef4df6edd6473228e94d5c805e8cf671227a21bad068"
dependencies = [
"anyhow",
"clap",
"itertools",
"proc-macro2",
"quote",
"rand",
]
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.1.7" version = "1.1.7"

View File

@ -37,3 +37,4 @@ reqwest = { version = "0.12.9", default-features = false, features = [
serde_json = "1.0.133" serde_json = "1.0.133"
wasmtime = "28.0.0" wasmtime = "28.0.0"
wasmtime-wasi = "28.0.0" wasmtime-wasi = "28.0.0"
petname = "2.0.2"

View File

@ -124,11 +124,21 @@ impl InnerPluginStore {
pub async fn execute(&mut self, plugin: &str) -> anyhow::Result<()> { pub async fn execute(&mut self, plugin: &str) -> anyhow::Result<()> {
let plugin = self.ensure_plugin(plugin).await?; let plugin = self.ensure_plugin(plugin).await?;
plugin if plugin
.interface0 .interface0
.call_execute(&mut self.store) .call_should_run(&mut self.store)
.await .await
.context("Failed to call add function") .context("Failed to call should run")?
{
tracing::info!("job was marked as required to run");
return plugin
.interface0
.call_execute(&mut self.store)
.await
.context("Failed to call add function");
}
Ok(())
} }
async fn ensure_plugin(&mut self, plugin: &str) -> anyhow::Result<Churn> { async fn ensure_plugin(&mut self, plugin: &str) -> anyhow::Result<Churn> {

View File

@ -31,6 +31,13 @@ pub async fn execute() -> anyhow::Result<()> {
setup_labels.insert(k, v); setup_labels.insert(k, v);
} }
if !setup_labels.contains_key("node_name") {
setup_labels.insert(
"node_name".into(),
petname::petname(2, "-").expect("to be able to generate a valid petname"),
);
}
agent::setup_config(discovery, force, setup_labels).await?; agent::setup_config(discovery, force, setup_labels).await?;
tracing::info!("wrote default agent config"); tracing::info!("wrote default agent config");
} }