diff --git a/api/res/openapi.yml b/api/res/openapi.yml index 7489333..5044446 100644 --- a/api/res/openapi.yml +++ b/api/res/openapi.yml @@ -194,22 +194,12 @@ components: type: string description: Name of the service to start example: mariadb - registry: + image: type: string - description: Hostname of the docker registry, containing the image of the service - example: docker.io - imageUser: - type: string - description: cf. `hub-user` from command `docker push /:` ([push docker images](https://docs.docker.com/docker-hub/repos/#pushing-a-repository-image-to-docker-hub)) - example: library - imageRepository: - type: string - description: cf. `repo-name` from command `docker push /:` ([push docker images](https://docs.docker.com/docker-hub/repos/#pushing-a-repository-image-to-docker-hub)) - example: mariadb - imageTag: - type: string - description: cf. `tag` from command `docker push /:` ([push docker images](https://docs.docker.com/docker-hub/repos/#pushing-a-repository-image-to-docker-hub)) - example: 10.3 + description: >- + The docker image with `//:`. ``, `` and `` + are optional values. + example: mariadb:10.3 env: type: array items: diff --git a/api/src/models/service.rs b/api/src/models/service.rs index 48279e0..178098b 100644 --- a/api/src/models/service.rs +++ b/api/src/models/service.rs @@ -26,6 +26,7 @@ use regex::Regex; use serde::ser::{Serialize, Serializer}; +use serde::{de, Deserialize, Deserializer}; use std::collections::BTreeMap; use std::str::FromStr; use url::Url; @@ -43,10 +44,8 @@ pub struct Service { #[serde(rename_all = "camelCase")] pub struct ServiceConfig { service_name: String, - image_repository: String, - registry: Option, - image_user: Option, - image_tag: Option, + #[serde(deserialize_with = "Image::parse_from_string")] + image: Image, env: Option>, volumes: Option>, #[serde(skip)] @@ -57,6 +56,7 @@ pub struct ServiceConfig { port: u16, } +#[derive(Clone, Deserialize, Eq, Hash, PartialEq)] pub enum Image { Named { image_repository: String, @@ -70,28 +70,10 @@ pub enum Image { } impl ServiceConfig { - pub fn new(service_name: String, image: &Image) -> ServiceConfig { - let (image_repository, registry, image_user, image_tag) = match image { - Image::Digest { hash } => (hash.clone(), None, None, None), - Image::Named { - image_repository, - registry, - image_user, - image_tag, - } => ( - image_repository.clone(), - registry.clone(), - image_user.clone(), - image_tag.clone(), - ), - }; - + pub fn new(service_name: String, image: Image) -> ServiceConfig { ServiceConfig { service_name, - image_repository, - registry, - image_user, - image_tag, + image, env: None, volumes: None, labels: None, @@ -104,39 +86,20 @@ impl ServiceConfig { self.container_type = container_type; } - pub fn get_container_type(&self) -> &ContainerType { + pub fn container_type(&self) -> &ContainerType { &self.container_type } - fn refers_to_image_id(&self) -> bool { - let regex = Regex::new(r"^(sha256:)?(?P[a-fA-F0-9]+)$").unwrap(); - regex - .captures(&self.image_repository) - .map(|_| true) - .unwrap_or_else(|| false) - } - /// Returns a fully qualifying docker image - pub fn get_image(&self) -> Image { - if self.refers_to_image_id() { - return Image::Digest { - hash: self.image_repository.clone(), - }; - } - - Image::Named { - image_repository: self.image_repository.clone(), - registry: self.registry.clone(), - image_user: self.image_user.clone(), - image_tag: self.image_tag.clone(), - } + pub fn image(&self) -> &Image { + &self.image } pub fn set_service_name(&mut self, service_name: &String) { self.service_name = service_name.clone() } - pub fn get_service_name(&self) -> &String { + pub fn service_name(&self) -> &String { &self.service_name } @@ -144,7 +107,7 @@ impl ServiceConfig { self.env = env; } - pub fn get_env<'a, 'b: 'a>(&'b self) -> Option<&'a Vec> { + pub fn env<'a, 'b: 'a>(&'b self) -> Option<&'a Vec> { match &self.env { None => None, Some(env) => Some(&env), @@ -155,7 +118,7 @@ impl ServiceConfig { self.labels = labels; } - pub fn get_labels<'a, 'b: 'a>(&'b self) -> Option<&'a BTreeMap> { + pub fn labels<'a, 'b: 'a>(&'b self) -> Option<&'a BTreeMap> { match &self.labels { None => None, Some(labels) => Some(&labels), @@ -166,7 +129,7 @@ impl ServiceConfig { self.volumes = volumes; } - pub fn get_volumes<'a, 'b: 'a>(&'b self) -> Option<&'a BTreeMap> { + pub fn volumes<'a, 'b: 'a>(&'b self) -> Option<&'a BTreeMap> { match &self.volumes { None => None, Some(volumes) => Some(&volumes), @@ -177,7 +140,7 @@ impl ServiceConfig { self.port = port; } - pub fn get_port(&self) -> u16 { + pub fn port(&self) -> u16 { self.port } } @@ -210,22 +173,22 @@ impl Service { self.container_type = container_type; } - fn get_service_url(&self) -> Option { + fn service_url(&self) -> Option { self.base_url.clone().map(|url| { url.join(&format!("/{}/{}/", &self.app_name, &self.service_name)) .unwrap() }) } - pub fn get_service_name(&self) -> &String { + pub fn service_name(&self) -> &String { &self.service_name } - pub fn get_container_id(&self) -> &String { + pub fn container_id(&self) -> &String { &self.container_id } - pub fn get_container_type(&self) -> &ContainerType { + pub fn container_type(&self) -> &ContainerType { &self.container_type } } @@ -247,7 +210,7 @@ impl Serialize for Service { let version_url = match self.container_type { ContainerType::Instance | ContainerType::Replica => self - .get_service_url() + .service_url() // TODO: use Web Host Metadata (RFC 6415): .well-known/host-meta.json .map(|url| url.join("version").unwrap()) .map(|url| url.to_string()), @@ -256,7 +219,7 @@ impl Serialize for Service { let s = Service { name: &self.service_name, - url: self.get_service_url().map(|url| url.to_string()), + url: self.service_url().map(|url| url.to_string()), service_type: self.container_type.to_string(), version_url, }; @@ -324,7 +287,15 @@ pub enum ServiceError { } impl Image { - pub fn get_tag(&self) -> Option { + fn parse_from_string<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let img = String::deserialize(deserializer)?; + Image::from_str(&img).map_err(de::Error::custom) + } + + pub fn tag(&self) -> Option { match &self { Image::Digest { .. } => None, Image::Named { @@ -339,7 +310,7 @@ impl Image { } } - pub fn get_name(&self) -> Option { + pub fn name(&self) -> Option { match &self { Image::Digest { .. } => None, Image::Named { @@ -358,7 +329,7 @@ impl Image { } } - pub fn get_registry(&self) -> Option { + pub fn registry(&self) -> Option { match &self { Image::Digest { .. } => None, Image::Named { @@ -460,8 +431,8 @@ mod tests { &image.to_string(), "sha256:9895c9b90b58c9490471b877f6bb6a90e6bdc154da7fbb526a0322ea242fc913" ); - assert_eq!(image.get_name(), None); - assert_eq!(image.get_tag(), None); + assert_eq!(image.name(), None); + assert_eq!(image.tag(), None); } #[test] @@ -469,24 +440,24 @@ mod tests { let image = Image::from_str("9895c9b90b58").unwrap(); assert_eq!(&image.to_string(), "9895c9b90b58"); - assert_eq!(image.get_name(), None); - assert_eq!(image.get_tag(), None); + assert_eq!(image.name(), None); + assert_eq!(image.tag(), None); } #[test] fn should_parse_image_with_repo_and_user() { let image = Image::from_str("zammad/zammad-docker-compose").unwrap(); - assert_eq!(&image.get_name().unwrap(), "zammad/zammad-docker-compose"); - assert_eq!(&image.get_tag().unwrap(), "latest"); + assert_eq!(&image.name().unwrap(), "zammad/zammad-docker-compose"); + assert_eq!(&image.tag().unwrap(), "latest"); } #[test] fn should_parse_image_with_version() { let image = Image::from_str("mariadb:10.3").unwrap(); - assert_eq!(&image.get_name().unwrap(), "library/mariadb"); - assert_eq!(&image.get_tag().unwrap(), "10.3"); + assert_eq!(&image.name().unwrap(), "library/mariadb"); + assert_eq!(&image.tag().unwrap(), "10.3"); assert_eq!(&image.to_string(), "docker.io/library/mariadb:10.3"); } @@ -494,8 +465,8 @@ mod tests { fn should_parse_image_with_latest_version() { let image = Image::from_str("nginx:latest").unwrap(); - assert_eq!(&image.get_name().unwrap(), "library/nginx"); - assert_eq!(&image.get_tag().unwrap(), "latest"); + assert_eq!(&image.name().unwrap(), "library/nginx"); + assert_eq!(&image.tag().unwrap(), "latest"); assert_eq!(&image.to_string(), "docker.io/library/nginx:latest"); } @@ -511,6 +482,30 @@ mod tests { let image = Image::from_str("localhost:5000/library/nginx:latest").unwrap(); assert_eq!(&image.to_string(), "localhost:5000/library/nginx:latest"); - assert_eq!(&image.get_registry().unwrap(), "localhost:5000"); + assert_eq!(&image.registry().unwrap(), "localhost:5000"); + } + + #[test] + fn should_parse_service_config_json() { + let json = r#"{ + "serviceName": "mariadb", + "image": "mariadb:10.3", + "env": [ + "MYSQL_USER=admin", + "MYSQL_DATABASE=dbname" + ] + }"#; + + let config = serde_json::from_str::(json).unwrap(); + + assert_eq!(config.service_name(), "mariadb"); + assert_eq!(config.image().to_string(), "docker.io/library/mariadb:10.3"); + assert_eq!( + config.env(), + Some(&vec![ + String::from("MYSQL_USER=admin"), + String::from("MYSQL_DATABASE=dbname") + ]) + ); } } diff --git a/api/src/services/apps_service.rs b/api/src/services/apps_service.rs index 704a163..5e32d9e 100644 --- a/api/src/services/apps_service.rs +++ b/api/src/services/apps_service.rs @@ -79,7 +79,7 @@ impl<'a> AppsService<'a> { .filter(|config| { match service_configs .iter() - .find(|c| c.get_service_name() == config.get_service_name()) + .find(|c| c.service_name() == config.service_name()) { None => true, Some(_) => false, @@ -119,8 +119,8 @@ impl<'a> AppsService<'a> { configs.extend(self.get_application_companion_configs(app_name, &configs)?); configs.sort_unstable_by(|a, b| { - let index1 = AppsService::container_type_index(a.get_container_type()); - let index2 = AppsService::container_type_index(b.get_container_type()); + let index1 = AppsService::container_type_index(a.container_type()); + let index2 = AppsService::container_type_index(b.container_type()); index1.cmp(&index2) }); @@ -148,7 +148,7 @@ impl<'a> AppsService<'a> { .filter(|config| { match service_configs .iter() - .find(|c| c.get_service_name() == config.get_service_name()) + .find(|c| c.service_name() == config.service_name()) { None => true, Some(_) => false, diff --git a/api/src/services/config_service.rs b/api/src/services/config_service.rs index ec91910..e02895d 100644 --- a/api/src/services/config_service.rs +++ b/api/src/services/config_service.rs @@ -219,7 +219,7 @@ impl TryFrom<&Companion> for ServiceConfig { Err(_) => return Err(ConfigError::UnableToParseImage), }; - let mut config = ServiceConfig::new(companion.service_name.clone(), &image); + let mut config = ServiceConfig::new(companion.service_name.clone(), image); config.set_env(companion.env.clone()); config.set_labels(companion.labels.clone()); @@ -257,16 +257,16 @@ mod tests { assert_eq!(companion_configs.len(), 1); companion_configs.iter().for_each(|config| { - assert_eq!(config.get_service_name(), "openid"); + assert_eq!(config.service_name(), "openid"); assert_eq!( - &config.get_image().to_string(), + &config.image().to_string(), "private.example.com/library/opendid:latest" ); assert_eq!( - config.get_container_type(), + config.container_type(), &ContainerType::ApplicationCompanion ); - assert_eq!(config.get_labels(), None); + assert_eq!(config.labels(), None); }); } @@ -292,16 +292,16 @@ mod tests { assert_eq!(companion_configs.len(), 1); companion_configs.iter().for_each(|config| { - assert_eq!(config.get_service_name(), "{{service-name}}-nginx"); + assert_eq!(config.service_name(), "{{service-name}}-nginx"); assert_eq!( - &config.get_image().to_string(), + &config.image().to_string(), "docker.io/library/nginx:latest" ); assert_eq!( - config.get_container_type(), + config.container_type(), &ContainerType::ServiceCompanion ); - assert_eq!(config.get_labels(), None); + assert_eq!(config.labels(), None); }); } @@ -325,7 +325,7 @@ mod tests { assert_eq!(companion_configs.len(), 1); companion_configs.iter().for_each(|config| { - assert_eq!(config.get_volumes().unwrap().len(), 2); + assert_eq!(config.volumes().unwrap().len(), 2); }); } @@ -347,7 +347,7 @@ mod tests { assert_eq!(companion_configs.len(), 1); companion_configs.iter().for_each(|config| { - for (k, v) in config.get_labels().unwrap().iter() { + for (k, v) in config.labels().unwrap().iter() { assert_eq!(k, "com.example.foo"); assert_eq!(v, "bar"); } diff --git a/api/src/services/docker/docker_infrastructure.rs b/api/src/services/docker/docker_infrastructure.rs index e06a83c..3502f65 100644 --- a/api/src/services/docker/docker_infrastructure.rs +++ b/api/src/services/docker/docker_infrastructure.rs @@ -195,13 +195,13 @@ impl DockerInfrastructure { let images = docker.images(); let mut runtime = Runtime::new()?; - if let Image::Named { .. } = service_config.get_image() { + if let Image::Named { .. } = service_config.image() { self.pull_image(&mut runtime, app_name, &service_config)?; } let mut image_to_delete = None; if let Some(ref container_info) = - self.get_app_container(app_name, service_config.get_service_name())? + self.get_app_container(app_name, service_config.service_name())? { let container = containers.get(&container_info.id); let container_image_id = runtime.block_on(container.inspect())?.image.clone(); @@ -216,38 +216,38 @@ impl DockerInfrastructure { image_to_delete = Some(container_image_id.clone()); } - let container_type_name = service_config.get_container_type().to_string(); - let image = service_config.get_image().to_string(); + let container_type_name = service_config.container_type().to_string(); + let image = service_config.image().to_string(); info!( "Creating new review app container for {:?}: service={:?} with image={:?} ({:?})", app_name, - service_config.get_service_name(), + service_config.service_name(), image, container_type_name ); let mut options = ContainerOptions::builder(&image); - if let Some(ref env) = service_config.get_env() { + if let Some(ref env) = service_config.env() { options.env(env.iter().map(|e| e.as_str()).collect()); } let traefik_frontend = format!( "ReplacePathRegex: ^/{app_name}/{service_name}/(.*) /$1;PathPrefix:/{app_name}/{service_name}/;", app_name = app_name, - service_name = service_config.get_service_name() + service_name = service_config.service_name() ); let mut labels: HashMap<&str, &str> = HashMap::new(); labels.insert("traefik.frontend.rule", &traefik_frontend); - if let Some(config_labels) = service_config.get_labels() { + if let Some(config_labels) = service_config.labels() { for (k, v) in config_labels { labels.insert(k, v); } } labels.insert(APP_NAME_LABEL, app_name); - labels.insert(SERVICE_NAME_LABEL, &service_config.get_service_name()); + labels.insert(SERVICE_NAME_LABEL, &service_config.service_name()); labels.insert(CONTAINER_TYPE_LABEL, &container_type_name); options.labels(&labels); @@ -268,7 +268,7 @@ impl DockerInfrastructure { runtime.block_on( docker.networks().get(network_id).connect( &ContainerConnectionOptions::builder(&container_info.id) - .aliases(vec![service_config.get_service_name().as_str()]) + .aliases(vec![service_config.service_name().as_str()]) .build(), ), )?; @@ -279,7 +279,7 @@ impl DockerInfrastructure { let mut service = Service::try_from(&self.get_app_container_by_id(&container_info.id)?.unwrap())?; - service.set_container_type(service_config.get_container_type().clone()); + service.set_container_type(service_config.container_type().clone()); if let Some(image) = image_to_delete { info!("Clean up image {:?} of app {:?}", image, app_name); @@ -301,7 +301,7 @@ impl DockerInfrastructure { container_info: &ContainerCreateInfo, service_config: &ServiceConfig, ) -> Result<(), ShipLiftError> { - let volumes = match service_config.get_volumes() { + let volumes = match service_config.volumes() { None => return Ok(()), Some(volumes) => volumes, }; @@ -309,7 +309,7 @@ impl DockerInfrastructure { debug!( "Copy data to container: {:?} (service = {})", container_info, - service_config.get_service_name() + service_config.service_name() ); let docker = Docker::new(); @@ -333,12 +333,12 @@ impl DockerInfrastructure { app_name: &String, config: &ServiceConfig, ) -> Result<(), ShipLiftError> { - let image = config.get_image().to_string(); + let image = config.image().to_string(); info!( "Pulling {:?} for {:?} of app {:?}", image, - config.get_service_name(), + config.service_name(), app_name ); @@ -528,7 +528,7 @@ impl Infrastructure for DockerInfrastructure { Ok(service) => service, }; - match service.get_container_type() { + match service.container_type() { ContainerType::ApplicationCompanion | ContainerType::ServiceCompanion => continue, _ => {} }; @@ -547,7 +547,7 @@ impl Infrastructure for DockerInfrastructure { let image = Image::from_str(&container_details.image).unwrap(); let mut service_config = - ServiceConfig::new(service.get_service_name().clone(), &image); + ServiceConfig::new(service.service_name().clone(), image); service_config.set_env(env); if let Some(ports) = container_details.network_settings.ports { diff --git a/api/src/services/images_service.rs b/api/src/services/images_service.rs index 58dc3cf..bab0368 100644 --- a/api/src/services/images_service.rs +++ b/api/src/services/images_service.rs @@ -52,14 +52,14 @@ impl ImagesService { let mut port_mappings = HashMap::new(); for config in configs.iter() { - if let Image::Digest { hash: _ } = config.get_image() { + if let Image::Digest { hash: _ } = config.image() { break; } - let reference = reference::Reference::from_str(&config.get_image().to_string())?; + let reference = reference::Reference::from_str(&config.image().to_string())?; - let image = config.get_image().get_name().unwrap(); - let tag = config.get_image().get_tag().unwrap(); + let image = config.image().name().unwrap(); + let tag = config.image().tag().unwrap(); let client = dkregistry::v2::Client::configure(&core.handle()) .registry(&reference.registry()) diff --git a/api/src/services/service_templating.rs b/api/src/services/service_templating.rs index 3942153..afb1865 100644 --- a/api/src/services/service_templating.rs +++ b/api/src/services/service_templating.rs @@ -43,9 +43,9 @@ pub fn apply_templating_for_service_companion( }, services: None, service: Some(ServiceTemplateParameter { - name: service_config.get_service_name().clone(), - container_type: service_config.get_container_type().clone(), - port: service_config.get_port(), + name: service_config.service_name().clone(), + container_type: service_config.container_type().clone(), + port: service_config.port(), }), }; @@ -65,9 +65,9 @@ pub fn apply_templating_for_application_companion( service_configs .iter() .map(|c| ServiceTemplateParameter { - name: c.get_service_name().clone(), - container_type: c.get_container_type().clone(), - port: c.get_port(), + name: c.service_name().clone(), + container_type: c.container_type().clone(), + port: c.port(), }) .collect(), ), @@ -87,9 +87,9 @@ fn apply_template( let mut templated_config = comapnion_config.clone(); templated_config - .set_service_name(®.render_template(comapnion_config.get_service_name(), ¶meters)?); + .set_service_name(®.render_template(comapnion_config.service_name(), ¶meters)?); - if let Some(env) = comapnion_config.get_env() { + if let Some(env) = comapnion_config.env() { let mut templated_env = Vec::new(); for e in env { @@ -99,11 +99,11 @@ fn apply_template( templated_config.set_env(Some(templated_env)); } - if let Some(volumes) = comapnion_config.get_volumes() { + if let Some(volumes) = comapnion_config.volumes() { templated_config.set_volumes(Some(apply_templates(®, ¶meters, volumes)?)); } - if let Some(labels) = comapnion_config.get_labels() { + if let Some(labels) = comapnion_config.labels() { templated_config.set_labels(Some(apply_templates(®, ¶meters, labels)?)); } @@ -212,7 +212,7 @@ mod tests { let env = vec![]; let mut config = ServiceConfig::new( String::from("postgres-{{application.name}}"), - &Image::from_str("postgres").unwrap(), + Image::from_str("postgres").unwrap(), ); config.set_env(Some(env)); @@ -224,7 +224,7 @@ mod tests { ) .unwrap(); - assert_eq!(templated_config.get_service_name(), "postgres-master"); + assert_eq!(templated_config.service_name(), "postgres-master"); } #[test] @@ -238,18 +238,18 @@ mod tests { let mut config = ServiceConfig::new( String::from("postgres-db"), - &Image::from_str("postgres").unwrap(), + Image::from_str("postgres").unwrap(), ); config.set_env(Some(env)); let service_configs = vec![ ServiceConfig::new( String::from("service-a"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ServiceConfig::new( String::from("service-b"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ]; let templated_config = apply_templating_for_application_companion( @@ -260,7 +260,7 @@ mod tests { .unwrap(); assert_eq!( - templated_config.get_env().unwrap().get(0).unwrap(), + templated_config.env().unwrap().get(0).unwrap(), "DATABASE_SCHEMAS=service-a,service-b," ); } @@ -269,7 +269,7 @@ mod tests { fn should_apply_app_companion_templating_with_labels() { let mut config = ServiceConfig::new( String::from("postgres-db"), - &Image::from_str("postgres").unwrap(), + Image::from_str("postgres").unwrap(), ); let mut labels = BTreeMap::new(); @@ -282,11 +282,11 @@ mod tests { let service_configs = vec![ ServiceConfig::new( String::from("service-a"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ServiceConfig::new( String::from("service-b"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ]; let templated_config = apply_templating_for_application_companion( @@ -296,7 +296,7 @@ mod tests { ) .unwrap(); - for (k, v) in templated_config.get_labels().unwrap().iter() { + for (k, v) in templated_config.labels().unwrap().iter() { assert_eq!(k, "com.foo.bar"); assert_eq!(v, "app-master"); } @@ -313,7 +313,7 @@ mod tests { let mut config = ServiceConfig::new( String::from("postgres-db"), - &Image::from_str("postgres").unwrap(), + Image::from_str("postgres").unwrap(), ); config.set_env(Some(env)); @@ -327,7 +327,7 @@ mod tests { fn should_apply_app_companion_templating_with_volumes() { let mut config = ServiceConfig::new( String::from("nginx-proxy"), - &Image::from_str("nginx").unwrap(), + Image::from_str("nginx").unwrap(), ); let mount_path = String::from("/etc/ningx/conf.d/default.conf"); @@ -347,11 +347,11 @@ location /{{name}} { let service_configs = vec![ ServiceConfig::new( String::from("service-a"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ServiceConfig::new( String::from("service-b"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ), ]; let templated_config = apply_templating_for_application_companion( @@ -363,7 +363,7 @@ location /{{name}} { assert_eq!( templated_config - .get_volumes() + .volumes() .unwrap() .get(&mount_path) .unwrap(), @@ -383,22 +383,22 @@ location /service-b { fn should_apply_templating_with_is_not_companion_helper() { let mut service_a = ServiceConfig::new( String::from("service-a"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_a.set_container_type(ContainerType::Instance); let mut service_b = ServiceConfig::new( String::from("service-b"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_b.set_container_type(ContainerType::Replica); let mut service_c = ServiceConfig::new( String::from("service-c"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_c.set_container_type(ContainerType::ApplicationCompanion); let mut service_d = ServiceConfig::new( String::from("service-d"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_d.set_container_type(ContainerType::ServiceCompanion); @@ -406,7 +406,7 @@ location /service-b { let mut config = ServiceConfig::new( String::from("nginx-proxy"), - &Image::from_str("nginx").unwrap(), + Image::from_str("nginx").unwrap(), ); let mount_path = String::from("/etc/ningx/conf.d/default.conf"); let mut volumes = BTreeMap::new(); @@ -433,7 +433,7 @@ location /{{name}} { assert_eq!( templated_config - .get_volumes() + .volumes() .unwrap() .get(&mount_path) .unwrap(), @@ -451,22 +451,22 @@ location /service-b { fn should_apply_templating_with_is_companion_helper() { let mut service_a = ServiceConfig::new( String::from("service-a"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_a.set_container_type(ContainerType::Instance); let mut service_b = ServiceConfig::new( String::from("service-b"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_b.set_container_type(ContainerType::Replica); let mut service_c = ServiceConfig::new( String::from("service-c"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_c.set_container_type(ContainerType::ApplicationCompanion); let mut service_d = ServiceConfig::new( String::from("service-d"), - &Image::from_str("service").unwrap(), + Image::from_str("service").unwrap(), ); service_d.set_container_type(ContainerType::ServiceCompanion); @@ -474,7 +474,7 @@ location /service-b { let mut config = ServiceConfig::new( String::from("nginx-proxy"), - &Image::from_str("nginx").unwrap(), + Image::from_str("nginx").unwrap(), ); let mount_path = String::from("/etc/ningx/conf.d/default.conf"); let mut volumes = BTreeMap::new(); @@ -501,7 +501,7 @@ location /{{name}} { assert_eq!( templated_config - .get_volumes() + .volumes() .unwrap() .get(&mount_path) .unwrap(),