mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
lint: continue
This commit is contained in:
@@ -138,15 +138,12 @@ impl<'a> Eks<'a> {
|
||||
let template_directory = format!("{}/aws/bootstrap", context.lib_root_dir());
|
||||
|
||||
for node_group in &nodes_groups {
|
||||
if AwsInstancesType::from_str(node_group.instance_type.as_str()).is_err() {
|
||||
if let Err(e) = AwsInstancesType::from_str(node_group.instance_type.as_str()) {
|
||||
return Err(EngineError::new(
|
||||
EngineErrorCause::Internal,
|
||||
EngineErrorScope::Engine,
|
||||
context.execution_id(),
|
||||
Some(format!(
|
||||
"Nodegroup instance type {} is not valid for {}",
|
||||
node_group.instance_type, cloud_provider.name
|
||||
)),
|
||||
e.message,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::cloud_provider::kubernetes::InstanceType;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use core::fmt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
@@ -54,9 +55,9 @@ impl fmt::Display for AwsInstancesType {
|
||||
}
|
||||
|
||||
impl FromStr for AwsInstancesType {
|
||||
type Err = ();
|
||||
type Err = SimpleError;
|
||||
|
||||
fn from_str(s: &str) -> Result<AwsInstancesType, ()> {
|
||||
fn from_str(s: &str) -> Result<AwsInstancesType, SimpleError> {
|
||||
match s {
|
||||
"t2.large" => Ok(AwsInstancesType::T2Large),
|
||||
"t2x.large" => Ok(AwsInstancesType::T2Xlarge),
|
||||
@@ -64,7 +65,10 @@ impl FromStr for AwsInstancesType {
|
||||
"t3x.large" => Ok(AwsInstancesType::T3Xlarge),
|
||||
"t3a.large" => Ok(AwsInstancesType::T3aLarge),
|
||||
"t3a.2xlarge" => Ok(AwsInstancesType::T3a2xlarge),
|
||||
_ => Err(()),
|
||||
_ => Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(format!("Nodegroup instance type `{}` is not a valid for AWS", s)),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,15 +106,12 @@ impl<'a> DoKs<'a> {
|
||||
let template_directory = format!("{}/digitalocean/bootstrap", context.lib_root_dir());
|
||||
|
||||
for node_group in &nodes_groups {
|
||||
if DoInstancesType::from_str(node_group.instance_type.as_str()).is_err() {
|
||||
if let Err(e) = DoInstancesType::from_str(node_group.instance_type.as_str()) {
|
||||
return Err(EngineError::new(
|
||||
EngineErrorCause::Internal,
|
||||
EngineErrorScope::Engine,
|
||||
context.execution_id(),
|
||||
Some(format!(
|
||||
"Nodegroup instance type {} is not valid for {}",
|
||||
node_group.instance_type, cloud_provider.name
|
||||
)),
|
||||
e.message,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -420,7 +417,7 @@ impl<'a> DoKs<'a> {
|
||||
let api_url = format!("{}/clusters", DoApiType::Doks.api_url());
|
||||
let json_content = do_get_from_api(self.cloud_provider.token.as_str(), DoApiType::Doks, api_url)?;
|
||||
// TODO(benjaminch): `qovery-` to be added into Rust name directly everywhere
|
||||
get_doks_info_from_name(json_content.as_str(), format!("qovery-{}", self.id().to_string()))
|
||||
get_doks_info_from_name(json_content.as_str(), format!("qovery-{}", self.id()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::cloud_provider::kubernetes::InstanceType;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use core::fmt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::str::FromStr;
|
||||
@@ -58,9 +59,9 @@ impl fmt::Display for DoInstancesType {
|
||||
}
|
||||
|
||||
impl FromStr for DoInstancesType {
|
||||
type Err = ();
|
||||
type Err = SimpleError;
|
||||
|
||||
fn from_str(s: &str) -> Result<DoInstancesType, ()> {
|
||||
fn from_str(s: &str) -> Result<DoInstancesType, SimpleError> {
|
||||
match s {
|
||||
"s-1vcpu-1gb" => Ok(DoInstancesType::S1vcpu1gb),
|
||||
"s-1vcpu-2gb" => Ok(DoInstancesType::S1vcpu2gb),
|
||||
@@ -69,7 +70,13 @@ impl FromStr for DoInstancesType {
|
||||
"s-4vcpu-8gb" => Ok(DoInstancesType::S4vcpu8gb),
|
||||
"s-6vcpu-16gb" => Ok(DoInstancesType::S6vcpu16gb),
|
||||
"s-8vcpu-32gb" => Ok(DoInstancesType::S8vcpu32gb),
|
||||
_ => Err(()),
|
||||
_ => Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(format!(
|
||||
"Nodegroup instance type `{}` is not a valid for DigitalOcean",
|
||||
s
|
||||
)),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ where
|
||||
let error_message = format!(
|
||||
"Wasn't able to delete all objects type {}, it's a blocker to then delete cert-manager namespace. {}",
|
||||
object,
|
||||
format!("{:?}", msg)
|
||||
msg,
|
||||
);
|
||||
return Err(SimpleError::new(Other, Some(error_message)));
|
||||
}
|
||||
|
||||
@@ -134,15 +134,12 @@ impl<'a> Kapsule<'a> {
|
||||
let template_directory = format!("{}/scaleway/bootstrap", context.lib_root_dir());
|
||||
|
||||
for node_group in &nodes_groups {
|
||||
if ScwInstancesType::from_str(node_group.instance_type.as_str()).is_err() {
|
||||
if let Err(e) = ScwInstancesType::from_str(node_group.instance_type.as_str()) {
|
||||
return Err(EngineError::new(
|
||||
EngineErrorCause::Internal,
|
||||
EngineErrorScope::Engine,
|
||||
context.execution_id(),
|
||||
Some(format!(
|
||||
"Nodegroup instance type {} is not valid for {}",
|
||||
node_group.instance_type, cloud_provider.name
|
||||
)),
|
||||
e.message,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::cloud_provider::kubernetes::InstanceType;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
@@ -66,9 +67,9 @@ impl fmt::Display for ScwInstancesType {
|
||||
}
|
||||
|
||||
impl FromStr for ScwInstancesType {
|
||||
type Err = ();
|
||||
type Err = SimpleError;
|
||||
|
||||
fn from_str(s: &str) -> Result<ScwInstancesType, ()> {
|
||||
fn from_str(s: &str) -> Result<ScwInstancesType, SimpleError> {
|
||||
match s {
|
||||
"gp1-xs" => Ok(ScwInstancesType::Gp1Xs),
|
||||
"gp1-s" => Ok(ScwInstancesType::Gp1S),
|
||||
@@ -79,7 +80,10 @@ impl FromStr for ScwInstancesType {
|
||||
"dev1-l" => Ok(ScwInstancesType::Dev1L),
|
||||
"dev1-xl" => Ok(ScwInstancesType::Dev1Xl),
|
||||
"render-s" => Ok(ScwInstancesType::RenderS),
|
||||
_ => Err(()),
|
||||
_ => Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(format!("Nodegroup instance type `{}` is not a valid for Scaleway", s)),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,10 +166,7 @@ pub fn generate_supported_version(
|
||||
|
||||
if minor_min == minor_max {
|
||||
// add short minor format targeting latest version
|
||||
supported_versions.insert(
|
||||
format!("{}.{}", major.to_string(), minor_max.to_string()),
|
||||
latest_major_version.clone(),
|
||||
);
|
||||
supported_versions.insert(format!("{}.{}", major, minor_max), latest_major_version.clone());
|
||||
if update_min.unwrap() == update_max.unwrap() {
|
||||
let version = format!("{}.{}.{}", major, minor_min, update_min.unwrap());
|
||||
supported_versions.insert(version.clone(), format!("{}{}", version, suffix));
|
||||
@@ -183,13 +180,8 @@ pub fn generate_supported_version(
|
||||
for minor in minor_min..minor_max + 1 {
|
||||
// add short minor format targeting latest version
|
||||
supported_versions.insert(
|
||||
format!("{}.{}", major.to_string(), minor.to_string()),
|
||||
format!(
|
||||
"{}.{}.{}",
|
||||
major.to_string(),
|
||||
minor.to_string(),
|
||||
update_max.unwrap().to_string()
|
||||
),
|
||||
format!("{}.{}", major, minor),
|
||||
format!("{}.{}.{}", major, minor, update_max.unwrap(),),
|
||||
);
|
||||
if update_min.unwrap() == update_max.unwrap() {
|
||||
let version = format!("{}.{}.{}", major, minor, update_min.unwrap());
|
||||
|
||||
@@ -387,7 +387,7 @@ impl ContainerRegistry for AwsEcr {
|
||||
}
|
||||
};
|
||||
|
||||
if cmd::utilities::exec(
|
||||
if let Err(e) = cmd::utilities::exec(
|
||||
"docker",
|
||||
vec![
|
||||
"login",
|
||||
@@ -398,15 +398,17 @@ impl ContainerRegistry for AwsEcr {
|
||||
endpoint_url.as_str(),
|
||||
],
|
||||
&self.docker_envs(),
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
) {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your ECR account seems to be no longer valid (bad Credentials). \
|
||||
Please contact your Organization administrator to fix or change the Credentials.",
|
||||
),
|
||||
format!("failed to login to ECR {}", self.name_with_id()),
|
||||
format!(
|
||||
"failed to login to ECR {}, error: {}",
|
||||
self.name_with_id(),
|
||||
e.message.unwrap_or_else(|| "no error message".to_string())
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
@@ -312,19 +312,21 @@ impl ContainerRegistry for DigitalOceanCr {
|
||||
Err(_) => warn!("DOCR {} already exists", registry_name.as_str()),
|
||||
};
|
||||
|
||||
if cmd::utilities::exec(
|
||||
if let Err(e) = cmd::utilities::exec(
|
||||
"doctl",
|
||||
vec!["registry", "login", self.name.as_str(), "-t", self.api_key.as_str()],
|
||||
&[],
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
) {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your DOCR account seems to be no longer valid (bad Credentials). \
|
||||
Please contact your Organization administrator to fix or change the Credentials.",
|
||||
),
|
||||
format!("failed to login to DOCR {}", self.name_with_id()),
|
||||
format!(
|
||||
"failed to login to DOCR {}, error: {}",
|
||||
self.name_with_id(),
|
||||
e.message.unwrap_or_else(|| "no error message".to_string())
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
@@ -113,19 +113,21 @@ impl ContainerRegistry for DockerHub {
|
||||
None => vec![],
|
||||
};
|
||||
|
||||
if cmd::utilities::exec(
|
||||
if let Err(e) = cmd::utilities::exec(
|
||||
"docker",
|
||||
vec!["login", "-u", self.login.as_str(), "-p", self.password.as_str()],
|
||||
&envs,
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
) {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your DockerHub account seems to be no longer valid (bad Credentials). \
|
||||
Please contact your Organization administrator to fix or change the Credentials.",
|
||||
),
|
||||
format!("failed to login to DockerHub {}", self.name_with_id()),
|
||||
format!(
|
||||
"failed to login to DockerHub {}, error: {}",
|
||||
self.name_with_id(),
|
||||
e.message.unwrap_or_else(|| "no error message".to_string())
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
@@ -391,21 +391,23 @@ impl ContainerRegistry for ScalewayCr {
|
||||
}
|
||||
}
|
||||
|
||||
if docker_login(
|
||||
if let Err(e) = docker_login(
|
||||
Kind::ScalewayCr,
|
||||
self.get_docker_envs(),
|
||||
self.login.clone(),
|
||||
self.secret_token.clone(),
|
||||
registry_url.clone(),
|
||||
)
|
||||
.is_err()
|
||||
{
|
||||
) {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your Scaleway account seems to be no longer valid (bad Credentials). \
|
||||
Please contact your Organization administrator to fix or change the Credentials.",
|
||||
),
|
||||
format!("failed to login to Scaleway {}", self.name_with_id()),
|
||||
format!(
|
||||
"failed to login to Scaleway {}, error: {}",
|
||||
self.name_with_id(),
|
||||
e.message.unwrap_or_else(|| "no error message".to_string())
|
||||
),
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ impl ScalewayOS {
|
||||
}
|
||||
|
||||
fn get_endpoint_url_for_region(&self) -> String {
|
||||
format!("https://s3.{}.scw.cloud", self.zone.region().to_string())
|
||||
format!("https://s3.{}.scw.cloud", self.zone.region())
|
||||
}
|
||||
|
||||
fn is_bucket_name_valid(bucket_name: &str) -> Result<(), Option<String>> {
|
||||
|
||||
@@ -21,9 +21,9 @@ pub fn environment_3_apps_3_routers_3_databases(
|
||||
database_instance_type: &str,
|
||||
database_disk_type: &str,
|
||||
) -> Environment {
|
||||
let app_name_1 = format!("{}-{}", "simple-app-1".to_string(), generate_id());
|
||||
let app_name_2 = format!("{}-{}", "simple-app-2".to_string(), generate_id());
|
||||
let app_name_3 = format!("{}-{}", "simple-app-3".to_string(), generate_id());
|
||||
let app_name_1 = format!("{}-{}", "simple-app-1", generate_id());
|
||||
let app_name_2 = format!("{}-{}", "simple-app-2", generate_id());
|
||||
let app_name_3 = format!("{}-{}", "simple-app-3", generate_id());
|
||||
|
||||
// mongoDB management part
|
||||
let database_host_mongo = format!("mongodb-{}.{}", generate_id(), &test_domain);
|
||||
@@ -295,7 +295,7 @@ pub fn working_minimal_environment(context: &Context, organization_id: &str, tes
|
||||
action: Action::Create,
|
||||
applications: vec![Application {
|
||||
id: generate_id(),
|
||||
name: format!("{}-{}", "simple-app".to_string(), &suffix),
|
||||
name: format!("{}-{}", "simple-app", &suffix),
|
||||
git_url: "https://github.com/Qovery/engine-testing.git".to_string(),
|
||||
commit_id: "fc575a2f3be0b9100492c8a463bf18134a8698a5".to_string(),
|
||||
dockerfile_path: Some("Dockerfile".to_string()),
|
||||
@@ -326,7 +326,7 @@ pub fn working_minimal_environment(context: &Context, organization_id: &str, tes
|
||||
custom_domains: vec![],
|
||||
routes: vec![Route {
|
||||
path: "/".to_string(),
|
||||
application_name: format!("{}-{}", "simple-app".to_string(), &suffix),
|
||||
application_name: format!("{}-{}", "simple-app", &suffix),
|
||||
}],
|
||||
}],
|
||||
databases: vec![],
|
||||
@@ -517,7 +517,7 @@ pub fn echo_app_environment(context: &Context, organization_id: &str, test_domai
|
||||
action: Action::Create,
|
||||
applications: vec![Application {
|
||||
id: generate_id(),
|
||||
name: format!("{}-{}", "echo-app".to_string(), &suffix),
|
||||
name: format!("{}-{}", "echo-app", &suffix),
|
||||
/*name: "simple-app".to_string(),*/
|
||||
git_url: "https://github.com/Qovery/engine-testing.git".to_string(),
|
||||
commit_id: "2205adea1db295547b99f7b17229afd7e879b6ff".to_string(),
|
||||
@@ -551,7 +551,7 @@ pub fn echo_app_environment(context: &Context, organization_id: &str, test_domai
|
||||
custom_domains: vec![],
|
||||
routes: vec![Route {
|
||||
path: "/".to_string(),
|
||||
application_name: format!("{}-{}", "echo-app".to_string(), &suffix),
|
||||
application_name: format!("{}-{}", "echo-app", &suffix),
|
||||
}],
|
||||
}],
|
||||
databases: vec![],
|
||||
|
||||
@@ -467,7 +467,7 @@ where
|
||||
));
|
||||
|
||||
if let Err(e) = clusters_res {
|
||||
let message = format!("error while trying to get clusters, error: {}", e.to_string());
|
||||
let message = format!("error while trying to get clusters, error: {}", e);
|
||||
error!("{}", message);
|
||||
|
||||
return OperationResult::Retry(SimpleError::new(SimpleErrorKind::Other, Some(message.as_str())));
|
||||
@@ -504,8 +504,7 @@ where
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
let message =
|
||||
format!("error while trying to get clusters, error: {}", e.to_string());
|
||||
let message = format!("error while trying to get clusters, error: {}", e);
|
||||
error!("{}", message);
|
||||
|
||||
return OperationResult::Retry(SimpleError::new(
|
||||
|
||||
Reference in New Issue
Block a user