feat: fix cuddle_releaser
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
f4e7ced9d8
commit
a6dab9a178
@ -13,7 +13,7 @@ pub struct CuddleVars {
|
|||||||
pub service: String,
|
pub service: String,
|
||||||
pub registry: String,
|
pub registry: String,
|
||||||
|
|
||||||
pub clusters: CuddleClusters,
|
pub clusters: Option<CuddleClusters>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||||
@ -116,7 +116,7 @@ scripts:
|
|||||||
vars: CuddleVars {
|
vars: CuddleVars {
|
||||||
service: "infrastructure-example".into(),
|
service: "infrastructure-example".into(),
|
||||||
registry: "kasperhermansen".into(),
|
registry: "kasperhermansen".into(),
|
||||||
clusters: CuddleClusters(clusters),
|
clusters: Some(CuddleClusters(clusters)),
|
||||||
},
|
},
|
||||||
deployment: Some(crate::cuddle_file::CuddleDeployment {
|
deployment: Some(crate::cuddle_file::CuddleDeployment {
|
||||||
registry: "git@git.front.kjuulh.io:kjuulh/clank-cluster".into(),
|
registry: "git@git.front.kjuulh.io:kjuulh/clank-cluster".into(),
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use eyre::Context;
|
use eyre::Context;
|
||||||
|
|
||||||
@ -23,11 +25,11 @@ pub enum CuddleEnv {
|
|||||||
Dev,
|
Dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for CuddleEnv {
|
impl Display for CuddleEnv {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
CuddleEnv::Prod => "prod".into(),
|
CuddleEnv::Prod => f.write_str("prod"),
|
||||||
CuddleEnv::Dev => "dev".into(),
|
CuddleEnv::Dev => f.write_str("dev"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,55 +85,57 @@ impl CuddleReleaser {
|
|||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let cluster = match self.cuddle_file.vars.clusters.0.get(chosen_cluster) {
|
if let Some(clusters) = &self.cuddle_file.vars.clusters {
|
||||||
Some(c) => c,
|
let cluster = match clusters.0.get(chosen_cluster) {
|
||||||
None => eyre::bail!("no cluster found for: {}", chosen_cluster),
|
Some(c) => c,
|
||||||
};
|
None => eyre::bail!("no cluster found for: {}", chosen_cluster),
|
||||||
|
};
|
||||||
|
|
||||||
let options = CuddleReleaserOptions {
|
let options = CuddleReleaserOptions {
|
||||||
cluster: chosen_cluster.clone(),
|
cluster: chosen_cluster.clone(),
|
||||||
namespace: cluster.namespace.clone(),
|
namespace: cluster.namespace.clone(),
|
||||||
app: self.cuddle_file.vars.service.clone(),
|
app: self.cuddle_file.vars.service.clone(),
|
||||||
upstream: self
|
upstream: self
|
||||||
.cuddle_file
|
.cuddle_file
|
||||||
.deployment
|
.deployment
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.registry
|
.registry
|
||||||
.clone(),
|
.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let cuddle_releaser_image = "docker.io/kasperhermansen/cuddle-releaser:main-1706726858";
|
let cuddle_releaser_image = "docker.io/kasperhermansen/cuddle-releaser:main-1706726858";
|
||||||
|
|
||||||
let folder = client.host().directory(&self.folder);
|
let folder = client.host().directory(&self.folder);
|
||||||
|
|
||||||
let ssh_sock = std::env::var("SSH_AUTH_SOCK").context("SSH_AUTH_SOCK not set")?;
|
let ssh_sock = std::env::var("SSH_AUTH_SOCK").context("SSH_AUTH_SOCK not set")?;
|
||||||
|
|
||||||
let cuddle_releaser = client
|
let cuddle_releaser = client
|
||||||
.container()
|
.container()
|
||||||
.from(cuddle_releaser_image)
|
.from(cuddle_releaser_image)
|
||||||
.with_env_variable("RUST_LOG", "trace")
|
.with_env_variable("RUST_LOG", "trace")
|
||||||
.with_directory("/mnt/templates", folder)
|
.with_directory("/mnt/templates", folder)
|
||||||
.with_unix_socket(
|
.with_unix_socket(
|
||||||
ssh_sock.clone(),
|
ssh_sock.clone(),
|
||||||
client.host().unix_socket(ssh_sock.clone()),
|
client.host().unix_socket(ssh_sock.clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let time = chrono::Local::now();
|
let time = chrono::Local::now();
|
||||||
|
|
||||||
cuddle_releaser
|
cuddle_releaser
|
||||||
.with_exec(vec!["echo", &time.to_rfc3339()])
|
.with_exec(vec!["echo", &time.to_rfc3339()])
|
||||||
.with_exec(vec![
|
.with_exec(vec![
|
||||||
"cuddle-releaser",
|
"cuddle-releaser",
|
||||||
"release",
|
"release",
|
||||||
&format!("--upstream={}", options.upstream),
|
&format!("--upstream={}", options.upstream),
|
||||||
&format!("--folder={}", "/mnt/templates/k8s"),
|
&format!("--folder={}", "/mnt/templates/k8s"),
|
||||||
&format!("--cluster={}", options.cluster),
|
&format!("--cluster={}", options.cluster),
|
||||||
&format!("--namespace={}", options.namespace),
|
&format!("--namespace={}", options.namespace),
|
||||||
&format!("--app={}", options.app),
|
&format!("--app={}", options.app),
|
||||||
])
|
])
|
||||||
.sync()
|
.sync()
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use std::{path::PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use dagger_rust::source::RustSource;
|
use dagger_rust::source::RustSource;
|
||||||
use dagger_sdk::Container;
|
use dagger_sdk::Container;
|
||||||
use futures::{StreamExt};
|
use futures::StreamExt;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli,
|
cli,
|
||||||
|
Loading…
Reference in New Issue
Block a user