Skip to content
Permalink
Browse files

Make project layout more idiomatic: moved infrastructure components t…

…o own

module and start to rename *_service mods to more “rustic” locations.
  • Loading branch information...
schrieveslaach committed May 24, 2019
1 parent cbc7127 commit ddc4d4ed5641d50a84b038063a1a93cc8a35c0f0

Some generated files are not rendered by default. Learn more.

File renamed without changes.
@@ -24,9 +24,9 @@
* =========================LICENSE_END==================================
*/

use crate::config::ContainerConfig;
use crate::infrastructure::Infrastructure;
use crate::models::service::{ContainerType, Image, Service, ServiceConfig, ServiceError};
use crate::services::config_service::ContainerConfig;
use crate::services::infrastructure::Infrastructure;
use failure::Error;
use futures::future::join_all;
use futures::{Future, Stream};
@@ -24,10 +24,10 @@
* =========================LICENSE_END==================================
*/

use crate::config::ContainerConfig;
use crate::infrastructure::Infrastructure;
use crate::models::service::Service;
use crate::models::service::ServiceConfig;
use crate::services::config_service::ContainerConfig;
use crate::services::infrastructure::Infrastructure;
use multimap::MultiMap;
use std::collections::HashSet;
use std::sync::Mutex;
@@ -24,7 +24,7 @@
* =========================LICENSE_END==================================
*/

use super::config_service::ContainerConfig;
use crate::config::ContainerConfig;
use crate::models::service::{Service, ServiceConfig};
use failure::Error;
use multimap::MultiMap;
@@ -0,0 +1,35 @@
/*-
* ========================LICENSE_START=================================
* PREvant REST API
* %%
* Copyright (C) 2018 - 2019 aixigo AG
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* =========================LICENSE_END==================================
*/

pub use docker::DockerInfrastructure as Docker;
#[cfg(test)]
pub use dummy_infrastructure::DummyInfrastructure as Dummy;
pub use infrastructure::Infrastructure;

mod docker;
#[cfg(test)]
mod dummy_infrastructure;
mod infrastructure;
@@ -39,10 +39,10 @@ extern crate rocket;
#[macro_use]
extern crate serde_derive;

use crate::config::Config;
use crate::infrastructure::Docker;
use crate::models::request_info::RequestInfo;
use crate::services::apps_service::AppsService;
use crate::services::config_service::Config;
use crate::services::docker::DockerInfrastructure;
use clap::{App, Arg};
use env_logger::Env;
use rocket::response::NamedFile;
@@ -53,6 +53,8 @@ use std::path::{Path, PathBuf};
use std::process;

mod apps;
mod config;
mod infrastructure;
mod models;
mod services;
mod tickets;
@@ -117,8 +119,7 @@ fn main() {
}
};

let apps_service = match AppsService::new(config.clone(), Box::new(DockerInfrastructure::new()))
{
let apps_service = match AppsService::new(config.clone(), Box::new(Docker::new())) {
Ok(apps_service) => apps_service,
Err(e) => {
error!("Cannot create apps service: {}", e);
@@ -24,17 +24,15 @@
* =========================LICENSE_END==================================
*/

use crate::config::{Config, ConfigError};
use crate::infrastructure::Infrastructure;
use crate::models::request_info::RequestInfo;
use crate::models::service::{ContainerType, Service, ServiceConfig};
use crate::models::web_host_meta::WebHostMeta;
use crate::services::config_service::{Config, ConfigError};
use crate::services::images_service::{ImagesService, ImagesServiceError};
use crate::services::service_templating::{
apply_templating_for_application_companion, apply_templating_for_service_companion,
};
use crate::services::{
images_service::{ImagesService, ImagesServiceError},
infrastructure::Infrastructure,
};
use cached::SizedCache;
use handlebars::TemplateRenderError;
use http_api_problem::{HttpApiProblem, StatusCode};
@@ -394,8 +392,8 @@ impl From<ImagesServiceError> for AppsServiceError {
mod tests {

use super::*;
use crate::infrastructure::Dummy;
use crate::models::service::Image;
use crate::services::dummy_infrastructure::DummyInfrastructure;
use sha2::{Digest, Sha256};
use std::str::FromStr;
use url::Url;
@@ -444,7 +442,7 @@ mod tests {
#[test]
fn should_create_app_for_master() -> Result<(), AppsServiceError> {
let config = Config::default();
let infrastructure = Box::new(DummyInfrastructure::new());
let infrastructure = Box::new(Dummy::new());
let apps = AppsService::new(config, infrastructure)?;

apps.create_or_update(
@@ -467,7 +465,7 @@ mod tests {
#[test]
fn should_replication_from_master() -> Result<(), AppsServiceError> {
let config = Config::default();
let infrastructure = Box::new(DummyInfrastructure::new());
let infrastructure = Box::new(Dummy::new());
let apps = AppsService::new(config, infrastructure)?;

apps.create_or_update(
@@ -496,7 +494,7 @@ mod tests {
#[test]
fn should_override_replicas_from_master() -> Result<(), AppsServiceError> {
let config = Config::default();
let infrastructure = Box::new(DummyInfrastructure::new());
let infrastructure = Box::new(Dummy::new());
let apps = AppsService::new(config, infrastructure)?;

apps.create_or_update(
@@ -540,7 +538,7 @@ mod tests {
"#
);

let infrastructure = Box::new(DummyInfrastructure::new());
let infrastructure = Box::new(Dummy::new());
let apps = AppsService::new(config, infrastructure)?;

apps.create_or_update(&String::from("master"), None, &service_configs!("mariadb"))?;
@@ -569,7 +567,7 @@ mod tests {
"#
);

let infrastructure = Box::new(DummyInfrastructure::new());
let infrastructure = Box::new(Dummy::new());
let apps = AppsService::new(config, infrastructure)?;

apps.create_or_update(
@@ -25,10 +25,5 @@
*/

pub mod apps_service;
pub mod config_service;
pub mod docker;
#[cfg(test)]
pub mod dummy_infrastructure;
pub mod images_service;
pub mod infrastructure;
pub mod service_templating;
@@ -24,10 +24,10 @@
* =========================LICENSE_END==================================
*/

use crate::config::Config;
use crate::models::request_info::RequestInfo;
use crate::models::ticket_info::TicketInfo;
use crate::services::apps_service::{AppsService, AppsServiceError};
use crate::services::config_service::Config;
use goji::Error as GojiError;
use goji::{Credentials, Jira, SearchOptions};
use http_api_problem::{HttpApiProblem, StatusCode};

0 comments on commit ddc4d4e

Please sign in to comment.
You can’t perform that action at this time.