fix: clippy #164
| @ -3,10 +3,7 @@ use std::time::Duration; | |||||||
| use derive_new::new; | use derive_new::new; | ||||||
| use k8s_openapi::{ | use k8s_openapi::{ | ||||||
|     ClusterResourceScope, NamespaceResourceScope, |     ClusterResourceScope, NamespaceResourceScope, | ||||||
|     api::{ |     api::{apps::v1::Deployment, core::v1::Pod}, | ||||||
|         apps::v1::Deployment, |  | ||||||
|         core::v1::Pod, |  | ||||||
|     }, |  | ||||||
| }; | }; | ||||||
| use kube::{ | use kube::{ | ||||||
|     Client, Config, Error, Resource, |     Client, Config, Error, Resource, | ||||||
| @ -172,10 +169,11 @@ impl K8sClient { | |||||||
| 
 | 
 | ||||||
|             if let Some(p) = pod |             if let Some(p) = pod | ||||||
|                 && let Some(status) = p.status |                 && let Some(status) = p.status | ||||||
|                     && let Some(phase) = status.phase |                 && let Some(phase) = status.phase | ||||||
|                         && phase.to_lowercase() == "running" { |                 && phase.to_lowercase() == "running" | ||||||
|                             return Ok(()); |             { | ||||||
|                         } |                 return Ok(()); | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             if elapsed >= timeout_secs { |             if elapsed >= timeout_secs { | ||||||
|                 return Err(Error::Discovery(DiscoveryError::MissingResource(format!( |                 return Err(Error::Discovery(DiscoveryError::MissingResource(format!( | ||||||
|  | |||||||
| @ -183,15 +183,12 @@ pub(crate) fn get_health_check_for_backend( | |||||||
|     match uppercase { |     match uppercase { | ||||||
|         "TCP" => { |         "TCP" => { | ||||||
|             if let Some(checkport) = haproxy_health_check.checkport.content.as_ref() |             if let Some(checkport) = haproxy_health_check.checkport.content.as_ref() | ||||||
|                 && !checkport.is_empty() { |                 && !checkport.is_empty() | ||||||
|                     return Some(HealthCheck::TCP(Some(checkport.parse().unwrap_or_else( |             { | ||||||
|                         |_| { |                 return Some(HealthCheck::TCP(Some(checkport.parse().unwrap_or_else( | ||||||
|                             panic!( |                     |_| panic!("HAProxy check port should be a valid port number, got {checkport}"), | ||||||
|                                 "HAProxy check port should be a valid port number, got {checkport}" |                 )))); | ||||||
|                             ) |             } | ||||||
|                         }, |  | ||||||
|                     )))); |  | ||||||
|                 } |  | ||||||
|             Some(HealthCheck::TCP(None)) |             Some(HealthCheck::TCP(None)) | ||||||
|         } |         } | ||||||
|         "HTTP" => { |         "HTTP" => { | ||||||
|  | |||||||
| @ -10,10 +10,7 @@ use crate::{ | |||||||
|     inventory::Inventory, |     inventory::Inventory, | ||||||
|     modules::helm::chart::{HelmChartScore, HelmRepository}, |     modules::helm::chart::{HelmChartScore, HelmRepository}, | ||||||
|     score::Score, |     score::Score, | ||||||
|     topology::{ |     topology::{HelmCommand, K8sclient, Topology, ingress::Ingress, k8s::K8sClient}, | ||||||
|         HelmCommand, K8sclient, Topology, ingress::Ingress, |  | ||||||
|         k8s::K8sClient, |  | ||||||
|     }, |  | ||||||
| }; | }; | ||||||
| use harmony_types::id::Id; | use harmony_types::id::Id; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -194,10 +194,10 @@ impl RustWebapp { | |||||||
|                     Some(body_full(tar_data.into())), |                     Some(body_full(tar_data.into())), | ||||||
|                 ); |                 ); | ||||||
| 
 | 
 | ||||||
|                 while let Some(mut msg) = image_build_stream.next().await { |                 while let Some(msg) = image_build_stream.next().await { | ||||||
|                     trace!("Got bollard msg {msg:?}"); |                     trace!("Got bollard msg {msg:?}"); | ||||||
|                     match msg { |                     match msg { | ||||||
|                         Ok(mut msg) => { |                         Ok(msg) => { | ||||||
|                             if let Some(progress) = msg.progress_detail { |                             if let Some(progress) = msg.progress_detail { | ||||||
|                                 info!( |                                 info!( | ||||||
|                                     "Build progress {}/{}", |                                     "Build progress {}/{}", | ||||||
| @ -511,25 +511,23 @@ ingress: | |||||||
|         fs::write(chart_dir.join("values.yaml"), values_yaml)?; |         fs::write(chart_dir.join("values.yaml"), values_yaml)?; | ||||||
| 
 | 
 | ||||||
|         // Create templates/_helpers.tpl
 |         // Create templates/_helpers.tpl
 | ||||||
|         let helpers_tpl = format!( |         let helpers_tpl = r#" | ||||||
|             r#" | {{/* | ||||||
| {{{{/* |  | ||||||
| Expand the name of the chart. | Expand the name of the chart. | ||||||
| */}}}} | */}} | ||||||
| {{{{- define "chart.name" -}}}} | {{- define "chart.name" -}} | ||||||
| {{{{- default .Chart.Name $.Values.nameOverride | trunc 63 | trimSuffix "-" }}}} | {{- default .Chart.Name $.Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||||||
| {{{{- end }}}} | {{- end }} | ||||||
| 
 | 
 | ||||||
| {{{{/* | {{/* | ||||||
| Create a default fully qualified app name. | Create a default fully qualified app name. | ||||||
| We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||||||
| */}}}} | */}} | ||||||
| {{{{- define "chart.fullname" -}}}} | {{- define "chart.fullname" -}} | ||||||
| {{{{- $name := default .Chart.Name $.Values.nameOverride }}}} | {{- $name := default .Chart.Name $.Values.nameOverride }} | ||||||
| {{{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}}} | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||||||
| {{{{- end }}}} | {{- end }} | ||||||
| "#
 | "#.to_string();
 | ||||||
|         ); |  | ||||||
|         fs::write(templates_dir.join("_helpers.tpl"), helpers_tpl)?; |         fs::write(templates_dir.join("_helpers.tpl"), helpers_tpl)?; | ||||||
| 
 | 
 | ||||||
|         // Create templates/service.yaml
 |         // Create templates/service.yaml
 | ||||||
|  | |||||||
| @ -107,9 +107,10 @@ impl HelmCommandExecutor { | |||||||
| 
 | 
 | ||||||
|     pub fn run_command(mut self, mut args: Vec<String>) -> Result<Output, std::io::Error> { |     pub fn run_command(mut self, mut args: Vec<String>) -> Result<Output, std::io::Error> { | ||||||
|         if let Some(d) = self.debug |         if let Some(d) = self.debug | ||||||
|             && d { |             && d | ||||||
|                 args.push("--debug".to_string()); |         { | ||||||
|             } |             args.push("--debug".to_string()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         let path = if let Some(p) = self.path { |         let path = if let Some(p) = self.path { | ||||||
|             p |             p | ||||||
| @ -233,24 +234,28 @@ impl HelmChart { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if let Some(crd) = self.include_crds |         if let Some(crd) = self.include_crds | ||||||
|             && crd { |             && crd | ||||||
|                 args.push("--include-crds".to_string()); |         { | ||||||
|             } |             args.push("--include-crds".to_string()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         if let Some(st) = self.skip_tests |         if let Some(st) = self.skip_tests | ||||||
|             && st { |             && st | ||||||
|                 args.push("--skip-tests".to_string()); |         { | ||||||
|             } |             args.push("--skip-tests".to_string()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         if let Some(sh) = self.skip_hooks |         if let Some(sh) = self.skip_hooks | ||||||
|             && sh { |             && sh | ||||||
|                 args.push("--no-hooks".to_string()); |         { | ||||||
|             } |             args.push("--no-hooks".to_string()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         if let Some(d) = self.debug |         if let Some(d) = self.debug | ||||||
|             && d { |             && d | ||||||
|                 args.push("--debug".to_string()); |         { | ||||||
|             } |             args.push("--debug".to_string()); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         args |         args | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,4 +1,3 @@ | |||||||
| 
 |  | ||||||
| use kube::CustomResource; | use kube::CustomResource; | ||||||
| use schemars::JsonSchema; | use schemars::JsonSchema; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
|  | |||||||
| @ -104,7 +104,9 @@ impl OKDSetup02BootstrapInterpret { | |||||||
|                 InterpretError::new(format!("Failed to create okd installation directory : {e}")) |                 InterpretError::new(format!("Failed to create okd installation directory : {e}")) | ||||||
|             })?; |             })?; | ||||||
|         if !exit_status.success() { |         if !exit_status.success() { | ||||||
|             return Err(InterpretError::new("Failed to create okd installation directory".to_string())); |             return Err(InterpretError::new( | ||||||
|  |                 "Failed to create okd installation directory".to_string(), | ||||||
|  |             )); | ||||||
|         } else { |         } else { | ||||||
|             info!( |             info!( | ||||||
|                 "Created OKD installation directory {}", |                 "Created OKD installation directory {}", | ||||||
|  | |||||||
| @ -183,12 +183,13 @@ impl CephRemoveOsdInterpret { | |||||||
| 
 | 
 | ||||||
|             if let Some(deployment) = dep |             if let Some(deployment) = dep | ||||||
|                 && let Some(status) = deployment.status |                 && let Some(status) = deployment.status | ||||||
|                     && status.replicas.unwrap_or(1) == 0 && status.ready_replicas.unwrap_or(1) == 0 |                 && status.replicas.unwrap_or(1) == 0 | ||||||
|                     { |                 && status.ready_replicas.unwrap_or(1) == 0 | ||||||
|                         return Ok(Outcome::success( |             { | ||||||
|                             "Deployment successfully scaled down.".to_string(), |                 return Ok(Outcome::success( | ||||||
|                         )); |                     "Deployment successfully scaled down.".to_string(), | ||||||
|                     } |                 )); | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             if start.elapsed() > timeout { |             if start.elapsed() > timeout { | ||||||
|                 return Err(InterpretError::new(format!( |                 return Err(InterpretError::new(format!( | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user