Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions linera-service/src/cli_wrappers/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use linera_base::command::{current_binary_parent, CommandExt};
use pathdiff::diff_paths;
use tokio::process::Command;

use crate::cli_wrappers::local_kubernetes_net::BuildMode;

pub struct DockerImage {
name: String,
}
Expand All @@ -21,7 +23,7 @@ impl DockerImage {
name: &str,
binaries: &BuildArg,
github_root: &PathBuf,
build_mode: &str,
build_mode: &BuildMode,
) -> Result<Self> {
let build_arg = match binaries {
BuildArg::Directory(bin_path) => {
Expand Down Expand Up @@ -63,16 +65,13 @@ impl DockerImage {
.args(["--build-arg", &build_arg]);

match build_mode {
"release" => {
BuildMode::Release => {
command.args(["--build-arg", "build_flag=--release"]);
command.args(["--build-arg", "build_folder=release"]);
}
"debug" => {
BuildMode::Debug => {
command.args(["--build-arg", "build_folder=debug"]);
}
_ => {
return Err(anyhow::anyhow!("Invalid build mode: {}", build_mode));
}
}

#[cfg(not(with_testing))]
Expand Down
29 changes: 25 additions & 4 deletions linera-service/src/cli_wrappers/local_kubernetes_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ static SHARED_LOCAL_KUBERNETES_TESTING_NET: OnceCell<(
ClientWrapper,
)> = OnceCell::const_new();

#[derive(Clone, clap::Parser, clap::ValueEnum, Debug, Default)]
pub enum BuildMode {
Debug,
#[default]
Release,
}

impl std::str::FromStr for BuildMode {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
clap::ValueEnum::from_str(s, true)
}
}

impl std::fmt::Display for BuildMode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}

/// The information needed to start a [`LocalKubernetesNet`].
pub struct LocalKubernetesNetConfig {
pub network: Network,
Expand All @@ -48,7 +69,7 @@ pub struct LocalKubernetesNetConfig {
pub binaries: BuildArg,
pub no_build: bool,
pub docker_image_name: String,
pub build_mode: String,
pub build_mode: BuildMode,
pub policy_config: ResourceControlPolicyConfig,
}

Expand All @@ -67,7 +88,7 @@ pub struct LocalKubernetesNet {
binaries: BuildArg,
no_build: bool,
docker_image_name: String,
build_mode: String,
build_mode: BuildMode,
kubectl_instance: Arc<Mutex<KubectlInstance>>,
kind_clusters: Vec<KindCluster>,
num_initial_validators: usize,
Expand Down Expand Up @@ -104,7 +125,7 @@ impl SharedLocalKubernetesNetTestingConfig {
binaries,
no_build: false,
docker_image_name: String::from("linera:latest"),
build_mode: String::from("release"),
build_mode: BuildMode::Release,
policy_config: ResourceControlPolicyConfig::Testnet,
})
}
Expand Down Expand Up @@ -312,7 +333,7 @@ impl LocalKubernetesNet {
binaries: BuildArg,
no_build: bool,
docker_image_name: String,
build_mode: String,
build_mode: BuildMode,
kubectl_instance: KubectlInstance,
kind_clusters: Vec<KindCluster>,
num_initial_validators: usize,
Expand Down
4 changes: 3 additions & 1 deletion linera-service/src/linera/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use linera_client::{
util,
};
use linera_rpc::config::CrossChainConfig;
#[cfg(feature = "kubernetes")]
use linera_service::cli_wrappers::local_kubernetes_net::BuildMode;
use linera_service::util::{
DEFAULT_PAUSE_AFTER_GQL_MUTATIONS_SECS, DEFAULT_PAUSE_AFTER_LINERA_SERVICE_SECS,
};
Expand Down Expand Up @@ -921,7 +923,7 @@ pub enum NetCommand {
/// The build mode to use.
#[cfg(feature = "kubernetes")]
#[arg(long, default_value = "release")]
build_mode: String,
build_mode: BuildMode,

/// Run with a specific path where the wallet and validator input files are.
/// If none, then a temporary directory is created.
Expand Down
4 changes: 2 additions & 2 deletions linera-service/src/linera/net_up_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use tokio_util::sync::CancellationToken;
use tracing::info;
#[cfg(feature = "kubernetes")]
use {
linera_service::cli_wrappers::local_kubernetes_net::LocalKubernetesNetConfig,
linera_service::cli_wrappers::local_kubernetes_net::{BuildMode, LocalKubernetesNetConfig},
std::path::PathBuf,
};

Expand Down Expand Up @@ -115,7 +115,7 @@ pub async fn handle_net_up_kubernetes(
binaries: &Option<Option<PathBuf>>,
no_build: bool,
docker_image_name: String,
build_mode: String,
build_mode: BuildMode,
policy_config: ResourceControlPolicyConfig,
with_faucet: bool,
faucet_chain: Option<u32>,
Expand Down