mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
chore: cleanup unused imports and make code more idiomatic
This commit is contained in:
@@ -192,7 +192,7 @@ impl MongoDB {
|
||||
) {
|
||||
Ok(_) => {
|
||||
info!("Deleting secrets containing tfstates");
|
||||
utilities::delete_terraform_tfstate_secret(
|
||||
let _ = utilities::delete_terraform_tfstate_secret(
|
||||
*kubernetes,
|
||||
environment,
|
||||
self.workspace_directory().as_str(),
|
||||
|
||||
@@ -197,7 +197,7 @@ impl PostgreSQL {
|
||||
) {
|
||||
Ok(_) => {
|
||||
info!("Deleting secrets containing tfstates");
|
||||
utilities::delete_terraform_tfstate_secret(
|
||||
let _ = utilities::delete_terraform_tfstate_secret(
|
||||
*kubernetes,
|
||||
environment,
|
||||
self.workspace_directory().as_str(),
|
||||
|
||||
@@ -185,7 +185,7 @@ impl Redis {
|
||||
) {
|
||||
Ok(_) => {
|
||||
info!("Deleting secrets containing tfstates");
|
||||
utilities::delete_terraform_tfstate_secret(
|
||||
let _ = utilities::delete_terraform_tfstate_secret(
|
||||
*kubernetes,
|
||||
environment,
|
||||
self.workspace_directory().as_str(),
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn create_namespace_without_labels(namespace: &str, kube_config: &str, aws:
|
||||
(AWS_ACCESS_KEY_ID, aws.access_key_id.as_str()),
|
||||
(AWS_SECRET_ACCESS_KEY, aws.secret_access_key.as_str()),
|
||||
];
|
||||
kubectl_exec_create_namespace(kube_config, namespace, None, aws_credentials_envs);
|
||||
let _ = kubectl_exec_create_namespace(kube_config, namespace, None, aws_credentials_envs);
|
||||
}
|
||||
|
||||
pub fn delete_terraform_tfstate_secret(
|
||||
@@ -64,7 +64,12 @@ pub fn delete_terraform_tfstate_secret(
|
||||
match kubernetes_config_file_path {
|
||||
Ok(kube_config) => {
|
||||
//create the namespace to insert the tfstate in secrets
|
||||
kubectl_exec_delete_secret(kube_config, "tfstate-default-state", aws_credentials_envs);
|
||||
let _ = kubectl_exec_delete_secret(
|
||||
kube_config,
|
||||
"tfstate-default-state",
|
||||
aws_credentials_envs,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -6,9 +6,7 @@ use rusoto_core::Region;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::aws::common::{
|
||||
get_stateless_resource_information_for_user, kubernetes_config_path,
|
||||
};
|
||||
use crate::cloud_provider::aws::common::kubernetes_config_path;
|
||||
use crate::cloud_provider::aws::kubernetes::node::Node;
|
||||
use crate::cloud_provider::aws::{common, AWS};
|
||||
use crate::cloud_provider::environment::Environment;
|
||||
@@ -19,13 +17,11 @@ use crate::cloud_provider::kubernetes::{
|
||||
use crate::cloud_provider::service::Service;
|
||||
use crate::cloud_provider::{CloudProvider, DeploymentTarget};
|
||||
use crate::cmd;
|
||||
use crate::cmd::kubectl::{
|
||||
kubectl_exec_delete_namespace, kubectl_exec_describe_pod, kubectl_exec_get_all_namespaces,
|
||||
};
|
||||
use crate::cmd::kubectl::{kubectl_exec_delete_namespace, kubectl_exec_get_all_namespaces};
|
||||
use crate::constants::{AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY};
|
||||
use crate::deletion_utilities::{get_firsts_namespaces_to_delete, get_qovery_managed_namespaces};
|
||||
use crate::dns_provider::DnsProvider;
|
||||
use crate::error::{cast_simple_error_to_engine_error, EngineError, EngineErrorCause, SimpleError};
|
||||
use crate::error::{cast_simple_error_to_engine_error, EngineError, EngineErrorCause};
|
||||
use crate::fs::workspace_directory;
|
||||
use crate::models::{
|
||||
Context, Listener, Listeners, ListenersHelper, ProgressInfo, ProgressLevel, ProgressScope,
|
||||
@@ -746,7 +742,7 @@ impl<'a> Kubernetes for EKS<'a> {
|
||||
info!("Delete all remaining deployed helm applications");
|
||||
match cmd::helm::helm_list(&kubernetes_config_file_path2, aws_credentials_envs.clone()) {
|
||||
Ok(helm_list) => {
|
||||
cmd::helm::helm_uninstall_list(
|
||||
let _ = cmd::helm::helm_uninstall_list(
|
||||
&kubernetes_config_file_path2,
|
||||
helm_list,
|
||||
aws_credentials_envs.clone(),
|
||||
@@ -769,7 +765,8 @@ impl<'a> Kubernetes for EKS<'a> {
|
||||
info!("Deleting S3 Bucket containing Kubeconfig");
|
||||
let s3_kubeconfig_bucket = get_s3_kubeconfig_bucket_name(self.id.clone());
|
||||
let _region = Region::from_str(self.region()).unwrap();
|
||||
s3::delete_bucket(
|
||||
|
||||
let _ = s3::delete_bucket(
|
||||
self.cloud_provider.access_key_id.as_str(),
|
||||
self.cloud_provider.secret_access_key.as_str(),
|
||||
s3_kubeconfig_bucket.clone().as_str(),
|
||||
|
||||
@@ -1 +1 @@
|
||||
pub mod workerNodeDataTemplate;
|
||||
pub mod worker_node_data_template;
|
||||
|
||||
@@ -12,14 +12,12 @@ use crate::cloud_provider::service::{
|
||||
};
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
use crate::cmd::helm::Timeout;
|
||||
use crate::cmd::structs::{HelmHistoryRow, LabelsContent};
|
||||
use crate::cmd::structs::LabelsContent;
|
||||
use crate::constants::DIGITAL_OCEAN_TOKEN;
|
||||
use crate::container_registry::docr::{
|
||||
get_current_registry_name, subscribe_kube_cluster_to_container_registry,
|
||||
};
|
||||
use crate::error::{
|
||||
cast_simple_error_to_engine_error, EngineError, EngineErrorCause, EngineErrorScope, SimpleError,
|
||||
};
|
||||
use crate::error::{cast_simple_error_to_engine_error, EngineError};
|
||||
use crate::models::Context;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||
@@ -229,9 +227,9 @@ impl Create for Application {
|
||||
Timeout::Value(self.start_timeout_in_seconds),
|
||||
digitalocean_envs.clone(),
|
||||
) {
|
||||
Ok(upgrade) => {
|
||||
Ok(_) => {
|
||||
let selector = format!("app={}", self.name());
|
||||
crate::cmd::kubectl::kubectl_exec_is_pod_ready_with_retry(
|
||||
let _ = crate::cmd::kubectl::kubectl_exec_is_pod_ready_with_retry(
|
||||
path.as_str(),
|
||||
environment.namespace(),
|
||||
selector.as_str(),
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
extern crate serde_json;
|
||||
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
use reqwest::StatusCode;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
use crate::cloud_provider::digitalocean::api_structs::clusters::Clusters;
|
||||
use crate::cloud_provider::digitalocean::DO;
|
||||
use crate::cloud_provider::environment::Environment;
|
||||
@@ -6,12 +15,6 @@ use crate::constants::DIGITAL_OCEAN_TOKEN;
|
||||
use crate::container_registry::docr::get_header_with_bearer;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use crate::object_storage::do_space::download_space_object;
|
||||
use reqwest::StatusCode;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
extern crate serde_json;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
pub fn kubernetes_config_path(
|
||||
workspace_directory: &str,
|
||||
@@ -50,7 +53,7 @@ pub fn kubernetes_config_path(
|
||||
Ok(kubernetes_config_file_path.clone())
|
||||
}
|
||||
|
||||
pub const do_cluster_api_path: &str = "https://api.digitalocean.com/v2/kubernetes/clusters";
|
||||
pub const DO_CLUSTER_API_PATH: &str = "https://api.digitalocean.com/v2/kubernetes/clusters";
|
||||
|
||||
/*
|
||||
Waiting for https://github.com/pandaman64/serde-query/issues/2
|
||||
@@ -71,18 +74,19 @@ pub fn get_uuid_of_cluster_from_name(
|
||||
) -> Result<String, SimpleError> {
|
||||
let mut headers = get_header_with_bearer(token);
|
||||
let res = reqwest::blocking::Client::new()
|
||||
.get(do_cluster_api_path)
|
||||
.get(DO_CLUSTER_API_PATH)
|
||||
.headers(headers)
|
||||
.send();
|
||||
match res {
|
||||
|
||||
return match res {
|
||||
Ok(response) => match response.status() {
|
||||
StatusCode::OK => {
|
||||
let content = response.text().unwrap();
|
||||
let res_clusters = serde_json::from_str::<Clusters>(&content);
|
||||
match res_clusters{
|
||||
Ok(clusters) => match search_uuid_cluster_for(kube_cluster_name,clusters){
|
||||
Some(uuid) => return Ok(uuid),
|
||||
None => return Err(SimpleError::new(
|
||||
let res_clusters = serde_json::from_str::<Clusters>(&content);
|
||||
match res_clusters {
|
||||
Ok(clusters) => match search_uuid_cluster_for(kube_cluster_name, clusters) {
|
||||
Some(uuid) => Ok(uuid),
|
||||
None => Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(
|
||||
"Unable to retrieve cluster id from this name",
|
||||
@@ -91,16 +95,16 @@ pub fn get_uuid_of_cluster_from_name(
|
||||
}
|
||||
Err(e) => {
|
||||
print!("{}", e);
|
||||
return Err(SimpleError::new(
|
||||
Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(
|
||||
"While trying to deserialize json received from Digital Ocean API",
|
||||
),
|
||||
));
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => return Err(SimpleError::new(
|
||||
_ => Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(
|
||||
"Receive weird status Code from Digital Ocean while retrieving the cluster list",
|
||||
@@ -108,17 +112,17 @@ pub fn get_uuid_of_cluster_from_name(
|
||||
)),
|
||||
},
|
||||
Err(_) => {
|
||||
return Err(SimpleError::new(
|
||||
Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some("Unable to get any responses from Digital Ocean"),
|
||||
))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn search_uuid_cluster_for(kubeName: &str, clusters: Clusters) -> Option<String> {
|
||||
fn search_uuid_cluster_for(kube_name: &str, clusters: Clusters) -> Option<String> {
|
||||
for cluster in clusters.kubernetes_clusters {
|
||||
match cluster.name.eq(kubeName) {
|
||||
match cluster.name.eq(kube_name) {
|
||||
true => return Some(cluster.id),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ fn get_forbidden_cidr_per_region() -> HashMap<&'static str, &'static str, Random
|
||||
|
||||
pub fn get_used_cidr_on_region(token: &str) {
|
||||
let mut output_from_cli = String::new();
|
||||
utilities::exec_with_output(
|
||||
let _ = utilities::exec_with_output(
|
||||
"doctl",
|
||||
vec!["vpcs", "list", "--output", "json", "-t", token],
|
||||
|r_out| match r_out {
|
||||
@@ -49,14 +49,17 @@ pub fn get_used_cidr_on_region(token: &str) {
|
||||
Err(e) => error!("DOCTL Cli not respond well{}", e),
|
||||
},
|
||||
|r_err| match r_err {
|
||||
Ok(s) => error!("DOCTL Cli error from cmd inserted, please check vpcs list command{}",
|
||||
Ok(s) => error!(
|
||||
"DOCTL Cli error from cmd inserted, please check vpcs list command{}",
|
||||
s
|
||||
),
|
||||
Err(e) => error!("DOCTL Cli not respond good {}", e),
|
||||
},
|
||||
);
|
||||
|
||||
let buff = output_from_cli.borrow();
|
||||
let array: Vec<DoVpc> = serde_json::from_str(&buff).expect("JSON was not well-formatted");
|
||||
|
||||
for elem in array.iter() {
|
||||
let reg = &elem.region;
|
||||
let ip = &elem.ip_range;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::cloud_provider::common::workerNodeDataTemplate::WorkerNodeDataTemplate;
|
||||
use crate::cloud_provider::common::worker_node_data_template::WorkerNodeDataTemplate;
|
||||
use crate::cloud_provider::digitalocean::kubernetes::node::Node;
|
||||
use crate::cloud_provider::digitalocean::DO;
|
||||
use crate::cloud_provider::environment::Environment;
|
||||
@@ -13,11 +13,9 @@ use crate::models::{
|
||||
ProgressScope,
|
||||
};
|
||||
use crate::string::terraform_list_format;
|
||||
use digitalocean::api::Region;
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::thread;
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
@@ -50,7 +48,7 @@ pub struct DOKS<'a> {
|
||||
region: String,
|
||||
cloud_provider: &'a DO,
|
||||
nodes: Vec<Node>,
|
||||
dns_provider: &'a DnsProvider,
|
||||
dns_provider: &'a dyn DnsProvider,
|
||||
template_directory: String,
|
||||
options: Options,
|
||||
listeners: Listeners,
|
||||
@@ -64,7 +62,7 @@ impl<'a> DOKS<'a> {
|
||||
version: &str,
|
||||
region: &str,
|
||||
cloud_provider: &'a DO,
|
||||
dns_provider: &'a DnsProvider,
|
||||
dns_provider: &'a dyn DnsProvider,
|
||||
options: Options,
|
||||
nodes: Vec<Node>,
|
||||
) -> Self {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use std::io::Error;
|
||||
use std::path::Path;
|
||||
use tracing::{debug, error, info, span, warn, Level};
|
||||
use crate::cmd::structs::{Helm, HelmHistoryRow};
|
||||
use crate::cmd::utilities::exec_with_envs_and_output;
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
use std::io::Error;
|
||||
use std::path::Path;
|
||||
use tracing::{debug, error, info, span, warn, Level};
|
||||
|
||||
const HELM_DEFAULT_TIMEOUT_IN_SECONDS: u32 = 300;
|
||||
|
||||
@@ -168,7 +168,7 @@ where
|
||||
} else {
|
||||
error!("{}", line)
|
||||
}
|
||||
},
|
||||
}
|
||||
Err(err) => error!("{:?}", err),
|
||||
},
|
||||
) {
|
||||
@@ -320,7 +320,7 @@ where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let mut output_vec: Vec<String> = Vec::new();
|
||||
helm_exec_with_output(
|
||||
let _ = helm_exec_with_output(
|
||||
vec![
|
||||
"list",
|
||||
"-A",
|
||||
@@ -339,9 +339,11 @@ where
|
||||
Err(err) => error!("{}", err),
|
||||
},
|
||||
);
|
||||
|
||||
let output_string: String = output_vec.join("");
|
||||
let values = serde_json::from_str::<Vec<Helm>>(output_string.as_str());
|
||||
let mut helms_name: Vec<String> = Vec::new();
|
||||
|
||||
match values {
|
||||
Ok(all_helms) => {
|
||||
for helm in all_helms {
|
||||
@@ -354,6 +356,7 @@ where
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other, Some(message)));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(helms_name)
|
||||
}
|
||||
|
||||
@@ -362,10 +365,10 @@ pub fn helm_exec(args: Vec<&str>, envs: Vec<(&str, &str)>) -> Result<(), SimpleE
|
||||
args,
|
||||
envs,
|
||||
|line| {
|
||||
span!(Level::INFO, "{}","{}", line.unwrap());
|
||||
span!(Level::INFO, "{}", "{}", line.unwrap());
|
||||
},
|
||||
|line_err| {
|
||||
span!(Level::INFO, "{}","{}", line_err.unwrap());
|
||||
span!(Level::INFO, "{}", "{}", line_err.unwrap());
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ where
|
||||
// return the output of "binary_name" --version
|
||||
pub fn run_version_command_for(binary_name: &str) -> String {
|
||||
let mut output_from_cmd = String::new();
|
||||
exec_with_output(
|
||||
let _ = exec_with_output(
|
||||
binary_name,
|
||||
vec!["--version"],
|
||||
|r_out| match r_out {
|
||||
@@ -198,6 +198,7 @@ pub fn run_version_command_for(binary_name: &str) -> String {
|
||||
Err(e) => error!("Error while getting stderr from {} {}", binary_name, e),
|
||||
},
|
||||
);
|
||||
|
||||
output_from_cmd
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
use crate::build_platform::Image;
|
||||
use crate::cmd;
|
||||
use crate::container_registry::{ContainerRegistry, EngineError, Kind, PushResult};
|
||||
@@ -6,7 +5,7 @@ use crate::error::EngineErrorCause;
|
||||
use crate::models::{Context, Listener, Listeners};
|
||||
extern crate reqwest;
|
||||
|
||||
use reqwest::{StatusCode};
|
||||
use reqwest::StatusCode;
|
||||
pub struct DockerHub {
|
||||
context: Context,
|
||||
id: String,
|
||||
@@ -49,7 +48,7 @@ impl ContainerRegistry for DockerHub {
|
||||
fn is_valid(&self) -> Result<(), EngineError> {
|
||||
// check the version of docker and print it as info
|
||||
let mut output_from_cmd = String::new();
|
||||
cmd::utilities::exec_with_output(
|
||||
let _ = cmd::utilities::exec_with_output(
|
||||
"docker",
|
||||
vec!["--version"],
|
||||
|r_out| match r_out {
|
||||
@@ -61,6 +60,7 @@ impl ContainerRegistry for DockerHub {
|
||||
Err(e) => error!("Error while getting stderr from docker {}", e),
|
||||
},
|
||||
);
|
||||
|
||||
info!("Using Docker: {}", output_from_cmd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@ extern crate digitalocean;
|
||||
use std::rc::Rc;
|
||||
|
||||
use digitalocean::DigitalOcean;
|
||||
use reqwest::blocking::{Client, Response};
|
||||
use reqwest::header::{HeaderMap, HeaderValue};
|
||||
use reqwest::{header, StatusCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Error;
|
||||
|
||||
use crate::build_platform::Image;
|
||||
use crate::cmd;
|
||||
@@ -11,11 +16,6 @@ use crate::error::{EngineErrorCause, EngineErrorScope, SimpleError, SimpleErrorK
|
||||
use crate::models::{
|
||||
Context, Listener, Listeners, ListenersHelper, ProgressInfo, ProgressLevel, ProgressScope,
|
||||
};
|
||||
use reqwest::blocking::{Client, Response};
|
||||
use reqwest::header::{HeaderMap, HeaderValue};
|
||||
use reqwest::{header, StatusCode};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Error;
|
||||
|
||||
// TODO : use --output json
|
||||
// see https://www.digitalocean.com/community/tutorials/how-to-use-doctl-the-official-digitalocean-command-line-client
|
||||
@@ -85,8 +85,8 @@ pub struct Tier {
|
||||
pub monthly_price_in_cents: i64,
|
||||
}
|
||||
|
||||
pub const cr_api_path: &str = "https://api.digitalocean.com/v2/registry";
|
||||
pub const cr_cluster_api_path: &str = "https://api.digitalocean.com/v2/kubernetes/registry";
|
||||
pub const CR_API_PATH: &str = "https://api.digitalocean.com/v2/registry";
|
||||
pub const CR_CLUSTER_API_PATH: &str = "https://api.digitalocean.com/v2/kubernetes/registry";
|
||||
|
||||
impl DOCR {
|
||||
pub fn new(context: Context, id: &str, registry_name: &str, api_key: &str) -> Self {
|
||||
@@ -114,7 +114,7 @@ impl DOCR {
|
||||
match to_create_repo {
|
||||
Ok(repo_res) => {
|
||||
let res = reqwest::blocking::Client::new()
|
||||
.post(cr_api_path)
|
||||
.post(CR_API_PATH)
|
||||
.headers(headers)
|
||||
.body(repo_res)
|
||||
.send();
|
||||
@@ -141,7 +141,7 @@ impl DOCR {
|
||||
"failed to create repository {} : {:?}",
|
||||
&self.registry_name, e,
|
||||
),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ impl DOCR {
|
||||
"Unable to initialize DO Registry {} : {:?}",
|
||||
&self.registry_name, e,
|
||||
),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ impl DOCR {
|
||||
pub fn delete_repository(&self, _image: &Image) -> Result<(), EngineError> {
|
||||
let mut headers = get_header_with_bearer(&self.api_key);
|
||||
let res = reqwest::blocking::Client::new()
|
||||
.delete(cr_api_path)
|
||||
.delete(CR_API_PATH)
|
||||
.headers(headers)
|
||||
.send();
|
||||
match res {
|
||||
@@ -239,7 +239,7 @@ impl DOCR {
|
||||
"No response from the Digital Ocean API {} : {:?}",
|
||||
&self.registry_name, e,
|
||||
),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,45 +436,46 @@ pub fn subscribe_kube_cluster_to_container_registry(
|
||||
cluster_uuid: &str,
|
||||
) -> Result<(), SimpleError> {
|
||||
let mut headers = get_header_with_bearer(api_key);
|
||||
let clusterIds = DO_API_Subecribe_to_Kube_Cluster {
|
||||
let cluster_ids = DO_API_Subecribe_to_Kube_Cluster {
|
||||
cluster_uuids: vec![cluster_uuid.to_string()],
|
||||
};
|
||||
let res_cluster_to_link = serde_json::to_string(&clusterIds);
|
||||
match res_cluster_to_link {
|
||||
|
||||
let res_cluster_to_link = serde_json::to_string(&cluster_ids);
|
||||
return match res_cluster_to_link {
|
||||
Ok(cluster_to_link) => {
|
||||
let res = reqwest::blocking::Client::new()
|
||||
.post(cr_cluster_api_path)
|
||||
.post(CR_CLUSTER_API_PATH)
|
||||
.headers(headers)
|
||||
.body(cluster_to_link)
|
||||
.send();
|
||||
match res {
|
||||
Ok(output) => match output.status() {
|
||||
StatusCode::NO_CONTENT => return Ok(()),
|
||||
StatusCode::NO_CONTENT => Ok(()),
|
||||
status => {
|
||||
warn!("status from DO registry API {}", status);
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other,Some("Incorrect Status received from Digital Ocean when tyring to subscribe repository to cluster")));
|
||||
Err(SimpleError::new(SimpleErrorKind::Other, Some("Incorrect Status received from Digital Ocean when tyring to subscribe repository to cluster")))
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
error!("{:?}", e);
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other,Some("Unable to call Digital Ocean when tyring to subscribe repository to cluster")));
|
||||
Err(SimpleError::new(SimpleErrorKind::Other, Some("Unable to call Digital Ocean when tyring to subscribe repository to cluster")))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("{:?}", e);
|
||||
return Err(SimpleError::new(
|
||||
Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some("Unable to Serialize digital ocean cluster uuids"),
|
||||
));
|
||||
))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_current_registry_name(api_key: &str) -> Result<String, SimpleError> {
|
||||
let headers = get_header_with_bearer(api_key);
|
||||
let res = reqwest::blocking::Client::new()
|
||||
.get(cr_api_path)
|
||||
.get(CR_API_PATH)
|
||||
.headers(headers)
|
||||
.send();
|
||||
match res {
|
||||
@@ -495,7 +496,7 @@ pub fn get_current_registry_name(api_key: &str) -> Result<String, SimpleError> {
|
||||
}
|
||||
status => {
|
||||
warn!("status from DO registry API {}", status);
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other,Some("Incorrect Status received from Digital Ocean when tyring to subscribe repository to cluster")));
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other, Some("Incorrect Status received from Digital Ocean when tyring to subscribe repository to cluster")));
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
||||
@@ -95,7 +95,7 @@ fn archive_workspace_directory(
|
||||
|
||||
pub fn cleanup_workspace_directory(working_root_dir: &str, execution_id: &str) {
|
||||
let workspace_dir = crate::fs::root_workspace_directory(working_root_dir, execution_id);
|
||||
std::fs::remove_dir_all(workspace_dir);
|
||||
let _ = std::fs::remove_dir_all(workspace_dir);
|
||||
}
|
||||
|
||||
pub fn create_workspace_archive(
|
||||
|
||||
@@ -71,7 +71,7 @@ pub fn checkout(repo: &Repository, commit_id: &str, repo_url: &str) -> Result<()
|
||||
Ok(o) => o,
|
||||
};
|
||||
|
||||
repo.checkout_tree(&obj, None);
|
||||
let _ = repo.checkout_tree(&obj, None);
|
||||
|
||||
repo.set_head(&("refs/heads/".to_owned() + &commit_id))
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
use std::fs;
|
||||
use std::fs::{read_to_string, File};
|
||||
use std::io::{Read, Write};
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use std::{fs};
|
||||
|
||||
use retry::delay::Fibonacci;
|
||||
use retry::OperationResult;
|
||||
use rusoto_core::{Client, HttpClient, Region, RusotoError};
|
||||
use rusoto_credential::StaticProvider;
|
||||
use rusoto_s3::{
|
||||
GetObjectError, GetObjectRequest, ListObjectsV2Output, ListObjectsV2Request,
|
||||
S3Client, S3,
|
||||
GetObjectError, GetObjectRequest, ListObjectsV2Output, ListObjectsV2Request, S3Client, S3,
|
||||
};
|
||||
|
||||
use crate::cmd::utilities::exec_with_envs;
|
||||
@@ -71,7 +70,7 @@ pub fn get_object(
|
||||
match r {
|
||||
Ok(x) => {
|
||||
let mut s = String::new();
|
||||
x.body.unwrap().into_blocking_read().read_to_string(&mut s);
|
||||
let _ = x.body.unwrap().into_blocking_read().read_to_string(&mut s);
|
||||
|
||||
if s.is_empty() {
|
||||
// this handle a case where the request succeeds but contains an empty body.
|
||||
|
||||
@@ -393,15 +393,15 @@ impl<'a> Transaction<'a> {
|
||||
|
||||
let action = match failover_environment.action {
|
||||
Action::Create => {
|
||||
kubernetes.deploy_environment_error(&target_qe_environment);
|
||||
let _ = kubernetes.deploy_environment_error(&target_qe_environment);
|
||||
kubernetes.deploy_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Pause => {
|
||||
kubernetes.pause_environment_error(&target_qe_environment);
|
||||
let _ = kubernetes.pause_environment_error(&target_qe_environment);
|
||||
kubernetes.pause_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Delete => {
|
||||
kubernetes.delete_environment_error(&target_qe_environment);
|
||||
let _ = kubernetes.delete_environment_error(&target_qe_environment);
|
||||
kubernetes.delete_environment(&failover_qe_environment)
|
||||
}
|
||||
Action::Nothing => Ok(()),
|
||||
|
||||
Reference in New Issue
Block a user