Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
59748fb6e6
commit
48f142ef58
@ -13,6 +13,7 @@ pub struct CuddleFile {
|
||||
pub struct CuddleComponents {
|
||||
pub database: Option<CuddleDatabase>,
|
||||
pub assets: Option<CuddleAssets>,
|
||||
pub packages: Option<Packages>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
@ -21,6 +22,17 @@ pub struct CuddleAssets {
|
||||
pub clean: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct Packages {
|
||||
pub debian: DebianPackages,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct DebianPackages {
|
||||
pub dev: Vec<String>,
|
||||
pub release: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct CuddleAssetInclude {
|
||||
pub from: PathBuf,
|
||||
@ -111,6 +123,13 @@ components:
|
||||
- from: somewhere
|
||||
to: somewhere-else
|
||||
|
||||
packages:
|
||||
debian:
|
||||
dev:
|
||||
- "capnp"
|
||||
release:
|
||||
- "capnp"
|
||||
|
||||
scripts:
|
||||
render:
|
||||
type: shell
|
||||
@ -159,6 +178,12 @@ scripts:
|
||||
}]),
|
||||
clean: None,
|
||||
}),
|
||||
packages: Some(Packages {
|
||||
debian: DebianPackages {
|
||||
dev: vec!["capnp".into()],
|
||||
release: vec!["capnp".into()],
|
||||
},
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
@ -190,6 +215,49 @@ components:
|
||||
components: Some(CuddleComponents {
|
||||
database: Some(CuddleDatabase::Default {}),
|
||||
assets: None,
|
||||
packages: None,
|
||||
}),
|
||||
};
|
||||
|
||||
pretty_assertions::assert_eq!(expected, res)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cuddle_packages() {
|
||||
let cuddle_file = r#"
|
||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
||||
|
||||
vars:
|
||||
service: "infrastructure-example"
|
||||
registry: kasperhermansen
|
||||
|
||||
components:
|
||||
packages:
|
||||
debian:
|
||||
dev:
|
||||
- "capnp"
|
||||
release:
|
||||
- "capnp"
|
||||
"#;
|
||||
|
||||
let res = CuddleFile::parse_cuddle_file(cuddle_file).expect("to parse file");
|
||||
|
||||
let expected = CuddleFile {
|
||||
vars: CuddleVars {
|
||||
service: "infrastructure-example".into(),
|
||||
registry: "kasperhermansen".into(),
|
||||
clusters: None,
|
||||
},
|
||||
deployment: None,
|
||||
components: Some(CuddleComponents {
|
||||
database: None,
|
||||
assets: None,
|
||||
packages: Some(Packages {
|
||||
debian: DebianPackages {
|
||||
dev: vec!["capnp".into()],
|
||||
release: vec!["capnp".into()],
|
||||
},
|
||||
}),
|
||||
}),
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::cuddle_file::{CuddleDatabase, CuddleFile};
|
||||
use crate::{
|
||||
cuddle_file::{CuddleDatabase, CuddleFile},
|
||||
rust_service::extensions::AptExt,
|
||||
};
|
||||
|
||||
use super::{
|
||||
extensions::{AssetsExt, CargoCleanExt, SqlxExt},
|
||||
@ -54,6 +57,28 @@ impl CuddleFileExt for RustService {
|
||||
s = s.with_assets(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(packages) = &components.packages {
|
||||
s = s
|
||||
.with_apt(
|
||||
packages
|
||||
.debian
|
||||
.dev
|
||||
.iter()
|
||||
.map(|r| r.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
)
|
||||
.with_apt_release(
|
||||
packages
|
||||
.debian
|
||||
.release
|
||||
.iter()
|
||||
.map(|r| r.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
s
|
||||
|
@ -97,8 +97,7 @@ impl RustBuild {
|
||||
|
||||
let mut containers = Vec::new();
|
||||
for container_image in images {
|
||||
let container =
|
||||
match &container_image {
|
||||
let container = match &container_image {
|
||||
SlimImage::Debian { image, deps, .. } => {
|
||||
let target = BuildTarget::from_target(&container_image);
|
||||
|
||||
@ -125,7 +124,11 @@ impl RustBuild {
|
||||
"-p",
|
||||
bin_name,
|
||||
])
|
||||
.file(format!("target/{}/release/{}", target.to_string(), bin_name));
|
||||
.file(format!(
|
||||
"target/{}/release/{}",
|
||||
target.to_string(),
|
||||
bin_name
|
||||
));
|
||||
|
||||
self.build_debian_image(
|
||||
bin,
|
||||
@ -163,7 +166,11 @@ impl RustBuild {
|
||||
"-p",
|
||||
bin_name,
|
||||
])
|
||||
.file(format!("target/{}/release/{}", target.to_string(), bin_name));
|
||||
.file(format!(
|
||||
"target/{}/release/{}",
|
||||
target.to_string(),
|
||||
bin_name
|
||||
));
|
||||
|
||||
self.build_alpine_image(
|
||||
bin,
|
||||
|
Loading…
Reference in New Issue
Block a user