From 6045cb7ca17a531a88e41ef1da4517f90321a44f Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Sun, 7 Jul 2024 17:39:39 +0200 Subject: [PATCH] chore!: made sure that the way structs are constructed is consistent and encourages the builder pattern --- src/cncf_distribution/mod.rs | 9 +++++++-- src/dynamodb_local/mod.rs | 9 +++++++-- src/elastic_search/mod.rs | 3 +++ src/elasticmq/mod.rs | 9 +++++++-- src/kwok/mod.rs | 9 +++++++-- src/localstack/mod.rs | 3 +++ src/mariadb/mod.rs | 3 +++ src/mongo/mod.rs | 9 +++++++-- src/mosquitto/mod.rs | 3 +++ src/mysql/mod.rs | 3 +++ src/oracle/free.rs | 3 +++ src/orientdb/mod.rs | 3 +++ src/parity_parity/mod.rs | 3 +++ src/rabbitmq/mod.rs | 9 +++++++-- src/redis/stack.rs | 11 ++++++++--- src/redis/standalone.rs | 9 +++++++-- src/solr/mod.rs | 3 +++ src/victoria_metrics/mod.rs | 9 +++++++-- src/zookeeper/mod.rs | 3 +++ 19 files changed, 94 insertions(+), 19 deletions(-) diff --git a/src/cncf_distribution/mod.rs b/src/cncf_distribution/mod.rs index 6317771..e0b1603 100644 --- a/src/cncf_distribution/mod.rs +++ b/src/cncf_distribution/mod.rs @@ -21,7 +21,12 @@ const TAG: &str = "2"; /// /// [`CNCF Distribution`]: https://distribution.github.io/distribution/ #[derive(Debug, Default, Clone)] -pub struct CncfDistribution; +pub struct CncfDistribution { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for CncfDistribution { fn name(&self) -> &str { @@ -52,7 +57,7 @@ mod tests { #[tokio::test] async fn distribution_push_pull_image() -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let distribution_node = cncf_distribution::CncfDistribution.start().await?; + let distribution_node = cncf_distribution::CncfDistribution::default().start().await?; let docker = bollard::Docker::connect_with_local_defaults().unwrap(); let image_tag = format!( "localhost:{}/test:latest", diff --git a/src/dynamodb_local/mod.rs b/src/dynamodb_local/mod.rs index e095ab8..ff059bc 100644 --- a/src/dynamodb_local/mod.rs +++ b/src/dynamodb_local/mod.rs @@ -5,7 +5,12 @@ const TAG: &str = "2.0.0"; const DEFAULT_WAIT: u64 = 3000; #[derive(Default, Debug, Clone)] -pub struct DynamoDb; +pub struct DynamoDb { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for DynamoDb { fn name(&self) -> &str { @@ -46,7 +51,7 @@ mod tests { #[tokio::test] async fn dynamodb_local_create_table() -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let node = DynamoDb.start().await?; + let node = DynamoDb::default().start().await?; let host = node.get_host().await?; let host_port = node.get_host_port_ipv4(8000.tcp()).await?; diff --git a/src/elastic_search/mod.rs b/src/elastic_search/mod.rs index 74033d7..63f3dae 100644 --- a/src/elastic_search/mod.rs +++ b/src/elastic_search/mod.rs @@ -10,6 +10,9 @@ const TAG: &str = "7.16.1"; #[derive(Debug, Default, Clone)] pub struct ElasticSearch { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/elasticmq/mod.rs b/src/elasticmq/mod.rs index 1cc1c71..1dcafab 100644 --- a/src/elasticmq/mod.rs +++ b/src/elasticmq/mod.rs @@ -4,7 +4,12 @@ const NAME: &str = "softwaremill/elasticmq"; const TAG: &str = "1.5.2"; #[derive(Debug, Default, Clone)] -pub struct ElasticMq; +pub struct ElasticMq { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for ElasticMq { fn name(&self) -> &str { @@ -31,7 +36,7 @@ mod tests { #[tokio::test] async fn sqs_list_queues() -> Result<(), Box> { - let node = ElasticMq.start().await?; + let node = ElasticMq::default().start().await?; let host_ip = node.get_host().await?; let host_port = node.get_host_port_ipv4(9324).await?; let client = build_sqs_client(host_ip, host_port).await; diff --git a/src/kwok/mod.rs b/src/kwok/mod.rs index bbf047c..a1b854d 100644 --- a/src/kwok/mod.rs +++ b/src/kwok/mod.rs @@ -26,7 +26,12 @@ const DEFAULT_WAIT: u64 = 3000; /// /// No environment variables are required. #[derive(Debug, Default, Clone)] -pub struct KwokCluster; +pub struct KwokCluster { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for KwokCluster { fn name(&self) -> &str { @@ -75,7 +80,7 @@ mod test { .expect("Error initializing rustls provider"); } - let node = KwokCluster.start().await?; + let node = KwokCluster::default().start().await?; let host_port = node.get_host_port_ipv4(8080.tcp()).await?; // Create a custom Kubeconfig diff --git a/src/localstack/mod.rs b/src/localstack/mod.rs index 73e688f..cd76b28 100644 --- a/src/localstack/mod.rs +++ b/src/localstack/mod.rs @@ -26,6 +26,9 @@ const DEFAULT_WAIT: u64 = 3000; /// No environment variables are required. #[derive(Default, Debug, Clone)] pub struct LocalStack { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/mariadb/mod.rs b/src/mariadb/mod.rs index 72636f9..766181b 100644 --- a/src/mariadb/mod.rs +++ b/src/mariadb/mod.rs @@ -27,6 +27,9 @@ const TAG: &str = "11.3"; /// [`MariaDB docker image`]: https://hub.docker.com/_/mariadb #[derive(Debug, Default, Clone)] pub struct Mariadb { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/mongo/mod.rs b/src/mongo/mod.rs index 13d90cf..1f7707c 100644 --- a/src/mongo/mod.rs +++ b/src/mongo/mod.rs @@ -4,7 +4,12 @@ const NAME: &str = "mongo"; const TAG: &str = "5.0.6"; #[derive(Default, Debug, Clone)] -pub struct Mongo; +pub struct Mongo { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for Mongo { fn name(&self) -> &str { @@ -30,7 +35,7 @@ mod tests { #[tokio::test] async fn mongo_fetch_document() -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let node = mongo::Mongo.start().await?; + let node = mongo::Mongo::default().start().await?; let host_ip = node.get_host().await?; let host_port = node.get_host_port_ipv4(27017.tcp()).await?; let url = format!("mongodb://{host_ip}:{host_port}/"); diff --git a/src/mosquitto/mod.rs b/src/mosquitto/mod.rs index 5f0479f..39b2e70 100644 --- a/src/mosquitto/mod.rs +++ b/src/mosquitto/mod.rs @@ -24,6 +24,9 @@ const TAG: &str = "2.0.18"; #[derive(Debug, Default, Clone)] pub struct Mosquitto { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/mysql/mod.rs b/src/mysql/mod.rs index 330cdff..d458404 100644 --- a/src/mysql/mod.rs +++ b/src/mysql/mod.rs @@ -27,6 +27,9 @@ const TAG: &str = "8.1"; /// [`MySQL docker image`]: https://hub.docker.com/_/mysql #[derive(Debug, Default, Clone)] pub struct Mysql { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/oracle/free.rs b/src/oracle/free.rs index 10ffa3f..4e20d68 100644 --- a/src/oracle/free.rs +++ b/src/oracle/free.rs @@ -46,6 +46,9 @@ const DEFAULT_IMAGE_TAG: &str = "23-slim-faststart"; /// [`gvenzl/oracle-free:23-slim-faststart`]: https://hub.docker.com/r/gvenzl/oracle-free #[derive(Debug, Default, Clone)] pub struct Oracle { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/orientdb/mod.rs b/src/orientdb/mod.rs index aafcda6..38f1962 100644 --- a/src/orientdb/mod.rs +++ b/src/orientdb/mod.rs @@ -7,6 +7,9 @@ const TAG: &str = "3.2.19"; #[derive(Debug, Default, Clone)] pub struct OrientDb { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/parity_parity/mod.rs b/src/parity_parity/mod.rs index 0964412..c87363d 100644 --- a/src/parity_parity/mod.rs +++ b/src/parity_parity/mod.rs @@ -7,6 +7,9 @@ const TAG: &str = "v2.5.0"; #[derive(Debug, Default, Clone)] pub struct ParityEthereum { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/rabbitmq/mod.rs b/src/rabbitmq/mod.rs index aafe2df..a7cf278 100644 --- a/src/rabbitmq/mod.rs +++ b/src/rabbitmq/mod.rs @@ -26,7 +26,12 @@ const TAG: &str = "3.8.22-management"; /// [`RabbitMQ Management HTTP API`]: https://www.rabbitmq.com/management.html#http-api /// [`RabbitMQ docker image`]: https://hub.docker.com/_/rabbitmq #[derive(Debug, Default, Clone)] -pub struct RabbitMq; +pub struct RabbitMq { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for RabbitMq { fn name(&self) -> &str { @@ -64,7 +69,7 @@ mod tests { async fn rabbitmq_produce_and_consume_messages( ) -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let rabbit_node = rabbitmq::RabbitMq.start().await?; + let rabbit_node = rabbitmq::RabbitMq::default().start().await?; let amqp_url = format!( "amqp://{}:{}", diff --git a/src/redis/stack.rs b/src/redis/stack.rs index 035c3d6..98ed613 100644 --- a/src/redis/stack.rs +++ b/src/redis/stack.rs @@ -15,7 +15,7 @@ const TAG: &str = "7.2.0-v8"; /// use serde_json::json; /// use testcontainers_modules::{testcontainers::runners::SyncRunner, redis::{RedisStack, REDIS_PORT}}; /// -/// let redis_instance = RedisStack.start().unwrap(); +/// let redis_instance = RedisStack::default().start().unwrap(); /// let host_ip = redis_instance.get_host().unwrap(); /// let host_port = redis_instance.get_host_port_ipv4(REDIS_PORT).unwrap(); /// @@ -32,7 +32,12 @@ const TAG: &str = "7.2.0-v8"; /// [`Redis reference guide`]: https://redis.io/docs/interact/ /// [`REDIS_PORT`]: super::REDIS_PORT #[derive(Debug, Default, Clone)] -pub struct RedisStack; +pub struct RedisStack { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for RedisStack { fn name(&self) -> &str { @@ -61,7 +66,7 @@ mod tests { #[test] fn redis_fetch_an_integer_in_json() -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let node = RedisStack.start()?; + let node = RedisStack::default().start()?; let host_ip = node.get_host()?; let host_port = node.get_host_port_ipv4(REDIS_PORT)?; let url = format!("redis://{host_ip}:{host_port}"); diff --git a/src/redis/standalone.rs b/src/redis/standalone.rs index 90de8e3..9af9e43 100644 --- a/src/redis/standalone.rs +++ b/src/redis/standalone.rs @@ -31,7 +31,12 @@ const TAG: &str = "5.0"; /// [`Redis reference guide`]: https://redis.io/docs/interact/ /// [`REDIS_PORT`]: super::REDIS_PORT #[derive(Debug, Default, Clone)] -pub struct Redis; +pub struct Redis { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for Redis { fn name(&self) -> &str { @@ -56,7 +61,7 @@ mod tests { #[test] fn redis_fetch_an_integer() -> Result<(), Box> { let _ = pretty_env_logger::try_init(); - let node = Redis.start()?; + let node = Redis::default().start()?; let host_ip = node.get_host()?; let host_port = node.get_host_port_ipv4(6379)?; let url = format!("redis://{host_ip}:{host_port}"); diff --git a/src/solr/mod.rs b/src/solr/mod.rs index 50b7654..0705934 100644 --- a/src/solr/mod.rs +++ b/src/solr/mod.rs @@ -28,6 +28,9 @@ const TAG: &str = "9.5.0-slim"; /// [`Solr reference guide`]: https://solr.apache.org/guide/solr/latest/ #[derive(Debug, Default, Clone)] pub struct Solr { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), } diff --git a/src/victoria_metrics/mod.rs b/src/victoria_metrics/mod.rs index b886019..f1d4ac8 100644 --- a/src/victoria_metrics/mod.rs +++ b/src/victoria_metrics/mod.rs @@ -25,7 +25,12 @@ const TAG: &str = "v1.96.0"; /// [`VictoriaMetrics API examples`]: https://docs.victoriametrics.com/url-examples.html#victoriametrics-api-examples /// [`VictoriaMetrics Docker image`]: https://hub.docker.com/r/victoriametrics/victoria-metrics #[derive(Debug, Default, Clone)] -pub struct VictoriaMetrics; +pub struct VictoriaMetrics { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes + _priv: (), +} impl Image for VictoriaMetrics { fn name(&self) -> &str { @@ -55,7 +60,7 @@ mod tests { #[test] fn query_buildinfo() -> Result<(), Box> { - let node = VictoriaMetricsImage.start()?; + let node = VictoriaMetricsImage::default().start()?; let host_ip = node.get_host()?; let host_port = node.get_host_port_ipv4(8428)?; let url = format!("http://{host_ip}:{host_port}/api/v1/status/buildinfo"); diff --git a/src/zookeeper/mod.rs b/src/zookeeper/mod.rs index 8813127..3aca664 100644 --- a/src/zookeeper/mod.rs +++ b/src/zookeeper/mod.rs @@ -7,6 +7,9 @@ const TAG: &str = "3.9.0"; #[derive(Debug, Default, Clone)] pub struct Zookeeper { + /// (remove if there is another variable) + /// Field is included to prevent this struct to be a unit struct. + /// This allows extending functionality (and thus further variables) without breaking changes _priv: (), }