diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2184b106e..03f053f42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,11 +185,11 @@ echo "api_key = ''" > ~/.config/shuttle/config.toml > Note: The JWT will expire in 15 minutes, at which point you need to run the commands again. > If you have [`jq`](https://github.com/stedolan/jq/wiki/Installation) installed you can combine > the two above commands into the following: -> ```bash -> curl -s -H "Authorization: Bearer test-key" localhost:8008/auth/key \ -> | jq -r '.token' \ -> | read token; echo "api_key='$token'" > ~/.config/shuttle/config.toml -> ``` +```bash +curl -s -H "Authorization: Bearer test-key" localhost:8008/auth/key \ + | jq -r '.token' \ + | read token; echo "api_key='$token'" > ~/.config/shuttle/config.toml +``` Finally we need to comment out the admin layer in the deployer handlers. So in `deployer/handlers/mod.rs`, in the `make_router` function comment out this line: `.layer(AdminSecretLayer::new(admin_secret))`. diff --git a/deployer/src/handlers/error.rs b/deployer/src/handlers/error.rs index 6ded00b06..09bedcfce 100644 --- a/deployer/src/handlers/error.rs +++ b/deployer/src/handlers/error.rs @@ -20,8 +20,8 @@ pub enum Error { to: String, message: String, }, - #[error("record could not be found")] - NotFound, + #[error("{0}, try running `cargo shuttle deploy`")] + NotFound(String), #[error("Custom error: {0}")] Custom(#[from] anyhow::Error), } @@ -44,7 +44,7 @@ impl IntoResponse for Error { error!(error = &self as &dyn std::error::Error, "request error"); let code = match self { - Error::NotFound => StatusCode::NOT_FOUND, + Error::NotFound(_) => StatusCode::NOT_FOUND, _ => StatusCode::INTERNAL_SERVER_ERROR, }; diff --git a/deployer/src/handlers/mod.rs b/deployer/src/handlers/mod.rs index c5fae49d2..2fd1fc692 100644 --- a/deployer/src/handlers/mod.rs +++ b/deployer/src/handlers/mod.rs @@ -147,7 +147,7 @@ async fn get_service( Ok(Json(response)) } else { - Err(Error::NotFound) + Err(Error::NotFound("service not found".to_string())) } } @@ -166,7 +166,7 @@ async fn get_service_resources( Ok(Json(resources)) } else { - Err(Error::NotFound) + Err(Error::NotFound("service not found".to_string())) } } @@ -229,7 +229,7 @@ async fn stop_service( if let Some(ref deployment) = running_deployment { deployment_manager.kill(deployment.id).await; } else { - return Err(Error::NotFound); + return Err(Error::NotFound("no running deployment found".to_string())); } let response = shuttle_common::models::service::Summary { @@ -240,7 +240,7 @@ async fn stop_service( Ok(Json(response)) } else { - Err(Error::NotFound) + Err(Error::NotFound("service not found".to_string())) } } @@ -259,7 +259,7 @@ async fn get_deployments( Ok(Json(deployments)) } else { - Err(Error::NotFound) + Err(Error::NotFound("service not found".to_string())) } } @@ -271,7 +271,7 @@ async fn get_deployment( if let Some(deployment) = persistence.get_deployment(&deployment_id).await? { Ok(Json(deployment.into())) } else { - Err(Error::NotFound) + Err(Error::NotFound("deployment not found".to_string())) } } @@ -286,7 +286,7 @@ async fn delete_deployment( Ok(Json(deployment.into())) } else { - Err(Error::NotFound) + Err(Error::NotFound("deployment not found".to_string())) } } @@ -305,7 +305,7 @@ async fn get_logs( .collect(), )) } else { - Err(Error::NotFound) + Err(Error::NotFound("deployment not found".to_string())) } } @@ -385,7 +385,7 @@ async fn get_secrets( Ok(Json(keys)) } else { - Err(Error::NotFound) + Err(Error::NotFound("service not found".to_string())) } }