feat: fix cuddle_releaser
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 2024-03-30 21:03:37 +01:00
parent f4e7ced9d8
commit a6dab9a178
Signed by: kjuulh
GPG Key ID: 9AA7BC13CE474394
3 changed files with 54 additions and 50 deletions

View File

@ -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(),

View File

@ -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,7 +85,8 @@ 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 {
let cluster = match clusters.0.get(chosen_cluster) {
Some(c) => c, Some(c) => c,
None => eyre::bail!("no cluster found for: {}", chosen_cluster), None => eyre::bail!("no cluster found for: {}", chosen_cluster),
}; };
@ -132,6 +135,7 @@ impl CuddleReleaser {
]) ])
.sync() .sync()
.await?; .await?;
}
Ok(()) Ok(())
} }

View File

@ -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,