From c3753254ed2cd066a5705f8d3a87eceb4c7c5b53 Mon Sep 17 00:00:00 2001 From: NathanFlurry Date: Wed, 3 Jul 2024 08:44:22 +0000 Subject: [PATCH] chore(k3d): disable volumes if using use_local_repo (#954) ## Changes --- infra/tf/k8s_cluster_k3d/main.tf | 33 ++++++++++++++++---------- infra/tf/k8s_cluster_k3d/vars.tf | 4 ++++ lib/bolt/core/src/dep/terraform/gen.rs | 9 +++++++ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/infra/tf/k8s_cluster_k3d/main.tf b/infra/tf/k8s_cluster_k3d/main.tf index 1c6eb8f8da..cdcfbda552 100644 --- a/infra/tf/k8s_cluster_k3d/main.tf +++ b/infra/tf/k8s_cluster_k3d/main.tf @@ -16,23 +16,32 @@ resource "k3d_cluster" "main" { name = "rivet-${var.namespace}" # Mount repository in to k3d so we can access the built binaries - volume { - source = var.cargo_target_dir - destination = "/target" - node_filters = ["server:0"] + dynamic "volume" { + for_each = var.k3d_use_local_repo ? [] : [0] + content { + source = var.cargo_target_dir + destination = "/target" + node_filters = ["server:0"] + } } # Mount the /nix/store and /local since the build binaries depend on dynamic libs from there - volume { - source = "/nix/store" - destination = "/nix/store" - node_filters = ["server:0"] + dynamic "volume" { + for_each = var.k3d_use_local_repo ? [] : [0] + content { + source = "/nix/store" + destination = "/nix/store" + node_filters = ["server:0"] + } } - volume { - source = "/local" - destination = "/local" - node_filters = ["server:0"] + dynamic "volume" { + for_each = var.k3d_use_local_repo ? [] : [0] + content { + source = "/local" + destination = "/local" + node_filters = ["server:0"] + } } # HTTP diff --git a/infra/tf/k8s_cluster_k3d/vars.tf b/infra/tf/k8s_cluster_k3d/vars.tf index 559a161046..1a08a35c84 100644 --- a/infra/tf/k8s_cluster_k3d/vars.tf +++ b/infra/tf/k8s_cluster_k3d/vars.tf @@ -2,6 +2,10 @@ variable "namespace" { type = string } +variable "k3d_use_local_repo" { + type = bool +} + variable "project_root" { type = string } diff --git a/lib/bolt/core/src/dep/terraform/gen.rs b/lib/bolt/core/src/dep/terraform/gen.rs index 22631662ea..15d0d10cae 100644 --- a/lib/bolt/core/src/dep/terraform/gen.rs +++ b/lib/bolt/core/src/dep/terraform/gen.rs @@ -273,6 +273,15 @@ async fn vars(ctx: &ProjectContext) { "cargo_target_dir".into(), json!(ctx.cargo_target_dir().display().to_string()), ); + vars.insert( + "k3d_use_local_repo".into(), + json!(matches!( + &config.kubernetes.provider, + ns::KubernetesProvider::K3d { + use_local_repo: true + } + )), + ); // Services {