Skip to content

Commit

Permalink
fix: replace some clone() with defererencing
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-gull-diana authored and thomas-mauran committed Aug 30, 2023
1 parent 87f9a07 commit e44b8df
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl SchedulingService for Scheduler {
..Default::default()
},
WorkloadStatus {
instance_id: workload.instance_id.clone(),
instance_id: workload.instance_id,
status: Some(DeploymentStatus {
code: 2,
message: Some("The workload is terminated".to_string()),
Expand Down
10 changes: 4 additions & 6 deletions controller/src/routes/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub async fn delete_instance(Path(id): Path<String>) -> anyhow::Result<Json<Valu
let mut client = Client::new().await?;

let instance = WorkloadInstance {
instance_id: id.clone(),
instance_id: (*id).to_string(),
};

client.stop_instance(instance).await?;
Expand All @@ -52,7 +52,7 @@ pub async fn delete_instance_force(
let mut client = Client::new().await?;

let instance = WorkloadInstance {
instance_id: id.clone(),
instance_id: (*id).to_string(),
};

client.destroy_instance(instance).await?;
Expand Down Expand Up @@ -80,15 +80,13 @@ pub async fn post_instance(body: String) -> anyhow::Result<Json<Value>, ApiError
match workload_request {
None => Ok(Json(json!({"description": "Workload not found"}))),
Some(json_request) => {
let wr = json_request.as_ref().clone();

// Create a grpc workload object
let workload = Workload::from(wr.workload.clone());
let workload = Workload::from(json_request.0.workload);

// We spawn a thread to handle the request
let mut client = Client::new().await?;

let instance_id = workload.instance_id.clone();
let instance_id = (*workload.instance_id).to_string();

let request = SchedulingRequest {
workload: Some(workload),
Expand Down
2 changes: 1 addition & 1 deletion controller/src/types/instance_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct InstanceStatus {
impl From<&WorkloadStatus> for InstanceStatus {
fn from(status: &WorkloadStatus) -> Self {
InstanceStatus {
name: status.instance_id.clone(),
name: (*status.instance_id).to_string(),
status_code: InstanceStatusCode::from(status.status.clone()),
resource_usage: InstanceResources {
cpu: 1,
Expand Down

0 comments on commit e44b8df

Please sign in to comment.