mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
code format
This commit is contained in:
committed by
Pierre Mavro
parent
706581a0a5
commit
0c438d855a
@@ -7,8 +7,7 @@ use crate::error::{EngineError, EngineErrorCause, SimpleError, SimpleErrorKind};
|
||||
use crate::fs::workspace_directory;
|
||||
use crate::git::checkout_submodules;
|
||||
use crate::models::{
|
||||
Context, Listen, Listener, Listeners, ListenersHelper, ProgressInfo, ProgressLevel,
|
||||
ProgressScope,
|
||||
Context, Listen, Listener, Listeners, ListenersHelper, ProgressInfo, ProgressLevel, ProgressScope,
|
||||
};
|
||||
use crate::{cmd, git};
|
||||
|
||||
@@ -75,12 +74,7 @@ impl LocalDocker {
|
||||
|
||||
let name_with_tag = build.image.name_with_tag();
|
||||
|
||||
docker_args.extend(vec![
|
||||
"-f",
|
||||
dockerfile_complete_path,
|
||||
"-t",
|
||||
name_with_tag.as_str(),
|
||||
]);
|
||||
docker_args.extend(vec!["-f", dockerfile_complete_path, "-t", name_with_tag.as_str()]);
|
||||
|
||||
let mut docker_args = if env_var_args.is_empty() {
|
||||
docker_args
|
||||
@@ -156,10 +150,8 @@ impl LocalDocker {
|
||||
) -> Result<BuildResult, EngineError> {
|
||||
let name_with_tag = build.image.name_with_tag();
|
||||
|
||||
let mut exit_status: Result<(), SimpleError> = Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some("no builder names"),
|
||||
));
|
||||
let mut exit_status: Result<(), SimpleError> =
|
||||
Err(SimpleError::new(SimpleErrorKind::Other, Some("no builder names")));
|
||||
|
||||
for builder_name in BUILDPACKS_BUILDERS.iter() {
|
||||
let mut buildpacks_args = if !use_build_cache {
|
||||
@@ -266,17 +258,11 @@ impl BuildPlatform for LocalDocker {
|
||||
|
||||
fn is_valid(&self) -> Result<(), EngineError> {
|
||||
if !crate::cmd::utilities::does_binary_exist("docker") {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::Internal,
|
||||
String::from("docker binary not found"),
|
||||
));
|
||||
return Err(self.engine_error(EngineErrorCause::Internal, String::from("docker binary not found")));
|
||||
}
|
||||
|
||||
if !crate::cmd::utilities::does_binary_exist("pack") {
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::Internal,
|
||||
String::from("pack binary not found"),
|
||||
));
|
||||
return Err(self.engine_error(EngineErrorCause::Internal, String::from("pack binary not found")));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -288,10 +274,7 @@ impl BuildPlatform for LocalDocker {
|
||||
let listeners_helper = ListenersHelper::new(&self.listeners);
|
||||
|
||||
if !force_build && self.image_does_exist(&build.image)? {
|
||||
info!(
|
||||
"image {:?} does already exist - no need to build it",
|
||||
build.image
|
||||
);
|
||||
info!("image {:?} does already exist - no need to build it", build.image);
|
||||
|
||||
return Ok(BuildResult { build });
|
||||
}
|
||||
@@ -368,8 +351,7 @@ impl BuildPlatform for LocalDocker {
|
||||
|
||||
let mut disable_build_cache = false;
|
||||
|
||||
let mut env_var_args: Vec<String> =
|
||||
Vec::with_capacity(build.options.environment_variables.len());
|
||||
let mut env_var_args: Vec<String> = Vec::with_capacity(build.options.environment_variables.len());
|
||||
|
||||
for ev in &build.options.environment_variables {
|
||||
if ev.key == "QOVERY_DISABLE_BUILD_CACHE" && ev.value.to_lowercase() == "true" {
|
||||
@@ -409,11 +391,7 @@ impl BuildPlatform for LocalDocker {
|
||||
let result = match dockerfile_exists {
|
||||
true => {
|
||||
// build container from the provided Dockerfile
|
||||
let dockerfile_complete_path = format!(
|
||||
"{}/{}",
|
||||
into_dir.as_str(),
|
||||
dockerfile_relative_path.unwrap()
|
||||
);
|
||||
let dockerfile_complete_path = format!("{}/{}", into_dir.as_str(), dockerfile_relative_path.unwrap());
|
||||
|
||||
self.build_image_with_docker(
|
||||
build,
|
||||
@@ -481,8 +459,7 @@ impl Listen for LocalDocker {
|
||||
fn check_docker_space_usage_and_clean(docker_path_size_info: FsStats, envs: Vec<(&str, &str)>) {
|
||||
let docker_max_disk_percentage_usage_before_purge = 50; // arbitrary percentage that should make the job anytime
|
||||
|
||||
let docker_percentage_used =
|
||||
docker_path_size_info.available_space() * 100 / docker_path_size_info.total_space();
|
||||
let docker_percentage_used = docker_path_size_info.available_space() * 100 / docker_path_size_info.total_space();
|
||||
|
||||
if docker_percentage_used > docker_max_disk_percentage_usage_before_purge {
|
||||
warn!(
|
||||
|
||||
@@ -4,10 +4,9 @@ use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::environment::Kind;
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::{
|
||||
generate_supported_version, get_self_hosted_mongodb_version, get_supported_version_to_use,
|
||||
@@ -65,10 +64,7 @@ impl MongoDB {
|
||||
}
|
||||
|
||||
fn matching_correct_version(&self, is_managed_services: bool) -> Result<String, EngineError> {
|
||||
check_service_version(
|
||||
get_mongodb_version(self.version(), is_managed_services),
|
||||
self,
|
||||
)
|
||||
check_service_version(get_mongodb_version(self.version(), is_managed_services), self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,9 +135,7 @@ impl Service for MongoDB {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
@@ -149,10 +143,7 @@ impl Service for MongoDB {
|
||||
let version = self.matching_correct_version(is_managed_services)?;
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -214,10 +205,7 @@ impl Helm for MongoDB {
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,10 +362,7 @@ impl Listen for MongoDB {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_mongodb_version(
|
||||
requested_version: &str,
|
||||
is_managed_service: bool,
|
||||
) -> Result<String, StringError> {
|
||||
fn get_mongodb_version(requested_version: &str, is_managed_service: bool) -> Result<String, StringError> {
|
||||
if is_managed_service {
|
||||
get_managed_mongodb_version(requested_version)
|
||||
} else {
|
||||
|
||||
@@ -4,10 +4,9 @@ use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::environment::Kind;
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::{
|
||||
generate_supported_version, get_self_hosted_mysql_version, get_supported_version_to_use,
|
||||
@@ -136,9 +135,7 @@ impl Service for MySQL {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
@@ -146,10 +143,7 @@ impl Service for MySQL {
|
||||
let version = &self.matching_correct_version(is_managed_services)?;
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -173,10 +167,7 @@ impl Service for MySQL {
|
||||
context.insert("tfstate_suffix_name", &get_tfstate_suffix(self));
|
||||
context.insert("tfstate_name", &get_tfstate_name(self));
|
||||
|
||||
context.insert(
|
||||
"delete_automated_backups",
|
||||
&self.context().is_test_cluster(),
|
||||
);
|
||||
context.insert("delete_automated_backups", &self.context().is_test_cluster());
|
||||
if self.context.resource_expiration_in_seconds().is_some() {
|
||||
context.insert(
|
||||
"resource_expiration_in_seconds",
|
||||
@@ -216,10 +207,7 @@ impl Helm for MySQL {
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,10 +365,7 @@ impl Listen for MySQL {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_mysql_version(
|
||||
requested_version: &str,
|
||||
is_managed_service: bool,
|
||||
) -> Result<String, StringError> {
|
||||
fn get_mysql_version(requested_version: &str, is_managed_service: bool) -> Result<String, StringError> {
|
||||
if is_managed_service {
|
||||
get_managed_mysql_version(requested_version)
|
||||
} else {
|
||||
|
||||
@@ -4,14 +4,11 @@ use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::environment::Kind;
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::{
|
||||
get_self_hosted_redis_version, get_supported_version_to_use,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::{get_self_hosted_redis_version, get_supported_version_to_use};
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
use crate::cmd::helm::Timeout;
|
||||
use crate::cmd::kubectl;
|
||||
@@ -136,9 +133,7 @@ impl Service for Redis {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
let version = self.matching_correct_version(is_managed_services)?;
|
||||
@@ -154,18 +149,12 @@ impl Service for Redis {
|
||||
));
|
||||
};
|
||||
|
||||
context.insert(
|
||||
"database_elasticache_parameter_group_name",
|
||||
parameter_group_name,
|
||||
);
|
||||
context.insert("database_elasticache_parameter_group_name", parameter_group_name);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -227,10 +216,7 @@ impl Helm for Redis {
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,10 +373,7 @@ impl Listen for Redis {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_redis_version(
|
||||
requested_version: &str,
|
||||
is_managed_service: bool,
|
||||
) -> Result<String, StringError> {
|
||||
fn get_redis_version(requested_version: &str, is_managed_service: bool) -> Result<String, StringError> {
|
||||
if is_managed_service {
|
||||
get_managed_redis_version(requested_version)
|
||||
} else {
|
||||
|
||||
@@ -3,9 +3,9 @@ use tera::Context as TeraContext;
|
||||
use crate::build_platform::Image;
|
||||
use crate::cloud_provider::models::{EnvironmentVariable, EnvironmentVariableDataTemplate};
|
||||
use crate::cloud_provider::service::{
|
||||
default_tera_context, delete_stateless_service, deploy_stateless_service_error,
|
||||
deploy_user_stateless_service, send_progress_on_long_task, Action, Application as AApplication,
|
||||
Create, Delete, Helm, Pause, Service, ServiceType, StatelessService,
|
||||
default_tera_context, delete_stateless_service, deploy_stateless_service_error, deploy_user_stateless_service,
|
||||
send_progress_on_long_task, Action, Application as AApplication, Create, Delete, Helm, Pause, Service, ServiceType,
|
||||
StatelessService,
|
||||
};
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
use crate::cmd::helm::Timeout;
|
||||
@@ -64,10 +64,7 @@ impl crate::cloud_provider::service::Application for ExternalService {
|
||||
|
||||
impl Helm for ExternalService {
|
||||
fn helm_release_name(&self) -> String {
|
||||
crate::string::cut(
|
||||
format!("external-service-{}-{}", self.name(), self.id()),
|
||||
50,
|
||||
)
|
||||
crate::string::cut(format!("external-service-{}-{}", self.name(), self.id()), 50)
|
||||
}
|
||||
|
||||
fn helm_chart_dir(&self) -> String {
|
||||
@@ -145,7 +142,10 @@ impl Service for ExternalService {
|
||||
Some(registry_url) => context.insert("image_name_with_tag", registry_url.as_str()),
|
||||
None => {
|
||||
let image_name_with_tag = self.image().name_with_tag();
|
||||
warn!("there is no registry url, use image name with tag with the default container registry: {}", image_name_with_tag.as_str());
|
||||
warn!(
|
||||
"there is no registry url, use image name with tag with the default container registry: {}",
|
||||
image_name_with_tag.as_str()
|
||||
);
|
||||
context.insert("image_name_with_tag", image_name_with_tag.as_str());
|
||||
}
|
||||
}
|
||||
@@ -175,10 +175,7 @@ impl Service for ExternalService {
|
||||
|
||||
impl Create for ExternalService {
|
||||
fn on_create(&self, target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
info!(
|
||||
"AWS.external_service.on_create() called for {}",
|
||||
self.name()
|
||||
);
|
||||
info!("AWS.external_service.on_create() called for {}", self.name());
|
||||
|
||||
send_progress_on_long_task(
|
||||
self,
|
||||
@@ -192,10 +189,7 @@ impl Create for ExternalService {
|
||||
}
|
||||
|
||||
fn on_create_error(&self, target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
warn!(
|
||||
"AWS.external_service.on_create_error() called for {}",
|
||||
self.name()
|
||||
);
|
||||
warn!("AWS.external_service.on_create_error() called for {}", self.name());
|
||||
|
||||
send_progress_on_long_task(
|
||||
self,
|
||||
@@ -221,10 +215,7 @@ impl Pause for ExternalService {
|
||||
}
|
||||
|
||||
fn on_pause_error(&self, target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
warn!(
|
||||
"AWS.external_service.on_pause_error() called for {}",
|
||||
self.name()
|
||||
);
|
||||
warn!("AWS.external_service.on_pause_error() called for {}", self.name());
|
||||
|
||||
send_progress_on_long_task(
|
||||
self,
|
||||
@@ -236,10 +227,7 @@ impl Pause for ExternalService {
|
||||
|
||||
impl Delete for ExternalService {
|
||||
fn on_delete(&self, target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
info!(
|
||||
"AWS.external_service.on_delete() called for {}",
|
||||
self.name()
|
||||
);
|
||||
info!("AWS.external_service.on_delete() called for {}", self.name());
|
||||
|
||||
send_progress_on_long_task(
|
||||
self,
|
||||
@@ -253,10 +241,7 @@ impl Delete for ExternalService {
|
||||
}
|
||||
|
||||
fn on_delete_error(&self, target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
warn!(
|
||||
"AWS.external_service.on_delete_error() called for {}",
|
||||
self.name()
|
||||
);
|
||||
warn!("AWS.external_service.on_delete_error() called for {}", self.name());
|
||||
|
||||
send_progress_on_long_task(
|
||||
self,
|
||||
|
||||
@@ -73,38 +73,17 @@ mod tests {
|
||||
assert_eq!(Node::new_with_cpu_and_mem(0, 1).instance_type(), "t2.micro");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(1, 1).instance_type(), "t2.micro");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(1, 2).instance_type(), "t2.small");
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(2, 4).instance_type(),
|
||||
"t2.medium"
|
||||
);
|
||||
assert_eq!(Node::new_with_cpu_and_mem(2, 4).instance_type(), "t2.medium");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(2, 5).instance_type(), "t2.large");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(1, 6).instance_type(), "t2.large");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(1, 7).instance_type(), "t2.large");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(2, 8).instance_type(), "t2.large");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(3, 8).instance_type(), "t2.large");
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(3, 10).instance_type(),
|
||||
"t2.xlarge"
|
||||
);
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(3, 12).instance_type(),
|
||||
"t2.xlarge"
|
||||
);
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(4, 16).instance_type(),
|
||||
"t2.xlarge"
|
||||
);
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(4, 17).instance_type(),
|
||||
"t2.2xlarge"
|
||||
);
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(8, 32).instance_type(),
|
||||
"t2.2xlarge"
|
||||
);
|
||||
assert_eq!(
|
||||
Node::new_with_cpu_and_mem(16, 64).instance_type(),
|
||||
"t2.2xlarge"
|
||||
);
|
||||
assert_eq!(Node::new_with_cpu_and_mem(3, 10).instance_type(), "t2.xlarge");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(3, 12).instance_type(), "t2.xlarge");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(4, 16).instance_type(), "t2.xlarge");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(4, 17).instance_type(), "t2.2xlarge");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(8, 32).instance_type(), "t2.2xlarge");
|
||||
assert_eq!(Node::new_with_cpu_and_mem(16, 64).instance_type(), "t2.2xlarge");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +91,13 @@ impl CloudProvider for AWS {
|
||||
match s {
|
||||
Ok(_x) => Ok(()),
|
||||
Err(_) => {
|
||||
return Err(
|
||||
self.engine_error(
|
||||
EngineErrorCause::User("Your AWS 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 AWS {}", self.name_with_id()))
|
||||
);
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your AWS 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 AWS {}", self.name_with_id()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::get_self_hosted_mongodb_version;
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
@@ -126,9 +125,7 @@ impl Service for MongoDB {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
@@ -136,10 +133,7 @@ impl Service for MongoDB {
|
||||
let version = self.matching_correct_version()?;
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -197,33 +191,21 @@ impl Helm for MongoDB {
|
||||
}
|
||||
|
||||
fn helm_chart_values_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/chart_values/mongodb",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/chart_values/mongodb", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
impl Terraform for MongoDB {
|
||||
fn terraform_common_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/common",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/common", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn terraform_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/mongodb",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/mongodb", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::get_self_hosted_mysql_version;
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
@@ -126,9 +125,7 @@ impl Service for MySQL {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
@@ -136,10 +133,7 @@ impl Service for MySQL {
|
||||
let version = &self.matching_correct_version()?;
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -162,10 +156,7 @@ impl Service for MySQL {
|
||||
context.insert("tfstate_suffix_name", &get_tfstate_suffix(self));
|
||||
context.insert("tfstate_name", &get_tfstate_name(self));
|
||||
|
||||
context.insert(
|
||||
"delete_automated_backups",
|
||||
&self.context().is_test_cluster(),
|
||||
);
|
||||
context.insert("delete_automated_backups", &self.context().is_test_cluster());
|
||||
if self.context.resource_expiration_in_seconds().is_some() {
|
||||
context.insert(
|
||||
"resource_expiration_in_seconds",
|
||||
@@ -205,10 +196,7 @@ impl Helm for MySQL {
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::get_self_hosted_postgres_version;
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
@@ -126,9 +125,7 @@ impl Service for PostgreSQL {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
context.insert("namespace", environment.namespace());
|
||||
@@ -136,10 +133,7 @@ impl Service for PostgreSQL {
|
||||
let version = self.matching_correct_version()?;
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -162,10 +156,7 @@ impl Service for PostgreSQL {
|
||||
context.insert("tfstate_suffix_name", &get_tfstate_suffix(self));
|
||||
context.insert("tfstate_name", &get_tfstate_name(self));
|
||||
|
||||
context.insert(
|
||||
"delete_automated_backups",
|
||||
&self.context().is_test_cluster(),
|
||||
);
|
||||
context.insert("delete_automated_backups", &self.context().is_test_cluster());
|
||||
|
||||
if self.context.resource_expiration_in_seconds().is_some() {
|
||||
context.insert(
|
||||
@@ -202,33 +193,21 @@ impl Helm for PostgreSQL {
|
||||
}
|
||||
|
||||
fn helm_chart_values_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/chart_values/postgresql",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/chart_values/postgresql", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
impl Terraform for PostgreSQL {
|
||||
fn terraform_common_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/common",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/common", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn terraform_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/postgresql",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/postgresql", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,10 +268,7 @@ impl Delete for PostgreSQL {
|
||||
}
|
||||
|
||||
fn on_delete_error(&self, _target: &DeploymentTarget) -> Result<(), EngineError> {
|
||||
warn!(
|
||||
"AWS.PostgreSQL.on_create_error() called for {}",
|
||||
self.name()
|
||||
);
|
||||
warn!("AWS.PostgreSQL.on_create_error() called for {}", self.name());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use tera::Context as TeraContext;
|
||||
|
||||
use crate::cloud_provider::service::{
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service,
|
||||
get_tfstate_name, get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create,
|
||||
Database, DatabaseOptions, DatabaseType, Delete, Downgrade, Helm, Pause, Service, ServiceType,
|
||||
StatefulService, Terraform, Upgrade,
|
||||
check_service_version, default_tera_context, delete_stateful_service, deploy_stateful_service, get_tfstate_name,
|
||||
get_tfstate_suffix, send_progress_on_long_task, Action, Backup, Create, Database, DatabaseOptions, DatabaseType,
|
||||
Delete, Downgrade, Helm, Pause, Service, ServiceType, StatefulService, Terraform, Upgrade,
|
||||
};
|
||||
use crate::cloud_provider::utilities::get_self_hosted_redis_version;
|
||||
use crate::cloud_provider::DeploymentTarget;
|
||||
@@ -126,9 +125,7 @@ impl Service for Redis {
|
||||
kubectl::kubectl_exec_create_namespace_without_labels(
|
||||
&environment.namespace(),
|
||||
kube_config_file_path.as_str(),
|
||||
kubernetes
|
||||
.cloud_provider()
|
||||
.credentials_environment_variables(),
|
||||
kubernetes.cloud_provider().credentials_environment_variables(),
|
||||
);
|
||||
|
||||
let version = self.matching_correct_version()?;
|
||||
@@ -136,10 +133,7 @@ impl Service for Redis {
|
||||
context.insert("namespace", environment.namespace());
|
||||
context.insert("version", &version);
|
||||
|
||||
for (k, v) in kubernetes
|
||||
.cloud_provider()
|
||||
.tera_context_environment_variables()
|
||||
{
|
||||
for (k, v) in kubernetes.cloud_provider().tera_context_environment_variables() {
|
||||
context.insert(k, v);
|
||||
}
|
||||
|
||||
@@ -197,33 +191,21 @@ impl Helm for Redis {
|
||||
}
|
||||
|
||||
fn helm_chart_values_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/chart_values/redis",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/chart_values/redis", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn helm_chart_external_name_service_dir(&self) -> String {
|
||||
format!(
|
||||
"{}/common/charts/external-name-svc",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/common/charts/external-name-svc", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
impl Terraform for Redis {
|
||||
fn terraform_common_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/common",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/common", self.context.lib_root_dir())
|
||||
}
|
||||
|
||||
fn terraform_resource_dir_path(&self) -> String {
|
||||
format!(
|
||||
"{}/digitalocean/services/redis",
|
||||
self.context.lib_root_dir()
|
||||
)
|
||||
format!("{}/digitalocean/services/redis", self.context.lib_root_dir())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,12 +83,13 @@ impl CloudProvider for DO {
|
||||
match client {
|
||||
Ok(_x) => Ok(()),
|
||||
Err(_) => {
|
||||
return Err(
|
||||
self.engine_error(
|
||||
EngineErrorCause::User("Your AWS 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 Digital Ocean {}", self.name_with_id()))
|
||||
);
|
||||
return Err(self.engine_error(
|
||||
EngineErrorCause::User(
|
||||
"Your AWS 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 Digital Ocean {}", self.name_with_id()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ pub struct Cluster {
|
||||
pub kubernetes_cluster: KubernetesCluster,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct KubernetesCluster {
|
||||
|
||||
@@ -113,8 +113,7 @@ pub struct FAnnotations {
|
||||
pub f_service_beta_kubernetes_io_do_loadbalancer_enable_proxy_protocol:
|
||||
Option<FServiceBetaKubernetesIoDoLoadbalancerEnableProxyProtocol>,
|
||||
#[serde(rename = "f:kubernetes.digitalocean.com/load-balancer-id")]
|
||||
pub f_kubernetes_digitalocean_com_load_balancer_id:
|
||||
Option<FKubernetesDigitaloceanComLoadBalancerId>,
|
||||
pub f_kubernetes_digitalocean_com_load_balancer_id: Option<FKubernetesDigitaloceanComLoadBalancerId>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, serde_derive::Serialize, serde_derive::Deserialize)]
|
||||
|
||||
@@ -97,8 +97,7 @@ impl Environment {
|
||||
EnvironmentResources {
|
||||
pods: required_pods,
|
||||
cpu: total_cpu_for_stateless_services + total_cpu_for_stateful_services,
|
||||
ram_in_mib: total_ram_in_mib_for_stateless_services
|
||||
+ total_ram_in_mib_for_stateless_services,
|
||||
ram_in_mib: total_ram_in_mib_for_stateless_services + total_ram_in_mib_for_stateless_services,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ where
|
||||
chart_root_dir.as_ref().to_str().unwrap()
|
||||
);
|
||||
|
||||
let helm_history_rows =
|
||||
helm_exec_history(kubernetes_config.as_ref(), namespace, release_name, envs)?;
|
||||
let helm_history_rows = helm_exec_history(kubernetes_config.as_ref(), namespace, release_name, envs)?;
|
||||
|
||||
// take the last deployment from helm history - or return none if there is no history
|
||||
Ok(match helm_history_rows.first() {
|
||||
@@ -220,10 +219,7 @@ where
|
||||
},
|
||||
) {
|
||||
Ok(_) => info!("Helm uninstall fail with : {}", helmlist_string.clone()),
|
||||
Err(_) => info!(
|
||||
"Helm history found for release name: {}",
|
||||
helmlist_string.clone()
|
||||
),
|
||||
Err(_) => info!("Helm history found for release name: {}", helmlist_string.clone()),
|
||||
};
|
||||
Ok(output_vec.join(""))
|
||||
}
|
||||
@@ -304,8 +300,7 @@ where
|
||||
chart_root_dir.as_ref().to_str().unwrap()
|
||||
);
|
||||
|
||||
let helm_history_rows =
|
||||
helm_exec_history(kubernetes_config.as_ref(), namespace, release_name, envs)?;
|
||||
let helm_history_rows = helm_exec_history(kubernetes_config.as_ref(), namespace, release_name, envs)?;
|
||||
|
||||
// take the last deployment from helm history - or return none if there is no history
|
||||
Ok(match helm_history_rows.first() {
|
||||
@@ -314,10 +309,7 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
pub fn helm_list<P>(
|
||||
kubernetes_config: P,
|
||||
envs: Vec<(&str, &str)>,
|
||||
) -> Result<Vec<String>, SimpleError>
|
||||
pub fn helm_list<P>(kubernetes_config: P, envs: Vec<(&str, &str)>) -> Result<Vec<String>, SimpleError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
|
||||
@@ -7,8 +7,8 @@ use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::cloud_provider::digitalocean::models::svc::DOKubernetesList;
|
||||
use crate::cmd::structs::{
|
||||
Item, KubernetesEvent, KubernetesJob, KubernetesList, KubernetesNode, KubernetesPod,
|
||||
KubernetesPodStatusPhase, KubernetesService, LabelsContent,
|
||||
Item, KubernetesEvent, KubernetesJob, KubernetesList, KubernetesNode, KubernetesPod, KubernetesPodStatusPhase,
|
||||
KubernetesService, LabelsContent,
|
||||
};
|
||||
use crate::cmd::utilities::exec_with_envs_and_output;
|
||||
use crate::constants::KUBECONFIG;
|
||||
@@ -107,10 +107,7 @@ where
|
||||
Err(err) => {
|
||||
error!("{:?}", err);
|
||||
error!("{}", output_string.as_str());
|
||||
return Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(output_string),
|
||||
));
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other, Some(output_string)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,16 +124,7 @@ where
|
||||
{
|
||||
match do_kubectl_exec_describe_service(kubernetes_config, namespace, selector, envs) {
|
||||
Ok(result) => {
|
||||
if result.items.is_empty()
|
||||
|| result
|
||||
.items
|
||||
.first()
|
||||
.unwrap()
|
||||
.status
|
||||
.load_balancer
|
||||
.ingress
|
||||
.is_empty()
|
||||
{
|
||||
if result.items.is_empty() || result.items.first().unwrap().status.load_balancer.ingress.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
@@ -169,16 +157,7 @@ where
|
||||
{
|
||||
match do_kubectl_exec_describe_service(kubernetes_config, namespace, selector, envs) {
|
||||
Ok(result) => {
|
||||
if result.items.is_empty()
|
||||
|| result
|
||||
.items
|
||||
.first()
|
||||
.unwrap()
|
||||
.status
|
||||
.load_balancer
|
||||
.ingress
|
||||
.is_empty()
|
||||
{
|
||||
if result.items.is_empty() || result.items.first().unwrap().status.load_balancer.ingress.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
@@ -215,16 +194,7 @@ where
|
||||
envs,
|
||||
)?;
|
||||
|
||||
if result.items.is_empty()
|
||||
|| result
|
||||
.items
|
||||
.first()
|
||||
.unwrap()
|
||||
.status
|
||||
.load_balancer
|
||||
.ingress
|
||||
.is_empty()
|
||||
{
|
||||
if result.items.is_empty() || result.items.first().unwrap().status.load_balancer.ingress.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
@@ -299,15 +269,7 @@ where
|
||||
{
|
||||
let result = kubectl_exec_get_pod(kubernetes_config, namespace, selector, envs)?;
|
||||
|
||||
if result.items.is_empty()
|
||||
|| result
|
||||
.items
|
||||
.first()
|
||||
.unwrap()
|
||||
.status
|
||||
.container_statuses
|
||||
.is_empty()
|
||||
{
|
||||
if result.items.is_empty() || result.items.first().unwrap().status.container_statuses.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
@@ -387,11 +349,7 @@ where
|
||||
Ok(Some(false))
|
||||
}
|
||||
|
||||
pub fn kubectl_exec_is_namespace_present<P>(
|
||||
kubernetes_config: P,
|
||||
namespace: &str,
|
||||
envs: Vec<(&str, &str)>,
|
||||
) -> bool
|
||||
pub fn kubectl_exec_is_namespace_present<P>(kubernetes_config: P, namespace: &str, envs: Vec<(&str, &str)>) -> bool
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
@@ -425,11 +383,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn kubectl_exec_create_namespace_without_labels(
|
||||
namespace: &str,
|
||||
kube_config: &str,
|
||||
envs: Vec<(&str, &str)>,
|
||||
) {
|
||||
pub fn kubectl_exec_create_namespace_without_labels(namespace: &str, kube_config: &str, envs: Vec<(&str, &str)>) {
|
||||
let _ = kubectl_exec_create_namespace(kube_config, namespace, None, envs);
|
||||
}
|
||||
|
||||
@@ -443,11 +397,7 @@ where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
// don't create the namespace if already exists and not not return error in this case
|
||||
if !kubectl_exec_is_namespace_present(
|
||||
kubernetes_config.as_ref(),
|
||||
namespace.clone(),
|
||||
envs.clone(),
|
||||
) {
|
||||
if !kubectl_exec_is_namespace_present(kubernetes_config.as_ref(), namespace.clone(), envs.clone()) {
|
||||
// create namespace
|
||||
let mut _envs = Vec::with_capacity(envs.len() + 1);
|
||||
_envs.push((KUBECONFIG, kubernetes_config.as_ref().to_str().unwrap()));
|
||||
@@ -494,11 +444,7 @@ where
|
||||
));
|
||||
};
|
||||
|
||||
if !kubectl_exec_is_namespace_present(
|
||||
kubernetes_config.as_ref(),
|
||||
namespace.clone(),
|
||||
envs.clone(),
|
||||
) {
|
||||
if !kubectl_exec_is_namespace_present(kubernetes_config.as_ref(), namespace.clone(), envs.clone()) {
|
||||
return Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(format! {"Can't set labels on namespace {} because it doesn't exists", namespace}),
|
||||
@@ -512,10 +458,7 @@ where
|
||||
for label in labels.iter() {
|
||||
labels_string.push(format! {"{}={}", label.name, label.value});
|
||||
}
|
||||
let labels_str = labels_string
|
||||
.iter()
|
||||
.map(|x| x.as_ref())
|
||||
.collect::<Vec<&str>>();
|
||||
let labels_str = labels_string.iter().map(|x| x.as_ref()).collect::<Vec<&str>>();
|
||||
command_args.extend(labels_str);
|
||||
|
||||
let mut _envs = Vec::with_capacity(envs.len() + 1);
|
||||
@@ -584,11 +527,8 @@ pub fn kubectl_exec_get_all_namespaces<P>(
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let result = kubectl_exec::<P, KubernetesList<Item>>(
|
||||
vec!["get", "namespaces", "-o", "json"],
|
||||
kubernetes_config,
|
||||
envs,
|
||||
);
|
||||
let result =
|
||||
kubectl_exec::<P, KubernetesList<Item>>(vec!["get", "namespaces", "-o", "json"], kubernetes_config, envs);
|
||||
|
||||
let mut to_return: Vec<String> = Vec::new();
|
||||
|
||||
@@ -743,11 +683,7 @@ pub fn kubectl_exec_get_node<P>(
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
kubectl_exec::<P, KubernetesList<KubernetesNode>>(
|
||||
vec!["get", "node", "-o", "json"],
|
||||
kubernetes_config,
|
||||
envs,
|
||||
)
|
||||
kubectl_exec::<P, KubernetesList<KubernetesNode>>(vec!["get", "node", "-o", "json"], kubernetes_config, envs)
|
||||
}
|
||||
|
||||
pub fn kubectl_exec_get_pod<P>(
|
||||
@@ -782,11 +718,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
fn kubectl_exec<P, T>(
|
||||
args: Vec<&str>,
|
||||
kubernetes_config: P,
|
||||
envs: Vec<(&str, &str)>,
|
||||
) -> Result<T, SimpleError>
|
||||
fn kubectl_exec<P, T>(args: Vec<&str>, kubernetes_config: P, envs: Vec<(&str, &str)>) -> Result<T, SimpleError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
T: DeserializeOwned,
|
||||
@@ -816,10 +748,7 @@ where
|
||||
Err(err) => {
|
||||
error!("{:?}", err);
|
||||
error!("{}", output_string.as_str());
|
||||
return Err(SimpleError::new(
|
||||
SimpleErrorKind::Other,
|
||||
Some(output_string),
|
||||
));
|
||||
return Err(SimpleError::new(SimpleErrorKind::Other, Some(output_string)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,10 +46,7 @@ fn terraform_exec_with_init_validate_plan(root_dir: &str) -> Result<(), SimpleEr
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn terraform_exec_with_init_validate_plan_apply(
|
||||
root_dir: &str,
|
||||
dry_run: bool,
|
||||
) -> Result<(), SimpleError> {
|
||||
pub fn terraform_exec_with_init_validate_plan_apply(root_dir: &str, dry_run: bool) -> Result<(), SimpleError> {
|
||||
match terraform_exec_with_init_validate_plan(root_dir) {
|
||||
Ok(_) => match dry_run {
|
||||
true => {
|
||||
|
||||
@@ -29,9 +29,7 @@ where
|
||||
|
||||
let mut cmd = Command::new(&_binary);
|
||||
|
||||
cmd.args(&args)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
cmd.args(&args).stdout(Stdio::piped()).stderr(Stdio::piped());
|
||||
|
||||
if current_dir.is_some() {
|
||||
cmd.current_dir(current_dir.unwrap());
|
||||
@@ -68,11 +66,7 @@ where
|
||||
))
|
||||
}
|
||||
|
||||
pub fn exec_with_envs<P>(
|
||||
binary: P,
|
||||
args: Vec<&str>,
|
||||
envs: Vec<(&str, &str)>,
|
||||
) -> Result<(), SimpleError>
|
||||
pub fn exec_with_envs<P>(binary: P, args: Vec<&str>, envs: Vec<(&str, &str)>) -> Result<(), SimpleError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
@@ -224,18 +218,11 @@ where
|
||||
format!("{} {}", binary.as_ref().to_str().unwrap(), args.join(" "))
|
||||
}
|
||||
|
||||
pub fn command_with_envs_to_string<P>(
|
||||
binary: P,
|
||||
args: &Vec<&str>,
|
||||
envs: &Vec<(&str, &str)>,
|
||||
) -> String
|
||||
pub fn command_with_envs_to_string<P>(binary: P, args: &Vec<&str>, envs: &Vec<(&str, &str)>) -> String
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let _envs = envs
|
||||
.iter()
|
||||
.map(|(k, v)| format!("{}={}", k, v))
|
||||
.collect::<Vec<_>>();
|
||||
let _envs = envs.iter().map(|(k, v)| format!("{}={}", k, v)).collect::<Vec<_>>();
|
||||
|
||||
format!(
|
||||
"{} {} {}",
|
||||
|
||||
@@ -2,4 +2,4 @@ pub const TF_PLUGIN_CACHE_DIR: &str = "TF_PLUGIN_CACHE_DIR";
|
||||
pub const AWS_ACCESS_KEY_ID: &str = "AWS_ACCESS_KEY_ID";
|
||||
pub const AWS_SECRET_ACCESS_KEY: &str = "AWS_SECRET_ACCESS_KEY";
|
||||
pub const KUBECONFIG: &str = "KUBECONFIG";
|
||||
pub const DIGITAL_OCEAN_TOKEN: &str = "DIGITAL_OCEAN_TOKEN";
|
||||
pub const DIGITAL_OCEAN_TOKEN: &str = "DIGITAL_OCEAN_TOKEN";
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
pub fn get_firsts_namespaces_to_delete(namespaces: Vec<&str>) -> Vec<&str> {
|
||||
// from all namesapce remove managed and never delete namespaces
|
||||
let minus_managed = minus_namespaces(namespaces, get_qovery_managed_namespaces());
|
||||
let minus_qovery_managed_and_never_delete =
|
||||
minus_namespaces(minus_managed, get_never_delete_namespaces());
|
||||
let minus_qovery_managed_and_never_delete = minus_namespaces(minus_managed, get_never_delete_namespaces());
|
||||
minus_qovery_managed_and_never_delete
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,7 @@ pub struct EngineError {
|
||||
}
|
||||
|
||||
impl EngineError {
|
||||
pub fn new<T, S>(
|
||||
cause: EngineErrorCause,
|
||||
scope: EngineErrorScope,
|
||||
execution_id: T,
|
||||
message: Option<S>,
|
||||
) -> Self
|
||||
pub fn new<T, S>(cause: EngineErrorCause, scope: EngineErrorScope, execution_id: T, message: Option<S>) -> Self
|
||||
where
|
||||
T: Into<String>,
|
||||
S: Into<String>,
|
||||
|
||||
31
src/fs.rs
31
src/fs.rs
@@ -8,19 +8,13 @@ use flate2::Compression;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn copy_files(from: &Path, to: &Path, exclude_j2_files: bool) -> Result<(), Error> {
|
||||
let files = WalkDir::new(from)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok());
|
||||
let files = WalkDir::new(from).follow_links(true).into_iter().filter_map(|e| e.ok());
|
||||
|
||||
let files = match exclude_j2_files {
|
||||
true => files
|
||||
.filter(|e| {
|
||||
// return only non *.j2.* files
|
||||
e.file_name()
|
||||
.to_str()
|
||||
.map(|s| !s.contains(".j2."))
|
||||
.unwrap_or(false)
|
||||
e.file_name().to_str().map(|s| !s.contains(".j2.")).unwrap_or(false)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
false => files.collect::<Vec<_>>(),
|
||||
@@ -31,11 +25,7 @@ pub fn copy_files(from: &Path, to: &Path, exclude_j2_files: bool) -> Result<(),
|
||||
|
||||
for file in files {
|
||||
let path_str = file.path().to_str().unwrap();
|
||||
let dest = format!(
|
||||
"{}{}",
|
||||
to.to_str().unwrap(),
|
||||
path_str.replace(from_str, "").as_str()
|
||||
);
|
||||
let dest = format!("{}{}", to.to_str().unwrap(), path_str.replace(from_str, "").as_str());
|
||||
|
||||
if file.metadata().unwrap().is_dir() {
|
||||
let _ = fs::create_dir_all(&dest)?;
|
||||
@@ -73,16 +63,10 @@ where
|
||||
dir
|
||||
}
|
||||
|
||||
fn archive_workspace_directory(
|
||||
working_root_dir: &str,
|
||||
execution_id: &str,
|
||||
) -> Result<String, std::io::Error> {
|
||||
fn archive_workspace_directory(working_root_dir: &str, execution_id: &str) -> Result<String, std::io::Error> {
|
||||
let workspace_dir = crate::fs::root_workspace_directory(working_root_dir, execution_id);
|
||||
|
||||
let tar_gz_file_path = format!(
|
||||
"{}/.qovery-workspace/{}.tar.gz",
|
||||
working_root_dir, execution_id
|
||||
);
|
||||
let tar_gz_file_path = format!("{}/.qovery-workspace/{}.tar.gz", working_root_dir, execution_id);
|
||||
|
||||
let tar_gz_file = File::create(tar_gz_file_path.as_str())?;
|
||||
|
||||
@@ -98,10 +82,7 @@ pub fn cleanup_workspace_directory(working_root_dir: &str, execution_id: &str) {
|
||||
let _ = std::fs::remove_dir_all(workspace_dir);
|
||||
}
|
||||
|
||||
pub fn create_workspace_archive(
|
||||
working_root_dir: &str,
|
||||
execution_id: &str,
|
||||
) -> Result<String, std::io::Error> {
|
||||
pub fn create_workspace_archive(working_root_dir: &str, execution_id: &str) -> Result<String, std::io::Error> {
|
||||
info!("archive workspace directory in progress");
|
||||
|
||||
match archive_workspace_directory(working_root_dir, execution_id) {
|
||||
|
||||
18
src/git.rs
18
src/git.rs
@@ -5,11 +5,7 @@ use git2::{Error, Oid, Repository};
|
||||
|
||||
/// TODO support SSH repository_url - we assume that the repository URL starts with HTTPS
|
||||
/// TODO support git submodules
|
||||
pub fn clone<P>(
|
||||
repository_url: &str,
|
||||
into_dir: P,
|
||||
credentials: &Option<Credentials>,
|
||||
) -> Result<Repository, Error>
|
||||
pub fn clone<P>(repository_url: &str, into_dir: P, credentials: &Option<Credentials>) -> Result<Repository, Error>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
@@ -44,11 +40,7 @@ pub fn checkout(repo: &Repository, commit_id: &str, repo_url: &str) -> Result<()
|
||||
let _ = match repo.find_commit(oid) {
|
||||
Err(e) => {
|
||||
let mut x = git2::Error::from_str(
|
||||
format!(
|
||||
"Commit ID {} on repository {} was not found",
|
||||
&commit_id, &repo_url
|
||||
)
|
||||
.as_ref(),
|
||||
format!("Commit ID {} on repository {} was not found", &commit_id, &repo_url).as_ref(),
|
||||
);
|
||||
x.set_code(e.code());
|
||||
x.set_class(e.class());
|
||||
@@ -80,11 +72,7 @@ pub fn checkout_submodules(repo: &Repository) -> Result<(), Error> {
|
||||
match repo.submodules() {
|
||||
Ok(submodules) => {
|
||||
for mut submodule in submodules {
|
||||
info!(
|
||||
"getting submodule {:?} from {:?}",
|
||||
submodule.name(),
|
||||
submodule.url()
|
||||
);
|
||||
info!("getting submodule {:?} from {:?}", submodule.name(), submodule.url());
|
||||
|
||||
match submodule.update(true, None) {
|
||||
Err(e) => return Err(e),
|
||||
|
||||
174
src/models.rs
174
src/models.rs
@@ -56,14 +56,10 @@ impl Environment {
|
||||
let external_services = self
|
||||
.external_services
|
||||
.iter()
|
||||
.map(
|
||||
|x| match built_applications.iter().find(|y| x.id.as_str() == y.id()) {
|
||||
Some(app) => {
|
||||
x.to_stateless_service(context, app.image().clone(), cloud_provider)
|
||||
}
|
||||
_ => x.to_stateless_service(context, x.to_image(), cloud_provider),
|
||||
},
|
||||
)
|
||||
.map(|x| match built_applications.iter().find(|y| x.id.as_str() == y.id()) {
|
||||
Some(app) => x.to_stateless_service(context, app.image().clone(), cloud_provider),
|
||||
_ => x.to_stateless_service(context, x.to_image(), cloud_provider),
|
||||
})
|
||||
.filter(|x| x.is_some())
|
||||
.map(|x| x.unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
@@ -71,14 +67,10 @@ impl Environment {
|
||||
let applications = self
|
||||
.applications
|
||||
.iter()
|
||||
.map(
|
||||
|x| match built_applications.iter().find(|y| x.id.as_str() == y.id()) {
|
||||
Some(app) => {
|
||||
x.to_stateless_service(context, app.image().clone(), cloud_provider)
|
||||
}
|
||||
_ => x.to_stateless_service(context, x.to_image(), cloud_provider),
|
||||
},
|
||||
)
|
||||
.map(|x| match built_applications.iter().find(|y| x.id.as_str() == y.id()) {
|
||||
Some(app) => x.to_stateless_service(context, app.image().clone(), cloud_provider),
|
||||
_ => x.to_stateless_service(context, x.to_image(), cloud_provider),
|
||||
})
|
||||
.filter(|x| x.is_some())
|
||||
.map(|x| x.unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
@@ -187,27 +179,22 @@ impl Application {
|
||||
let listeners = cloud_provider.listeners().clone();
|
||||
|
||||
match cloud_provider.kind() {
|
||||
CPKind::Aws => Some(Box::new(
|
||||
crate::cloud_provider::aws::application::Application::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
self.name.as_str(),
|
||||
self.private_port,
|
||||
self.total_cpus.clone(),
|
||||
self.cpu_burst.clone(),
|
||||
self.total_ram_in_mib,
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image.clone(),
|
||||
self.storage
|
||||
.iter()
|
||||
.map(|s| s.to_aws_storage())
|
||||
.collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
),
|
||||
)),
|
||||
CPKind::Aws => Some(Box::new(crate::cloud_provider::aws::application::Application::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
self.name.as_str(),
|
||||
self.private_port,
|
||||
self.total_cpus.clone(),
|
||||
self.cpu_burst.clone(),
|
||||
self.total_ram_in_mib,
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image.clone(),
|
||||
self.storage.iter().map(|s| s.to_aws_storage()).collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
))),
|
||||
CPKind::Do => Some(Box::new(
|
||||
crate::cloud_provider::digitalocean::application::Application::new(
|
||||
context.clone(),
|
||||
@@ -221,10 +208,7 @@ impl Application {
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image.clone(),
|
||||
self.storage
|
||||
.iter()
|
||||
.map(|s| s.to_do_storage())
|
||||
.collect::<Vec<_>>(),
|
||||
self.storage.iter().map(|s| s.to_do_storage()).collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
),
|
||||
@@ -248,27 +232,22 @@ impl Application {
|
||||
let listeners = cloud_provider.listeners().clone();
|
||||
|
||||
match cloud_provider.kind() {
|
||||
CPKind::Aws => Some(Box::new(
|
||||
crate::cloud_provider::aws::application::Application::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
self.name.as_str(),
|
||||
self.private_port,
|
||||
self.total_cpus.clone(),
|
||||
self.cpu_burst.clone(),
|
||||
self.total_ram_in_mib,
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image,
|
||||
self.storage
|
||||
.iter()
|
||||
.map(|s| s.to_aws_storage())
|
||||
.collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
),
|
||||
)),
|
||||
CPKind::Aws => Some(Box::new(crate::cloud_provider::aws::application::Application::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
self.name.as_str(),
|
||||
self.private_port,
|
||||
self.total_cpus.clone(),
|
||||
self.cpu_burst.clone(),
|
||||
self.total_ram_in_mib,
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image,
|
||||
self.storage.iter().map(|s| s.to_aws_storage()).collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
))),
|
||||
CPKind::Do => Some(Box::new(
|
||||
crate::cloud_provider::digitalocean::application::Application::new(
|
||||
context.clone(),
|
||||
@@ -282,10 +261,7 @@ impl Application {
|
||||
self.total_instances,
|
||||
self.start_timeout_in_seconds,
|
||||
image,
|
||||
self.storage
|
||||
.iter()
|
||||
.map(|s| s.to_do_storage())
|
||||
.collect::<Vec<_>>(),
|
||||
self.storage.iter().map(|s| s.to_do_storage()).collect::<Vec<_>>(),
|
||||
environment_variables,
|
||||
listeners,
|
||||
),
|
||||
@@ -379,8 +355,7 @@ pub enum StorageType {
|
||||
impl Storage {
|
||||
pub fn to_aws_storage(
|
||||
&self,
|
||||
) -> crate::cloud_provider::models::Storage<crate::cloud_provider::aws::application::StorageType>
|
||||
{
|
||||
) -> crate::cloud_provider::models::Storage<crate::cloud_provider::aws::application::StorageType> {
|
||||
crate::cloud_provider::models::Storage {
|
||||
id: self.id.clone(),
|
||||
name: self.name.clone(),
|
||||
@@ -398,9 +373,7 @@ impl Storage {
|
||||
|
||||
pub fn to_do_storage(
|
||||
&self,
|
||||
) -> crate::cloud_provider::models::Storage<
|
||||
crate::cloud_provider::digitalocean::application::StorageType,
|
||||
> {
|
||||
) -> crate::cloud_provider::models::Storage<crate::cloud_provider::digitalocean::application::StorageType> {
|
||||
crate::cloud_provider::models::Storage {
|
||||
id: self.id.clone(),
|
||||
name: self.name.clone(),
|
||||
@@ -453,16 +426,15 @@ impl Router {
|
||||
|
||||
match cloud_provider.kind() {
|
||||
CPKind::Aws => {
|
||||
let router: Box<dyn StatelessService> =
|
||||
Box::new(crate::cloud_provider::aws::router::Router::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.name.as_str(),
|
||||
self.default_domain.as_str(),
|
||||
custom_domains,
|
||||
routes,
|
||||
listeners,
|
||||
));
|
||||
let router: Box<dyn StatelessService> = Box::new(crate::cloud_provider::aws::router::Router::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.name.as_str(),
|
||||
self.default_domain.as_str(),
|
||||
custom_domains,
|
||||
routes,
|
||||
listeners,
|
||||
));
|
||||
Some(router)
|
||||
}
|
||||
CPKind::Do => {
|
||||
@@ -627,8 +599,8 @@ impl Database {
|
||||
Some(db)
|
||||
}
|
||||
DatabaseKind::Redis => {
|
||||
let db: Box<dyn StatefulService> = Box::new(
|
||||
crate::cloud_provider::digitalocean::databases::redis::Redis::new(
|
||||
let db: Box<dyn StatefulService> =
|
||||
Box::new(crate::cloud_provider::digitalocean::databases::redis::Redis::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
@@ -641,14 +613,13 @@ impl Database {
|
||||
self.database_instance_type.as_str(),
|
||||
database_options,
|
||||
listeners,
|
||||
),
|
||||
);
|
||||
));
|
||||
|
||||
Some(db)
|
||||
}
|
||||
DatabaseKind::Mongodb => {
|
||||
let db: Box<dyn StatefulService> = Box::new(
|
||||
crate::cloud_provider::digitalocean::databases::mongodb::MongoDB::new(
|
||||
let db: Box<dyn StatefulService> =
|
||||
Box::new(crate::cloud_provider::digitalocean::databases::mongodb::MongoDB::new(
|
||||
context.clone(),
|
||||
self.id.as_str(),
|
||||
self.action.to_service_action(),
|
||||
@@ -661,8 +632,7 @@ impl Database {
|
||||
self.database_instance_type.as_str(),
|
||||
database_options,
|
||||
listeners,
|
||||
),
|
||||
);
|
||||
));
|
||||
|
||||
Some(db)
|
||||
}
|
||||
@@ -903,15 +873,11 @@ impl<'a> ListenersHelper<'a> {
|
||||
}
|
||||
|
||||
pub fn pause_in_progress(&self, info: ProgressInfo) {
|
||||
self.listeners
|
||||
.iter()
|
||||
.for_each(|l| l.pause_in_progress(info.clone()));
|
||||
self.listeners.iter().for_each(|l| l.pause_in_progress(info.clone()));
|
||||
}
|
||||
|
||||
pub fn delete_in_progress(&self, info: ProgressInfo) {
|
||||
self.listeners
|
||||
.iter()
|
||||
.for_each(|l| l.delete_in_progress(info.clone()));
|
||||
self.listeners.iter().for_each(|l| l.delete_in_progress(info.clone()));
|
||||
}
|
||||
|
||||
pub fn error(&self, info: ProgressInfo) {
|
||||
@@ -931,21 +897,15 @@ impl<'a> ListenersHelper<'a> {
|
||||
}
|
||||
|
||||
pub fn deployment_error(&self, info: ProgressInfo) {
|
||||
self.listeners
|
||||
.iter()
|
||||
.for_each(|l| l.deployment_error(info.clone()));
|
||||
self.listeners.iter().for_each(|l| l.deployment_error(info.clone()));
|
||||
}
|
||||
|
||||
pub fn pause_error(&self, info: ProgressInfo) {
|
||||
self.listeners
|
||||
.iter()
|
||||
.for_each(|l| l.pause_error(info.clone()));
|
||||
self.listeners.iter().for_each(|l| l.pause_error(info.clone()));
|
||||
}
|
||||
|
||||
pub fn delete_error(&self, info: ProgressInfo) {
|
||||
self.listeners
|
||||
.iter()
|
||||
.for_each(|l| l.delete_error(info.clone()));
|
||||
self.listeners.iter().for_each(|l| l.delete_error(info.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1056,11 +1016,7 @@ pub struct Metadata {
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
pub fn new(
|
||||
test: Option<bool>,
|
||||
dry_run_deploy: Option<bool>,
|
||||
resource_expiration_in_seconds: Option<u32>,
|
||||
) -> Self {
|
||||
pub fn new(test: Option<bool>, dry_run_deploy: Option<bool>, resource_expiration_in_seconds: Option<u32>) -> Self {
|
||||
Metadata {
|
||||
test,
|
||||
dry_run_deploy,
|
||||
|
||||
@@ -18,12 +18,7 @@ pub trait ObjectStorage {
|
||||
fn is_valid(&self) -> Result<(), EngineError>;
|
||||
fn create_bucket(&self, bucket_name: &str) -> Result<(), EngineError>;
|
||||
fn delete_bucket(&self, bucket_name: &str) -> Result<(), EngineError>;
|
||||
fn get(
|
||||
&self,
|
||||
bucket_name: &str,
|
||||
object_key: &str,
|
||||
use_cache: bool,
|
||||
) -> Result<(StringPath, File), EngineError>;
|
||||
fn get(&self, bucket_name: &str, object_key: &str, use_cache: bool) -> Result<(StringPath, File), EngineError>;
|
||||
fn put(&self, bucket_name: &str, object_key: &str, file_path: &str) -> Result<(), EngineError>;
|
||||
fn engine_error_scope(&self) -> EngineErrorScope {
|
||||
EngineErrorScope::ObjectStorage(self.id().to_string(), self.name().to_string())
|
||||
|
||||
@@ -17,13 +17,7 @@ pub struct S3 {
|
||||
}
|
||||
|
||||
impl S3 {
|
||||
pub fn new(
|
||||
context: Context,
|
||||
id: String,
|
||||
name: String,
|
||||
access_key_id: String,
|
||||
secret_access_key: String,
|
||||
) -> Self {
|
||||
pub fn new(context: Context, id: String, name: String, access_key_id: String, secret_access_key: String) -> Self {
|
||||
S3 {
|
||||
context,
|
||||
id,
|
||||
@@ -93,12 +87,7 @@ impl ObjectStorage for S3 {
|
||||
)
|
||||
}
|
||||
|
||||
fn get(
|
||||
&self,
|
||||
bucket_name: &str,
|
||||
object_key: &str,
|
||||
use_cache: bool,
|
||||
) -> Result<(StringPath, File), EngineError> {
|
||||
fn get(&self, bucket_name: &str, object_key: &str, use_cache: bool) -> Result<(StringPath, File), EngineError> {
|
||||
let workspace_directory = crate::fs::workspace_directory(
|
||||
self.context().workspace_root_dir(),
|
||||
self.context().execution_id(),
|
||||
|
||||
@@ -11,11 +11,7 @@ use walkdir::WalkDir;
|
||||
|
||||
use crate::error::{SimpleError, SimpleErrorKind};
|
||||
|
||||
pub fn generate_and_copy_all_files_into_dir<S, P>(
|
||||
from_dir: S,
|
||||
to_dir: P,
|
||||
context: &Context,
|
||||
) -> Result<(), SimpleError>
|
||||
pub fn generate_and_copy_all_files_into_dir<S, P>(from_dir: S, to_dir: P, context: &Context) -> Result<(), SimpleError>
|
||||
where
|
||||
S: AsRef<Path>,
|
||||
P: AsRef<Path>,
|
||||
@@ -28,10 +24,7 @@ where
|
||||
let error_msg = match e.kind {
|
||||
tera::ErrorKind::TemplateNotFound(x) => format!("template not found: {}", x),
|
||||
tera::ErrorKind::Msg(x) => format!("tera error: {}", x),
|
||||
tera::ErrorKind::CircularExtend {
|
||||
tpl,
|
||||
inheritance_chain,
|
||||
} => format!(
|
||||
tera::ErrorKind::CircularExtend { tpl, inheritance_chain } => format!(
|
||||
"circular extend - template: {}, inheritance chain: {:?}",
|
||||
tpl, inheritance_chain
|
||||
),
|
||||
@@ -77,10 +70,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_j2_template_files<P>(
|
||||
root_dir: P,
|
||||
context: &Context,
|
||||
) -> Result<Vec<RenderedTemplate>, TeraError>
|
||||
pub fn generate_j2_template_files<P>(root_dir: P, context: &Context) -> Result<Vec<RenderedTemplate>, TeraError>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
@@ -95,12 +85,7 @@ where
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
.filter(|e| {
|
||||
e.file_name()
|
||||
.to_str()
|
||||
.map(|s| s.contains(".j2."))
|
||||
.unwrap_or(false)
|
||||
})
|
||||
.filter(|e| e.file_name().to_str().map(|s| s.contains(".j2.")).unwrap_or(false))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut results: Vec<RenderedTemplate> = vec![];
|
||||
@@ -122,10 +107,7 @@ where
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
pub fn write_rendered_templates(
|
||||
rendered_templates: &[RenderedTemplate],
|
||||
into: &Path,
|
||||
) -> Result<(), SimpleError> {
|
||||
pub fn write_rendered_templates(rendered_templates: &[RenderedTemplate], into: &Path) -> Result<(), SimpleError> {
|
||||
for rt in rendered_templates {
|
||||
let dest = format!("{}/{}", into.to_str().unwrap(), rt.path_and_file_name());
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ use reqwest::header::{HeaderMap, HeaderValue};
|
||||
pub fn get_header_with_bearer(token: &str) -> HeaderMap<HeaderValue> {
|
||||
let mut headers = header::HeaderMap::new();
|
||||
headers.insert("Content-Type", "application/json".parse().unwrap());
|
||||
headers.insert(
|
||||
"Authorization",
|
||||
format!("Bearer {}", token).parse().unwrap(),
|
||||
);
|
||||
headers.insert("Authorization", format!("Bearer {}", token).parse().unwrap());
|
||||
headers
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ use qovery_engine::container_registry::ecr::ECR;
|
||||
use qovery_engine::dns_provider::DnsProvider;
|
||||
use qovery_engine::engine::Engine;
|
||||
use qovery_engine::models::{
|
||||
Action, Application, Context, Database, DatabaseKind, Environment, EnvironmentVariable,
|
||||
GitCredentials, Kind, Route, Router, Storage, StorageType,
|
||||
Action, Application, Context, Database, DatabaseKind, Environment, EnvironmentVariable, GitCredentials, Kind,
|
||||
Route, Router, Storage, StorageType,
|
||||
};
|
||||
|
||||
use crate::cloudflare::dns_provider_cloudflare;
|
||||
@@ -39,13 +39,11 @@ pub fn aws_default_region() -> String {
|
||||
}
|
||||
|
||||
pub fn terraform_aws_access_key_id() -> String {
|
||||
std::env::var("TERRAFORM_AWS_ACCESS_KEY_ID")
|
||||
.expect("env var TERRAFORM_AWS_ACCESS_KEY_ID is mandatory")
|
||||
std::env::var("TERRAFORM_AWS_ACCESS_KEY_ID").expect("env var TERRAFORM_AWS_ACCESS_KEY_ID is mandatory")
|
||||
}
|
||||
|
||||
pub fn terraform_aws_secret_access_key() -> String {
|
||||
std::env::var("TERRAFORM_AWS_SECRET_ACCESS_KEY")
|
||||
.expect("env var TERRAFORM_AWS_SECRET_ACCESS_KEY is mandatory")
|
||||
std::env::var("TERRAFORM_AWS_SECRET_ACCESS_KEY").expect("env var TERRAFORM_AWS_SECRET_ACCESS_KEY is mandatory")
|
||||
}
|
||||
|
||||
pub fn execution_id() -> String {
|
||||
@@ -156,8 +154,7 @@ pub fn environment_3_apps_3_routers_3_databases(context: &Context) -> Environmen
|
||||
let app_name_3 = format!("{}-{}", "simple-app-3".to_string(), generate_id());
|
||||
|
||||
// mongoDB management part
|
||||
let database_host_mongo =
|
||||
"mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_host_mongo = "mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port_mongo = 27017;
|
||||
let database_db_name_mongo = "my-mongodb".to_string();
|
||||
let database_username_mongo = "superuser".to_string();
|
||||
|
||||
@@ -5,8 +5,7 @@ use test_utilities::utilities::{init, is_pod_restarted_aws_env};
|
||||
use tracing::{span, Level};
|
||||
|
||||
use qovery_engine::models::{
|
||||
Action, Clone2, Context, Database, DatabaseKind, Environment, EnvironmentAction,
|
||||
EnvironmentVariable, Kind,
|
||||
Action, Clone2, Context, Database, DatabaseKind, Environment, EnvironmentAction, EnvironmentVariable, Kind,
|
||||
};
|
||||
use qovery_engine::transaction::TransactionResult;
|
||||
|
||||
@@ -26,10 +25,7 @@ use self::test_utilities::utilities::{engine_run_test, generate_id};
|
||||
fn deploy_an_environment_with_3_databases_and_3_apps() {
|
||||
init();
|
||||
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_an_environment_with_3_databases_and_3_apps"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_an_environment_with_3_databases_and_3_apps");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -88,16 +84,14 @@ fn postgresql_failover_dev_environment_with_all_options() {
|
||||
app
|
||||
})
|
||||
.collect::<Vec<qovery_engine::models::Application>>();
|
||||
let mut environment_delete =
|
||||
test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
let mut environment_delete = test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
|
||||
environment.kind = Kind::Development;
|
||||
environment_delete.kind = Kind::Development;
|
||||
environment_delete.action = Action::Delete;
|
||||
|
||||
let ea = EnvironmentAction::Environment(environment.clone());
|
||||
let ea_fail_ok =
|
||||
EnvironmentAction::EnvironmentWithFailover(environment_never_up, environment.clone());
|
||||
let ea_fail_ok = EnvironmentAction::EnvironmentWithFailover(environment_never_up, environment.clone());
|
||||
let ea_for_deletion = EnvironmentAction::Environment(environment_delete);
|
||||
|
||||
match deploy_environment(&context, &ea) {
|
||||
@@ -146,8 +140,7 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
|
||||
let mut environment = test_utilities::aws::environnement_2_app_2_routers_1_psql(&context);
|
||||
//let env_to_check = environment.clone();
|
||||
let mut environment_delete =
|
||||
test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
let mut environment_delete = test_utilities::aws::environnement_2_app_2_routers_1_psql(&context_for_deletion);
|
||||
|
||||
environment.kind = Kind::Development;
|
||||
environment_delete.kind = Kind::Development;
|
||||
@@ -179,10 +172,7 @@ fn postgresql_deploy_a_working_development_environment_with_all_options() {
|
||||
#[test]
|
||||
fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"postgresql_deploy_a_working_environment_and_redeploy"
|
||||
);
|
||||
let span = span!(Level::INFO, "postgresql_deploy_a_working_environment_and_redeploy");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -191,8 +181,7 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
|
||||
let database_host =
|
||||
"postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_host = "postgresql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 5432;
|
||||
let database_db_name = "my-postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
@@ -288,19 +277,13 @@ fn postgresql_deploy_a_working_environment_and_redeploy() {
|
||||
**
|
||||
**/
|
||||
|
||||
fn test_postgresql_configuration(
|
||||
context: Context,
|
||||
mut environment: Environment,
|
||||
version: &str,
|
||||
test_name: &str,
|
||||
) {
|
||||
fn test_postgresql_configuration(context: Context, mut environment: Environment, version: &str, test_name: &str) {
|
||||
engine_run_test(|| {
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"postgres-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; //
|
||||
let database_host = "postgres-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; //
|
||||
let database_port = 5432;
|
||||
let database_db_name = "postgres".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
@@ -473,20 +456,14 @@ fn postgresql_v12_deploy_a_working_prod_environment() {
|
||||
**
|
||||
**/
|
||||
|
||||
fn test_mongodb_configuration(
|
||||
context: Context,
|
||||
mut environment: Environment,
|
||||
version: &str,
|
||||
test_name: &str,
|
||||
) {
|
||||
fn test_mongodb_configuration(context: Context, mut environment: Environment, version: &str, test_name: &str) {
|
||||
init();
|
||||
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_host = "mongodb-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 27017;
|
||||
let database_db_name = "my-mongodb".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
@@ -675,20 +652,14 @@ fn mongodb_v4_0_deploy_a_working_prod_environment() {
|
||||
**
|
||||
**/
|
||||
|
||||
fn test_mysql_configuration(
|
||||
context: Context,
|
||||
mut environment: Environment,
|
||||
version: &str,
|
||||
test_name: &str,
|
||||
) {
|
||||
fn test_mysql_configuration(context: Context, mut environment: Environment, version: &str, test_name: &str) {
|
||||
engine_run_test(|| {
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
|
||||
let deletion_context = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"mysql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_host = "mysql-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 3306;
|
||||
let database_db_name = "mysqldatabase".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
@@ -799,12 +770,7 @@ fn mysql_v5_7_deploy_a_working_dev_environment() {
|
||||
fn mysql_v8_deploy_a_working_dev_environment() {
|
||||
let context = context();
|
||||
let environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_mysql_configuration(
|
||||
context,
|
||||
environment,
|
||||
"8.0",
|
||||
"mysql_v8_deploy_a_working_dev_environment",
|
||||
);
|
||||
test_mysql_configuration(context, environment, "8.0", "mysql_v8_deploy_a_working_dev_environment");
|
||||
}
|
||||
|
||||
// MySQL production environment (RDS)
|
||||
@@ -842,20 +808,14 @@ fn mysql_v8_0_deploy_a_working_prod_environment() {
|
||||
**
|
||||
**/
|
||||
|
||||
fn test_redis_configuration(
|
||||
context: Context,
|
||||
mut environment: Environment,
|
||||
version: &str,
|
||||
test_name: &str,
|
||||
) {
|
||||
fn test_redis_configuration(context: Context, mut environment: Environment, version: &str, test_name: &str) {
|
||||
engine_run_test(|| {
|
||||
let span = span!(Level::INFO, "test", name = test_name);
|
||||
let _enter = span.enter();
|
||||
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
|
||||
let database_host =
|
||||
"redis-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_host = "redis-".to_string() + generate_id().as_str() + ".CHANGE-ME/DEFAULT_TEST_DOMAIN"; // External access check
|
||||
let database_port = 6379;
|
||||
let database_db_name = "my-redis".to_string();
|
||||
let database_username = "superuser".to_string();
|
||||
@@ -955,12 +915,7 @@ fn test_redis_configuration(
|
||||
fn redis_v5_deploy_a_working_dev_environment() {
|
||||
let context = context();
|
||||
let environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_redis_configuration(
|
||||
context,
|
||||
environment,
|
||||
"5",
|
||||
"redis_v5_deploy_a_working_dev_environment",
|
||||
);
|
||||
test_redis_configuration(context, environment, "5", "redis_v5_deploy_a_working_dev_environment");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -968,12 +923,7 @@ fn redis_v6_deploy_a_working_dev_environment() {
|
||||
let context = context();
|
||||
const TEST_NAME: &str = "redis_v6_0_dev";
|
||||
let environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
test_redis_configuration(
|
||||
context,
|
||||
environment,
|
||||
"6",
|
||||
"redis_v6_deploy_a_working_dev_environment",
|
||||
);
|
||||
test_redis_configuration(context, environment, "6", "redis_v6_deploy_a_working_dev_environment");
|
||||
}
|
||||
|
||||
// Redis production environment (Elasticache)
|
||||
@@ -983,12 +933,7 @@ fn redis_v5_deploy_a_working_prod_environment() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
test_redis_configuration(
|
||||
context,
|
||||
environment,
|
||||
"5",
|
||||
"redis_v5_deploy_a_working_prod_environment",
|
||||
);
|
||||
test_redis_configuration(context, environment, "5", "redis_v5_deploy_a_working_prod_environment");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -997,10 +942,5 @@ fn redis_v6_deploy_a_working_prod_environment() {
|
||||
let context = context();
|
||||
let mut environment = test_utilities::aws::working_minimal_environment(&context);
|
||||
environment.kind = Kind::Production;
|
||||
test_redis_configuration(
|
||||
context,
|
||||
environment,
|
||||
"6",
|
||||
"redis_v6_deploy_a_working_prod_environment",
|
||||
);
|
||||
test_redis_configuration(context, environment, "6", "redis_v6_deploy_a_working_prod_environment");
|
||||
}
|
||||
|
||||
@@ -29,10 +29,7 @@ pub fn generate_contexts_and_environments(
|
||||
(context_vec, env_vec)
|
||||
}
|
||||
|
||||
pub fn deploy_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
pub fn deploy_environment(context: &Context, environment_action: &EnvironmentAction) -> TransactionResult {
|
||||
let engine = test_utilities::aws::docker_ecr_aws_engine(&context);
|
||||
let session = engine.session().unwrap();
|
||||
let mut tx = session.transaction();
|
||||
@@ -72,10 +69,7 @@ pub fn deploy_environment(
|
||||
// tx.commit()
|
||||
// }
|
||||
|
||||
pub fn delete_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
pub fn delete_environment(context: &Context, environment_action: &EnvironmentAction) -> TransactionResult {
|
||||
let engine = test_utilities::aws::docker_ecr_aws_engine(&context);
|
||||
let session = engine.session().unwrap();
|
||||
let mut tx = session.transaction();
|
||||
@@ -93,10 +87,7 @@ pub fn delete_environment(
|
||||
#[test]
|
||||
fn deploy_a_working_environment_with_no_router_on_aws_eks() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_with_no_router_on_aws_eks"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_with_no_router_on_aws_eks");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -166,10 +157,7 @@ fn deploy_a_not_working_environment_with_no_router_on_aws_eks() {
|
||||
#[test]
|
||||
fn build_with_buildpacks_and_deploy_a_working_environment() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"build_with_buildpacks_and_deploy_a_working_environment"
|
||||
);
|
||||
let span = span!(Level::INFO, "build_with_buildpacks_and_deploy_a_working_environment");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -242,10 +230,7 @@ fn deploy_a_working_environment_with_domain() {
|
||||
|
||||
fn deploy_a_working_environment_with_custom_domain() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_with_custom_domain"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_with_custom_domain");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -294,10 +279,7 @@ fn deploy_a_working_environment_with_custom_domain() {
|
||||
#[ignore]
|
||||
fn deploy_a_working_environment_with_storage_on_aws_eks() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_with_storage_on_aws_eks"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_with_storage_on_aws_eks");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
|
||||
@@ -71,9 +71,8 @@ fn create_and_destroy_eks_cluster_in_eu_west_3() {
|
||||
let mut read_buf = String::new();
|
||||
file.read_to_string(&mut read_buf).unwrap();
|
||||
|
||||
let options_result = serde_json::from_str::<
|
||||
qovery_engine::cloud_provider::aws::kubernetes::Options,
|
||||
>(read_buf.as_str());
|
||||
let options_result =
|
||||
serde_json::from_str::<qovery_engine::cloud_provider::aws::kubernetes::Options>(read_buf.as_str());
|
||||
|
||||
let region = "eu-west-3";
|
||||
let kubernetes = EKS::new(
|
||||
@@ -129,9 +128,8 @@ fn create_eks_cluster_in_us_east_2() {
|
||||
let mut read_buf = String::new();
|
||||
file.read_to_string(&mut read_buf).unwrap();
|
||||
|
||||
let options_result = serde_json::from_str::<
|
||||
qovery_engine::cloud_provider::aws::kubernetes::Options,
|
||||
>(read_buf.as_str());
|
||||
let options_result =
|
||||
serde_json::from_str::<qovery_engine::cloud_provider::aws::kubernetes::Options>(read_buf.as_str());
|
||||
|
||||
let region = "us-east-2";
|
||||
let kubernetes = EKS::new(
|
||||
@@ -177,9 +175,8 @@ fn delete_eks_cluster_in_us_east_2() {
|
||||
let mut read_buf = String::new();
|
||||
file.read_to_string(&mut read_buf).unwrap();
|
||||
|
||||
let options_result = serde_json::from_str::<
|
||||
qovery_engine::cloud_provider::aws::kubernetes::Options,
|
||||
>(read_buf.as_str());
|
||||
let options_result =
|
||||
serde_json::from_str::<qovery_engine::cloud_provider::aws::kubernetes::Options>(read_buf.as_str());
|
||||
|
||||
let region = "us-east-2";
|
||||
let kubernetes = EKS::new(
|
||||
@@ -225,9 +222,8 @@ fn delete_eks_cluster_in_eu_west_3() {
|
||||
let mut read_buf = String::new();
|
||||
file.read_to_string(&mut read_buf).unwrap();
|
||||
|
||||
let options_result = serde_json::from_str::<
|
||||
qovery_engine::cloud_provider::aws::kubernetes::Options,
|
||||
>(read_buf.as_str());
|
||||
let options_result =
|
||||
serde_json::from_str::<qovery_engine::cloud_provider::aws::kubernetes::Options>(read_buf.as_str());
|
||||
|
||||
let region = "eu-west-3";
|
||||
let kubernetes = EKS::new(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use test_utilities::utilities::{context, init, engine_run_test};
|
||||
use test_utilities::utilities::{context, engine_run_test, init};
|
||||
use tracing::{span, Level};
|
||||
|
||||
use qovery_engine::models::{Action, Clone2, EnvironmentAction};
|
||||
@@ -9,7 +9,6 @@ use crate::digitalocean::deploy_environment_on_do;
|
||||
//TODO: Do you wanna play a game ?
|
||||
fn deploy_one_postgresql() {
|
||||
engine_run_test(|| {
|
||||
|
||||
let span = span!(Level::INFO, "deploy_one_postgresql");
|
||||
let _enter = span.enter();
|
||||
|
||||
|
||||
@@ -10,10 +10,7 @@ use test_utilities::digitalocean::digital_ocean_token;
|
||||
use test_utilities::utilities::{context, engine_run_test, init};
|
||||
use tracing::{span, Level};
|
||||
|
||||
pub fn deploy_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
pub fn deploy_environment(context: &Context, environment_action: &EnvironmentAction) -> TransactionResult {
|
||||
let engine = test_utilities::digitalocean::docker_cr_do_engine(&context);
|
||||
let session = engine.session().unwrap();
|
||||
let mut tx = session.transaction();
|
||||
@@ -35,10 +32,7 @@ pub fn deploy_environment(
|
||||
tx.commit()
|
||||
}
|
||||
|
||||
pub fn delete_environment(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
pub fn delete_environment(context: &Context, environment_action: &EnvironmentAction) -> TransactionResult {
|
||||
let engine = test_utilities::digitalocean::docker_cr_do_engine(&context);
|
||||
let session = engine.session().unwrap();
|
||||
let mut tx = session.transaction();
|
||||
@@ -57,17 +51,13 @@ pub fn delete_environment(
|
||||
//#[test]
|
||||
fn deploy_a_working_environment_with_no_router_on_do() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_with_no_router_on_do"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_with_no_router_on_do");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
let context_for_delete = context.clone_not_same_execution_id();
|
||||
let mut environment = test_utilities::aws::environment_only_http_server(&context);
|
||||
let mut environment_for_delete =
|
||||
test_utilities::aws::environment_only_http_server(&context);
|
||||
let mut environment_for_delete = test_utilities::aws::environment_only_http_server(&context);
|
||||
environment.routers = vec![];
|
||||
environment_for_delete.routers = vec![];
|
||||
environment_for_delete.action = Action::Delete;
|
||||
@@ -118,10 +108,7 @@ fn deploy_a_working_environment_with_no_router_on_do() {
|
||||
//#[test]
|
||||
fn do_deploy_a_working_environment_with_custom_domain() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_with_custom_domain"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_with_custom_domain");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
@@ -169,10 +156,7 @@ fn do_deploy_a_working_environment_with_custom_domain() {
|
||||
//#[test]
|
||||
fn deploy_a_working_environment_router_and_app_on_do() {
|
||||
engine_run_test(|| {
|
||||
let span = span!(
|
||||
Level::INFO,
|
||||
"deploy_a_working_environment_router_and_app_on_do"
|
||||
);
|
||||
let span = span!(Level::INFO, "deploy_a_working_environment_router_and_app_on_do");
|
||||
let _enter = span.enter();
|
||||
|
||||
let context = context();
|
||||
|
||||
@@ -43,9 +43,8 @@ fn create_doks_cluster_in_fra_10() {
|
||||
let mut read_buf = String::new();
|
||||
file.read_to_string(&mut read_buf).unwrap();
|
||||
|
||||
let options_result = serde_json::from_str::<
|
||||
qovery_engine::cloud_provider::digitalocean::kubernetes::Options,
|
||||
>(read_buf.as_str());
|
||||
let options_result =
|
||||
serde_json::from_str::<qovery_engine::cloud_provider::digitalocean::kubernetes::Options>(read_buf.as_str());
|
||||
|
||||
let kubernetes = DOKS::new(
|
||||
context.clone(),
|
||||
@@ -65,13 +64,9 @@ fn create_doks_cluster_in_fra_10() {
|
||||
tx.commit();
|
||||
|
||||
// TESTING: Kube cluster UUID is OK ?
|
||||
let res_uuid =
|
||||
get_uuid_of_cluster_from_name(digital_ocean_token().as_str(), cluster_name.clone());
|
||||
let res_uuid = get_uuid_of_cluster_from_name(digital_ocean_token().as_str(), cluster_name.clone());
|
||||
match res_uuid {
|
||||
Ok(uuid) => assert_eq!(
|
||||
get_kube_cluster_name_from_uuid(uuid.as_str()),
|
||||
cluster_name.clone()
|
||||
),
|
||||
Ok(uuid) => assert_eq!(get_kube_cluster_name_from_uuid(uuid.as_str()), cluster_name.clone()),
|
||||
Err(e) => {
|
||||
error!("{:?}", e.message);
|
||||
assert!(false);
|
||||
|
||||
@@ -6,10 +6,7 @@ mod do_databases;
|
||||
mod do_environment;
|
||||
pub mod do_kubernetes;
|
||||
|
||||
pub fn deploy_environment_on_do(
|
||||
context: &Context,
|
||||
environment_action: &EnvironmentAction,
|
||||
) -> TransactionResult {
|
||||
pub fn deploy_environment_on_do(context: &Context, environment_action: &EnvironmentAction) -> TransactionResult {
|
||||
let engine = test_utilities::digitalocean::docker_cr_do_engine(&context);
|
||||
let session = engine.session().unwrap();
|
||||
let mut tx = session.transaction();
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use trust_dns_resolver::proto::rr::{RecordType, RData};
|
||||
use trust_dns_resolver::proto::rr::{RData, RecordType};
|
||||
|
||||
#[test]
|
||||
fn test_bad_add() {
|
||||
use std::net::*;
|
||||
use trust_dns_resolver::Resolver;
|
||||
use trust_dns_resolver::config::*;
|
||||
use trust_dns_resolver::Resolver;
|
||||
|
||||
// Construct a new Resolver with default configuration options
|
||||
// Construct a new Resolver with default configuration options
|
||||
let resolver = Resolver::new(ResolverConfig::default(), ResolverOpts::default()).unwrap();
|
||||
let ret = resolver.lookup("www.fillbit.io.", RecordType::CNAME).unwrap();
|
||||
|
||||
@@ -15,6 +15,5 @@ fn test_bad_add() {
|
||||
RData::CNAME(name) => eprintln!("{:?}", name.to_utf8()),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
mod aws;
|
||||
mod unit;
|
||||
mod digitalocean;
|
||||
mod unit;
|
||||
|
||||
Reference in New Issue
Block a user