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
2 changes: 1 addition & 1 deletion lib/api-helper/build/src/start.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{convert::Infallible, future::Future, net::SocketAddr, sync::Arc, time::Instant};
use std::{convert::Infallible, future::Future, net::SocketAddr, time::Instant};

use hyper::{
body::HttpBody,
Expand Down
2 changes: 1 addition & 1 deletion lib/bolt/cli/src/commands/admin/cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl SubCommand {
admin_clusters_api::admin_clusters_create(
&ctx.openapi_config_cloud().await?,
models::AdminClustersCreateRequest {
name_id: name_id,
name_id,
owner_team_id: Some(Uuid::parse_str(&owner_team_id).unwrap()),
},
)
Expand Down
6 changes: 3 additions & 3 deletions lib/bolt/cli/src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ impl SubCommand {
match self {
Self::Generate { namespace } => {
let project_root = context::ProjectContextData::seek_project_root().await;
tasks::config::generate(&project_root, &namespace).await?;
tasks::config::generate(&project_root, namespace).await?;
}
Self::SetNamespace { namespace } => {
tasks::config::set_namespace(&namespace).await?;
tasks::config::set_namespace(namespace).await?;
}
Self::ServiceDependencies {
svc_name,
Expand Down Expand Up @@ -429,7 +429,7 @@ impl SubCommand {
.context("failed to read namespace config")?;
let local_secrets_str = fs::read_to_string(&secrets_path).await?;
let secrets =
ProjectContextData::read_secrets(Some(ctx.ns()), ctx.path(), &ns_id).await;
ProjectContextData::read_secrets(Some(ctx.ns()), ctx.path(), ns_id).await;

let ns_patches = json_patch::diff(&op_namespace, &namespace);
if !ns_patches.is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions lib/bolt/cli/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ impl SubCommand {
};

assert!(
!pkg_name.contains("_"),
!pkg_name.contains('_'),
"package name should not contain underscores, use dashes"
);

assert!(
!service_name.contains("_"),
!service_name.contains('_'),
"service name should not contain underscores, use dashes"
);

Expand Down
2 changes: 1 addition & 1 deletion lib/bolt/cli/src/commands/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl SubCommand {
tasks::db::shell(
&ctx,
&ctx.service_with_name(&service).await,
query.as_ref().map(String::as_str),
query.as_deref(),
)
.await?;

Expand Down
6 changes: 3 additions & 3 deletions lib/bolt/cli/src/commands/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl SubCommand {
optional,
format,
} => {
let path = path.split("/").collect::<Vec<_>>();
let path = path.split('/').collect::<Vec<_>>();

// Fetch value
let value = if optional {
Expand All @@ -49,14 +49,14 @@ impl SubCommand {
if let Some(value) = value {
println!("{value}")
} else {
println!("")
println!()
}
}
Some(Format::Json) => println!("{}", json!({ "value": value })),
}
}
Self::Set { path, value } => {
let path = path.split("/").collect::<Vec<_>>();
let path = path.split('/').collect::<Vec<_>>();

let mut generator = ConfigGenerator::new(ctx.path(), ctx.ns_id()).await?;
generator.set_secret(&path, toml_edit::value(value)).await?;
Expand Down
6 changes: 3 additions & 3 deletions lib/bolt/cli/src/commands/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ impl SubCommand {
&ctx,
&ip,
&ssh_key,
command.as_ref().map(String::as_str),
command.as_deref(),
)
.await?;
}
Self::Id { server_id, command } => {
bolt_core::tasks::ssh::id(&ctx, &server_id, command.as_ref().map(String::as_str))
bolt_core::tasks::ssh::id(&ctx, &server_id, command.as_deref())
.await?;
}
Self::Pool { pool, command, all } => {
if all {
let command = command.context("must provide command with --all")?;
bolt_core::tasks::ssh::pool_all(&ctx, &pool, &command).await?;
} else {
bolt_core::tasks::ssh::pool(&ctx, &pool, command.as_ref().map(String::as_str))
bolt_core::tasks::ssh::pool(&ctx, &pool, command.as_deref())
.await?;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/bolt/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn prompt_prod(ctx: &bolt_core::context::ProjectContextData) -> Result<()>
.await?;

if response {
return Ok(());
Ok(())
} else {
bail!("Bailing");
}
Expand Down
31 changes: 4 additions & 27 deletions lib/bolt/config/src/ns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,12 @@ impl Default for Docker {
}
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Nomad {
pub health_checks: Option<bool>,
}

impl Default for Nomad {
fn default() -> Self {
Self {
health_checks: None,
}
}
}

#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Kubernetes {
Expand Down Expand Up @@ -570,7 +562,7 @@ pub struct RivetTest {
pub load_tests: bool,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Api {
#[serde(default)]
Expand All @@ -582,16 +574,6 @@ pub struct Api {
pub hub_origin_regex: Option<String>,
}

impl Default for Api {
fn default() -> Self {
Self {
error_verbose: false,
hub_origin: None,
hub_origin_regex: None,
}
}
}

#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(deny_unknown_fields)]
pub struct Profanity {
Expand Down Expand Up @@ -627,20 +609,15 @@ pub struct Provisioning {
pub acme_directory: ProvisioningAcmeDirectory,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub enum ProvisioningAcmeDirectory {
#[serde(rename = "lets_encrypt")]
#[default]
LetsEncrypt,
#[serde(rename = "lets_encrypt_staging")]
LetsEncryptStaging,
}

impl Default for ProvisioningAcmeDirectory {
fn default() -> Self {
ProvisioningAcmeDirectory::LetsEncryptStaging
}
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
pub struct ProvisioningCluster {
Expand Down
5 changes: 1 addition & 4 deletions lib/bolt/config/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,7 @@ impl ServiceKind {
/// because this will be true for any services that are internally-facing HTTP servers, such as
/// `api-job`.
pub fn has_server(&self) -> bool {
match self {
ServiceKind::Api { .. } | ServiceKind::Static { .. } => true,
_ => false,
}
matches!(self, ServiceKind::Api { .. } | ServiceKind::Static { .. })
}

pub fn short(&self) -> &str {
Expand Down
22 changes: 10 additions & 12 deletions lib/bolt/core/src/context/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl ProjectContextData {
reader: impl FnOnce(&config::cache::Cache) -> T + Sized,
) -> T {
let cache = self.cache.lock().await;
reader(&*cache)
reader(&cache)
}

pub async fn cache_mut<T: Sized>(
Expand All @@ -69,7 +69,7 @@ impl ProjectContextData {
) -> T {
let res = {
let mut cache = self.cache.lock().await;
reader(&mut *cache)
reader(&mut cache)
};

self.write_cache().await;
Expand Down Expand Up @@ -368,7 +368,7 @@ impl ProjectContextData {
// Load the service
let svc_ctx = context::service::ServiceContextData::from_path(
Weak::new(),
&svc_ctxs_map,
svc_ctxs_map,
&workspace_path,
&worker_path,
)
Expand Down Expand Up @@ -415,7 +415,7 @@ impl ProjectContextData {
// Load the service
let svc_ctx = context::service::ServiceContextData::from_path(
Weak::new(),
&svc_ctxs_map,
svc_ctxs_map,
workspace_path,
&entry.path(),
)
Expand Down Expand Up @@ -461,10 +461,9 @@ impl ProjectContextData {
let path = project_path
.join("namespaces")
.join(format!("{ns_id}.toml"));
let config_str = fs::read_to_string(&path).await.expect(&format!(
"failed to read namespace config: {}",
path.display()
));
let config_str = fs::read_to_string(&path)
.await
.unwrap_or_else(|_| panic!("failed to read namespace config: {}", path.display()));
let config = match toml::from_str::<config::ns::Namespace>(&config_str) {
Result::Ok(x) => x,
Result::Err(err) => {
Expand Down Expand Up @@ -497,8 +496,7 @@ impl ProjectContextData {
project_path: &Path,
ns_id: &str,
) -> serde_json::Value {
let secrets_path = ProjectContextData::get_secrets_path(ns, project_path, &ns_id);

let secrets_path = ProjectContextData::get_secrets_path(ns, project_path, ns_id);
// Read the config
let config_str = fs::read_to_string(&secrets_path)
.await
Expand Down Expand Up @@ -546,7 +544,7 @@ impl ProjectContextData {
name: &str,
) -> context::service::ServiceContext {
if let Some(ctx) = self.svc_ctxs_map.get(name) {
return ctx.clone();
ctx.clone()
} else {
panic!("Could not find service with name {}", name);
}
Expand Down Expand Up @@ -792,7 +790,7 @@ impl ProjectContextData {
.clone()
.unwrap_or_else(|| {
// Create regex pattern from the default hub origin
format!("^{}$", self.origin_hub().replace(".", "\\."))
format!("^{}$", self.origin_hub().replace('.', "\\."))
})
}

Expand Down
8 changes: 4 additions & 4 deletions lib/bolt/core/src/context/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ impl ServiceContextData {
// Aggregate secrets from all dependencies
.flat_map(|x| x.config().secrets.clone().into_iter())
// Convert keys to string array
.map(|(k, v)| (k.split("/").map(|x| x.to_string()).collect::<Vec<_>>(), v))
.map(|(k, v)| (k.split('/').map(|x| x.to_string()).collect::<Vec<_>>(), v))
// Dedupe
.collect::<HashMap<_, _>>()
.into_iter()
Expand Down Expand Up @@ -1025,13 +1025,13 @@ impl ServiceContextData {

if self.depends_on_provision_margin() {
env.insert(
format!("RIVET_JOB_SERVER_PROVISION_MARGIN"),
"RIVET_JOB_SERVER_PROVISION_MARGIN".to_string(),
provisioning.job_server_provision_margin.to_string(),
);
}

env.insert(
format!("TLS_ACME_DIRECTORY"),
"TLS_ACME_DIRECTORY".to_string(),
serde_json::to_value(&provisioning.acme_directory)?
.as_str()
.unwrap()
Expand Down Expand Up @@ -1180,7 +1180,7 @@ impl ServiceContextData {
};

env.insert(
format!("REDIS_URL_{}", db_name.to_uppercase().replace("-", "_")),
format!("REDIS_URL_{}", db_name.to_uppercase().replace('-', "_")),
url,
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/bolt/core/src/dep/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ pub async fn build_tests<'a, T: AsRef<str>>(
let package = v["package_id"]
.as_str()
.context("missing package_id")?
.split_once("#")
.split_once('#')
.context("split_once failed")?
.1
.split_once("@")
.split_once('@')
.context("split_once failed")?
.0;

Expand Down
4 changes: 2 additions & 2 deletions lib/bolt/core/src/dep/k8s/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ fn build_ingress_router(
}

// Build paths for rule
rule.push_str("(");
rule.push('(');
rule.push_str(
&mount
.paths
Expand All @@ -866,7 +866,7 @@ fn build_ingress_router(
.collect::<Vec<_>>()
.join(" || "),
);
rule.push_str(")");
rule.push(')');

if let Some(strip_prefix) = &mount.strip_prefix {
let mw_name = format!("{}-{i}-strip-prefix", svc_ctx.name());
Expand Down
2 changes: 1 addition & 1 deletion lib/bolt/core/src/dep/one_password/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub async fn write(service_token: Option<&str>, op_path: &str, tmp_path: &Path,
let field_json = fields_json
.iter_mut()
.find(|f| f["label"] == field)
.expect(&format!("could not find field {field} in {item}"));
.unwrap_or_else(|| panic!("could not find field {field} in {item}"));
field_json["value"] = content.into();

// Save to file
Expand Down
4 changes: 2 additions & 2 deletions lib/bolt/core/src/dep/terraform/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ lazy_static! {
/// Builds the workspace name that's used for the specific plan. This lets us
/// store multiple workspaces on the same backend.
pub fn build_localized_workspace_name(ns: &str, plan: &str) -> String {
format!("{}-{}", ns.replace("_", "-"), plan.replace("_", "-"))
format!("{}-{}", ns.replace('_', "-"), plan.replace('_', "-"))
}

pub async fn build_command(ctx: &ProjectContext, plan_id: &str) -> Command {
Expand Down Expand Up @@ -120,7 +120,7 @@ pub async fn destroy(ctx: &ProjectContext, plan_id: &str, varfile_path: &Path) -
event.insert_prop("plan_id", plan_id)?;
utils::telemetry::capture_event(ctx, event).await?;

let mut cmd = build_command(&ctx, plan_id).await;
let mut cmd = build_command(ctx, plan_id).await;
cmd.arg("destroy")
.arg(format!("-var-file={}", varfile_path.display()));
cmd.exec().await?;
Expand Down
2 changes: 1 addition & 1 deletion lib/bolt/core/src/dep/terraform/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn gen_remote_state(
let plan_id = &remote_state.plan_id;
let data_name = remote_state.data_name();
let workspace =
dep::terraform::cli::build_localized_workspace_name(ctx.ns_id(), &remote_state.plan_id);
dep::terraform::cli::build_localized_workspace_name(ctx.ns_id(), remote_state.plan_id);

let meta = if let Some(condition) = &remote_state.condition {
format!("count = {condition} ? 1 : 0")
Expand Down
Loading