feat: make sure to add values property
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
9aa3e88b32
commit
e479c79cc9
@ -1,4 +1,4 @@
|
|||||||
use std::{path::PathBuf, time::UNIX_EPOCH};
|
use std::{collections::BTreeMap, path::PathBuf, time::UNIX_EPOCH};
|
||||||
|
|
||||||
const DRONE_TEMPLATER_IMAGE: &str = "kasperhermansen/drone-templater:main-1711807810";
|
const DRONE_TEMPLATER_IMAGE: &str = "kasperhermansen/drone-templater:main-1711807810";
|
||||||
|
|
||||||
@ -10,6 +10,8 @@ use crate::MainAction;
|
|||||||
pub struct DroneTemplater {
|
pub struct DroneTemplater {
|
||||||
client: dagger_sdk::Query,
|
client: dagger_sdk::Query,
|
||||||
template: PathBuf,
|
template: PathBuf,
|
||||||
|
|
||||||
|
variables: BTreeMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DroneTemplater {
|
impl DroneTemplater {
|
||||||
@ -17,8 +19,19 @@ impl DroneTemplater {
|
|||||||
Self {
|
Self {
|
||||||
client: client.pipeline("drone-templater"),
|
client: client.pipeline("drone-templater"),
|
||||||
template: template.into(),
|
template: template.into(),
|
||||||
|
variables: BTreeMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_variable(
|
||||||
|
&mut self,
|
||||||
|
name: impl Into<String>,
|
||||||
|
value: impl Into<String>,
|
||||||
|
) -> &mut Self {
|
||||||
|
self.variables.insert(name.into(), value.into());
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@ -36,6 +49,18 @@ impl MainAction for DroneTemplater {
|
|||||||
.duration_since(UNIX_EPOCH)
|
.duration_since(UNIX_EPOCH)
|
||||||
.context("failed to get system time")?;
|
.context("failed to get system time")?;
|
||||||
|
|
||||||
|
let template_name = self.template.display().to_string();
|
||||||
|
|
||||||
|
let mut cmd = vec!["drone-templater", "upload", "--template", &template_name]
|
||||||
|
.into_iter()
|
||||||
|
.map(|v| v.to_string())
|
||||||
|
.chain(
|
||||||
|
self.variables
|
||||||
|
.iter()
|
||||||
|
.map(|(name, value)| format!(r#"--variable='{name}={value}'"#)),
|
||||||
|
)
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
self.client
|
self.client
|
||||||
.container()
|
.container()
|
||||||
.from(DRONE_TEMPLATER_IMAGE)
|
.from(DRONE_TEMPLATER_IMAGE)
|
||||||
@ -45,12 +70,7 @@ impl MainAction for DroneTemplater {
|
|||||||
.with_env_variable("DRONE_HOST", drone_host)
|
.with_env_variable("DRONE_HOST", drone_host)
|
||||||
.with_env_variable("DRONE_USER", drone_user)
|
.with_env_variable("DRONE_USER", drone_user)
|
||||||
.with_secret_variable("DRONE_TOKEN", drone_token_secret)
|
.with_secret_variable("DRONE_TOKEN", drone_token_secret)
|
||||||
.with_exec(vec![
|
.with_exec(cmd)
|
||||||
"drone-templater",
|
|
||||||
"upload",
|
|
||||||
"--template",
|
|
||||||
&self.template.display().to_string(),
|
|
||||||
])
|
|
||||||
.sync()
|
.sync()
|
||||||
.await
|
.await
|
||||||
.context("failed to upload drone templates with error")?;
|
.context("failed to upload drone templates with error")?;
|
||||||
|
Loading…
Reference in New Issue
Block a user