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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/docs

/target
*.zip
*.txt
Expand All @@ -14,4 +16,4 @@ MultiTool.yaml
# Remove any workers user for development
/worker/**
wrangler.toml
wrangler.json
wrangler.json
2 changes: 1 addition & 1 deletion src/adapters/backend/deploy_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) type RolloutId = u64;
/// rollout. This struct is mostly used in conjuction with a `BackendClient`
/// to hold the context for the current rollout.
#[derive(Builder, Getters, Clone)]
pub(crate) struct RolloutMetadata {
pub struct RolloutMetadata {
workspace_id: WorkspaceId,
application_id: ApplicationId,
rollout_id: RolloutId,
Expand Down
22 changes: 11 additions & 11 deletions src/adapters/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tokio::sync::mpsc::Sender;
use tokio::sync::oneshot;
use tokio::time::Duration;

pub(crate) use deploy_meta::*;
pub use deploy_meta::*;
use tracing::trace;

/// Write the CLI's version to a
Expand Down Expand Up @@ -84,7 +84,7 @@ impl BackendClient {

pub fn is_authenicated(&self) -> Result<()> {
if self.session.clone().is_some_and(Session::is_not_expired) {
return Ok(());
Ok(())
} else {
bail!("Please login before running this command.");
}
Expand Down Expand Up @@ -343,9 +343,9 @@ impl BackendClient {
};
let metrics = StatusCodeMetrics {
app_group: group,
status_2xx_count: item.get_count(&ResponseStatusCode::_2XX) as u32,
status_4xx_count: item.get_count(&ResponseStatusCode::_4XX) as u32,
status_5xx_count: item.get_count(&ResponseStatusCode::_5XX) as u32,
status_2xx_count: item.get_count(&ResponseStatusCode::_2XX),
status_4xx_count: item.get_count(&ResponseStatusCode::_4XX),
status_5xx_count: item.get_count(&ResponseStatusCode::_5XX),
created_at: item.created_at().to_rfc3339(),
};

Expand Down Expand Up @@ -427,8 +427,8 @@ impl BackendClient {

pub(crate) async fn create_application<T: AsRef<str>>(
&self,
workspace_id: WorkspaceId,
name: T,
_workspace_id: WorkspaceId,
_name: T,
) -> Result<ApplicationDetails> {
self.is_authenicated()?;

Expand All @@ -454,7 +454,7 @@ impl BackendClient {

if workspaces.len() > 1 {
bail!("More than one workspace with the given name found.");
} else if workspaces.len() < 1 {
} else if workspaces.is_empty() {
bail!("No workspace with the given name exists for this account");
} else {
// TODO: We can simplify this code with .ok_or()
Expand Down Expand Up @@ -488,7 +488,7 @@ impl BackendClient {

let application = if applications.len() > 1 {
bail!("More than one application with the given name found.");
} else if applications.len() < 1 {
} else if applications.is_empty() {
bail!("No application with the given name exists for this account");
} else {
// TODO: We can simplify this code with .ok_or()
Expand Down Expand Up @@ -535,8 +535,8 @@ impl BackendConfig {
// • Convert the Option<T> to a String.
let origin = origin.map(|val| val.as_ref().to_owned());
// • Set up the default configuration values.
let jwt = session.and_then(|session| match session {
Session::User(creds) => Some(creds.jwt),
let jwt = session.map(|session| match session {
Session::User(creds) => creds.jwt,
});
let conf = Configuration {
base_path: origin.unwrap_or(MULTITOOL_ORIGIN.to_string()),
Expand Down
9 changes: 2 additions & 7 deletions src/adapters/cloudflare/deployments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ use bon::Builder;
use derive_getters::Getters;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum DeploymentStrategy {
#[serde(rename = "percentage")]
#[default]
Percentage,
}

impl Default for DeploymentStrategy {
fn default() -> Self {
Self::Percentage
}
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Builder, Getters)]
pub struct CreateDeploymentRequest {
#[serde(default)]
Expand Down
7 changes: 4 additions & 3 deletions src/adapters/cloudflare/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct EventData {

#[derive(Deserialize, Debug)]
pub struct RequestData {
#[allow(dead_code)] // TODO: Why is this dead?
pub url: String,
pub method: String,
pub path: String,
Expand Down Expand Up @@ -78,11 +79,11 @@ pub struct CloudflareErrorLog {
pub logs: Vec<String>,
}

impl Into<Vec<CloudflareErrorLog>> for ErrorLogsResponse {
fn into(self) -> Vec<CloudflareErrorLog> {
impl From<ErrorLogsResponse> for Vec<CloudflareErrorLog> {
fn from(val: ErrorLogsResponse) -> Self {
let mut error_logs = Vec::new();

for (_request_id, invocations) in self.invocations {
for (_request_id, invocations) in val.invocations {
// The cf-worker-event entry contains the request/response details
let event_entry = invocations
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/cloudflare/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ impl CloudflareClient {
let count = metrics_response
.result
.calculations
.get(0)
.and_then(|c| c.aggregates.get(0).cloned())
.first()
.and_then(|c| c.aggregates.first().cloned())
.map_or(0, |a| a.count);

Ok(count)
Expand Down
6 changes: 6 additions & 0 deletions src/adapters/cloudflare/uploads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ use serde::{Deserialize, Serialize};

use crate::{adapters::cloudflare::deployments::Binding, fs::wrangler::Wrangler};

// this is probably dead because we bundle the upload,
// which we won't do in the future.
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct UploadSessionResponse {
pub jwt: String,
// Contains a list of lists of file hashes that Cloudflare wants us to upload together
pub buckets: Vec<Vec<String>>,
}

// this is probably dead because we bundle the upload,
// which we won't do in the future.
#[allow(dead_code)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct UploadAssetsResponse {
pub jwt: String,
Expand Down
112 changes: 48 additions & 64 deletions src/adapters/ingresses/apig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,12 @@ impl AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -110,14 +108,12 @@ impl AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -157,14 +153,12 @@ impl AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -217,14 +211,12 @@ impl Ingress for AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -256,14 +248,12 @@ impl Ingress for AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -291,14 +281,12 @@ impl Ingress for AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -337,14 +325,12 @@ impl Ingress for AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -394,14 +380,12 @@ impl Ingress for AwsApiGateway {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down
5 changes: 3 additions & 2 deletions src/adapters/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pub use backend::BackendClient;
pub(crate) use backend::{LockedState, RolloutMetadata};
pub use backend::{BackendClient, RolloutMetadata};
pub use cloudflare::CloudflareClient;

pub(crate) use backend::LockedState;

pub use ingresses::*;
pub use monitors::*;
pub use platforms::*;
Expand Down
28 changes: 12 additions & 16 deletions src/adapters/platforms/lambda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,12 @@ impl Platform for LambdaPlatform {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down Expand Up @@ -115,14 +113,12 @@ impl Platform for LambdaPlatform {
let error_message = match err {
SdkError::ServiceError(service_err) => {
// Extract the specific service error details
format!(
"{}",
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
)
service_err
.err()
.meta()
.message()
.unwrap_or("No error message found")
.to_string()
}
_ => format!("{:?}", err),
};
Expand Down
1 change: 1 addition & 0 deletions src/adapters/platforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl Shutdownable for MockPlatform {

mod cloudflare;
mod lambda;
mod vercel;

#[cfg(test)]
mod tests {
Expand Down
Loading