Skip to content

Commit

Permalink
Change from ProjectName to String
Browse files Browse the repository at this point in the history
  • Loading branch information
fatfingers23 committed Dec 5, 2023
1 parent 41670ed commit 97c7bb7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cargo-shuttle/Cargo.toml
Expand Up @@ -9,7 +9,7 @@ homepage = "https://www.shuttle.rs"
rust-version = "1.70"

[dependencies]
shuttle-common = { workspace = true, features = ["models", "backend"] }
shuttle-common = { workspace = true, features = ["models"] }
shuttle-proto = { workspace = true, features = ["provisioner", "runtime"] }
shuttle-service = { workspace = true, features = ["builder", "runner"] }

Expand Down
3 changes: 1 addition & 2 deletions common/src/models/error.rs
@@ -1,6 +1,5 @@
use std::fmt::{Display, Formatter};

use crate::models::project::name::ProjectName;
use crossterm::style::Stylize;
use http::StatusCode;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -40,7 +39,7 @@ pub enum ErrorKind {
Forbidden,
UserNotFound,
UserAlreadyExists,
ProjectNotFound(ProjectName),
ProjectNotFound(String),
InvalidProjectName(InvalidProjectName),
ProjectAlreadyExists,
/// Contains a message describing a running state of the project.
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/auth.rs
Expand Up @@ -87,7 +87,7 @@ where
if user.projects.contains(&scope) || user.claim.scopes.contains(&Scope::Admin) {
Ok(Self { user, scope })
} else {
Err(Error::from(ErrorKind::ProjectNotFound(scope)))
Err(Error::from(ErrorKind::ProjectNotFound(scope.to_string())))
}
}
}
6 changes: 3 additions & 3 deletions gateway/src/service.rs
Expand Up @@ -388,7 +388,7 @@ impl GatewayService {
))
}),
})
.ok_or_else(|| Error::from_kind(ErrorKind::ProjectNotFound(project_name.clone())))
.ok_or_else(|| Error::from_kind(ErrorKind::ProjectNotFound(project_name.to_string())))
}

pub async fn project_name_exists(&self, project_name: &ProjectName) -> Result<bool, Error> {
Expand Down Expand Up @@ -472,7 +472,7 @@ impl GatewayService {
.fetch_optional(&self.db)
.await?
.map(|row| row.get("account_name"))
.ok_or_else(|| Error::from(ErrorKind::ProjectNotFound(project_name.clone())))
.ok_or_else(|| Error::from(ErrorKind::ProjectNotFound(project_name.to_string())))
}

pub async fn control_key_from_project_name(
Expand All @@ -484,7 +484,7 @@ impl GatewayService {
.fetch_optional(&self.db)
.await?
.map(|row| row.try_get("initial_key").unwrap())
.ok_or_else(|| Error::from(ErrorKind::ProjectNotFound(project_name.clone())))?;
.ok_or_else(|| Error::from(ErrorKind::ProjectNotFound(project_name.to_string())))?;
Ok(control_key)
}

Expand Down

0 comments on commit 97c7bb7

Please sign in to comment.