Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/eng 486 update deployer with runtime changes #696

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: use &str in storagemanager
  • Loading branch information
oddgrd committed Mar 13, 2023
commit a2a4d18fcdd13f5688888f7ccd2d7326bf9131a7
16 changes: 8 additions & 8 deletions common/src/storage_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use uuid::Uuid;

pub trait StorageManager: Sync + Send {
/// Path for a specific service build files
fn service_build_path(&self, service_name: String) -> Result<PathBuf, io::Error>;
fn service_build_path(&self, service_name: &str) -> Result<PathBuf, io::Error>;

/// Path to folder for storing deployment files
fn deployment_storage_path(
&self,
service_name: String,
service_name: &str,
deployment_id: &Uuid,
) -> Result<PathBuf, io::Error>;
}
Expand Down Expand Up @@ -58,21 +58,21 @@ impl ArtifactsStorageManager {
}

impl StorageManager for ArtifactsStorageManager {
fn service_build_path(&self, service_name: String) -> Result<PathBuf, io::Error> {
let builds_path = self.builds_path()?.join(service_name.as_str());
fn service_build_path(&self, service_name: &str) -> Result<PathBuf, io::Error> {
let builds_path = self.builds_path()?.join(service_name);
fs::create_dir_all(&builds_path)?;

Ok(builds_path)
}

fn deployment_storage_path(
&self,
service_name: String,
service_name: &str,
deployment_id: &Uuid,
) -> Result<PathBuf, io::Error> {
let storage_path = self
.storage_path()?
.join(service_name.as_str())
.join(service_name)
.join(deployment_id.to_string());
fs::create_dir_all(&storage_path)?;

Expand All @@ -93,13 +93,13 @@ impl WorkingDirStorageManager {
}

impl StorageManager for WorkingDirStorageManager {
fn service_build_path(&self, _service_name: String) -> Result<PathBuf, io::Error> {
fn service_build_path(&self, _service_name: &str) -> Result<PathBuf, io::Error> {
Ok(self.working_dir.clone())
}

fn deployment_storage_path(
&self,
_service_name: String,
_service_name: &str,
_deployment_id: &Uuid,
) -> Result<PathBuf, io::Error> {
Ok(self.working_dir.clone())
Expand Down
2 changes: 1 addition & 1 deletion deployer/src/deployment/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Queued {
) -> Result<Built> {
info!("Extracting received data");

let project_path = storage_manager.service_build_path(self.service_name.clone())?;
let project_path = storage_manager.service_build_path(&self.service_name)?;

extract_tar_gz_data(self.data.as_slice(), &project_path).await?;

Expand Down
2 changes: 1 addition & 1 deletion deployer/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ async fn post_clean(
) -> Result<Json<Vec<String>>> {
let project_path = deployment_manager
.storage_manager()
.service_build_path(project_name)
.service_build_path(&project_name)
.map_err(anyhow::Error::new)?;

let lines = clean_crate(&project_path, true)?;
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/provisioner_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ impl Factory for ProvisionerFactory {

fn get_build_path(&self) -> Result<PathBuf, shuttle_service::Error> {
self.storage_manager
.service_build_path(self.service_name.to_string())
.service_build_path(self.service_name.as_str())
.map_err(Into::into)
}

fn get_storage_path(&self) -> Result<PathBuf, shuttle_service::Error> {
self.storage_manager
.deployment_storage_path(self.service_name.to_string(), &self.deployment_id)
.deployment_storage_path(self.service_name.as_str(), &self.deployment_id)
.map_err(Into::into)
}

Expand Down