Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions lib/bolt/core/src/tasks/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,15 @@ pub async fn test_services<T: AsRef<str>>(
let k8s_svc_name = format!("test-{test_suite_id}");

// Apply pod
let specs = gen_spec(ctx, &run_context, &rust_svcs, &image, &k8s_svc_name).await;
let specs = gen_spec(
ctx,
&run_context,
&rust_svcs,
&image,
&k8s_svc_name,
ctx.build_svcs_locally(),
)
.await;
dep::k8s::cli::apply_specs(ctx, specs).await?;

// Wait for pod to start
Expand Down Expand Up @@ -838,6 +846,7 @@ pub async fn gen_spec(
svcs: &[&ServiceContext],
image: &str,
k8s_svc_name: &str,
build_svcs_locally: bool,
) -> Vec<serde_json::Value> {
let mut specs = Vec::new();

Expand Down Expand Up @@ -874,7 +883,7 @@ pub async fn gen_spec(
"data": secret_data
}));

let (volumes, volume_mounts) = build_volumes(ctx, run_context, svcs).await;
let (volumes, volume_mounts) = build_volumes(ctx, run_context, svcs, build_svcs_locally).await;

let metadata = json!({
"name": k8s_svc_name,
Expand Down Expand Up @@ -934,40 +943,43 @@ pub async fn build_volumes(
project_ctx: &ProjectContext,
run_context: &RunContext,
svcs: &[&ServiceContext],
build_svcs_locally: bool,
) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {
// Shared data between containers
let mut volumes = Vec::<serde_json::Value>::new();
let mut volume_mounts = Vec::<serde_json::Value>::new();

match &project_ctx.ns().cluster.kind {
ns::ClusterKind::SingleNode { .. } => {
// Volumes
volumes.push(json!({
"name": "target",
"hostPath": {
"path": "/target",
"type": "Directory"
}
}));
volumes.push(json!({
"name": "nix-store",
"hostPath": {
"path": "/nix/store",
"type": "Directory"
}
}));
if build_svcs_locally {
// Volumes
volumes.push(json!({
"name": "target",
"hostPath": {
"path": "/target",
"type": "Directory"
}
}));
volumes.push(json!({
"name": "nix-store",
"hostPath": {
"path": "/nix/store",
"type": "Directory"
}
}));

// Mounts
volume_mounts.push(json!({
"name": "target",
"mountPath": "/target",
"readOnly": true
}));
volume_mounts.push(json!({
"name": "nix-store",
"mountPath": "/nix/store",
"readOnly": true
}));
// Mounts
volume_mounts.push(json!({
"name": "target",
"mountPath": "/target",
"readOnly": true
}));
volume_mounts.push(json!({
"name": "nix-store",
"mountPath": "/nix/store",
"readOnly": true
}));
}
}
ns::ClusterKind::Distributed { .. } => {
// Those volumes only exist on single node setups
Expand Down