Skip to content

Commit

Permalink
feat: Add WithLogger(ILogger) builder API (#1100)
Browse files Browse the repository at this point in the history
Co-authored-by: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com>
  • Loading branch information
0xced and HofmeisterAn authored Mar 11, 2024
1 parent d7b4f14 commit 1cfc850
Show file tree
Hide file tree
Showing 157 changed files with 578 additions and 458 deletions.
4 changes: 3 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
<PackageVersion Include="Docker.DotNet.X509" Version="3.125.15"/>
<PackageVersion Include="Docker.DotNet" Version="3.125.15"/>
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0"/>
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.4"/>
<PackageVersion Include="SharpZipLib" Version="1.4.2"/>
<PackageVersion Include="SSH.NET" Version="2023.0.0"/>
<PackageVersion Include="System.Text.Json" Version="6.0.9"/>
<!-- Unit and integration test dependencies: -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageVersion Include="coverlet.collector" Version="6.0.0"/>
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.2.0"/>
<PackageVersion Include="coverlet.collector" Version="6.0.1"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.7"/>
<PackageVersion Include="xunit" Version="2.7.0"/>
<!-- Third-party client dependencies to connect and interact with the containers: -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class ModuleNameContainer : DockerContainer
/// Initializes a new instance of the <see cref="ModuleNameContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public ModuleNameContainer(ModuleNameConfiguration configuration, ILogger logger)
: base(configuration, logger)
public ModuleNameContainer(ModuleNameConfiguration configuration)
: base(configuration)
{
}
}
2 changes: 1 addition & 1 deletion src/Testcontainers.ActiveMq/ArtemisBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ArtemisBuilder WithPassword(string password)
public override ArtemisContainer Build()
{
Validate();
return new ArtemisContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new ArtemisContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.ActiveMq/ArtemisContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public sealed class ArtemisContainer : DockerContainer
/// Initializes a new instance of the <see cref="ArtemisContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public ArtemisContainer(ActiveMqConfiguration configuration, ILogger logger)
: base(configuration, logger)
public ArtemisContainer(ActiveMqConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.ActiveMq/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.ArangoDb/ArangoDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ArangoDbBuilder WithPassword(string password)
public override ArangoDbContainer Build()
{
Validate();
return new ArangoDbContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new ArangoDbContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.ArangoDb/ArangoDbContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class ArangoDbContainer : DockerContainer
/// Initializes a new instance of the <see cref="ArangoDbContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public ArangoDbContainer(ArangoDbConfiguration configuration, ILogger logger)
: base(configuration, logger)
public ArangoDbContainer(ArangoDbConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.ArangoDb/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.Azurite/AzuriteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override AzuriteContainer Build()
}

var azuriteBuilder = DockerResourceConfiguration.WaitStrategies.Count() > 1 ? this : WithWaitStrategy(waitStrategy);
return new AzuriteContainer(azuriteBuilder.DockerResourceConfiguration, TestcontainersSettings.Logger);
return new AzuriteContainer(azuriteBuilder.DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.Azurite/AzuriteContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ public sealed class AzuriteContainer : DockerContainer
/// Initializes a new instance of the <see cref="AzuriteContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public AzuriteContainer(AzuriteConfiguration configuration, ILogger logger)
: base(configuration, logger)
public AzuriteContainer(AzuriteConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.Azurite/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.BigQuery/BigQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public BigQueryBuilder WithProject(string projectId)
public override BigQueryContainer Build()
{
Validate();
return new BigQueryContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new BigQueryContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.BigQuery/BigQueryContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class BigQueryContainer : DockerContainer
/// Initializes a new instance of the <see cref="BigQueryContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public BigQueryContainer(BigQueryConfiguration configuration, ILogger logger)
: base(configuration, logger)
public BigQueryContainer(BigQueryConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.BigQuery/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.Bigtable/BigtableBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private BigtableBuilder(BigtableConfiguration resourceConfiguration)
public override BigtableContainer Build()
{
Validate();
return new BigtableContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new BigtableContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.Bigtable/BigtableContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class BigtableContainer : DockerContainer
/// Initializes a new instance of the <see cref="BigtableContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public BigtableContainer(IContainerConfiguration configuration, ILogger logger)
: base(configuration, logger)
public BigtableContainer(IContainerConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.Bigtable/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.ClickHouse/ClickHouseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ClickHouseBuilder WithPassword(string password)
public override ClickHouseContainer Build()
{
Validate();
return new ClickHouseContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new ClickHouseContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.ClickHouse/ClickHouseContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public sealed class ClickHouseContainer : DockerContainer, IDatabaseContainer
/// Initializes a new instance of the <see cref="ClickHouseContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public ClickHouseContainer(ClickHouseConfiguration configuration, ILogger logger)
: base(configuration, logger)
public ClickHouseContainer(ClickHouseConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.ClickHouse/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.CockroachDb/CockroachDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public CockroachDbBuilder WithPassword(string password)
public override CockroachDbContainer Build()
{
Validate();
return new CockroachDbContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new CockroachDbContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.CockroachDb/CockroachDbContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public sealed class CockroachDbContainer : DockerContainer, IDatabaseContainer
/// Initializes a new instance of the <see cref="CockroachDbContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public CockroachDbContainer(CockroachDbConfiguration configuration, ILogger logger)
: base(configuration, logger)
public CockroachDbContainer(CockroachDbConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.CockroachDb/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.Consul/ConsulBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private ConsulBuilder(ConsulConfiguration resourceConfiguration)
public override ConsulContainer Build()
{
Validate();
return new ConsulContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new ConsulContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.Consul/ConsulContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class ConsulContainer : DockerContainer
/// Initializes a new instance of the <see cref="ConsulContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public ConsulContainer(ConsulConfiguration configuration, ILogger logger)
: base(configuration, logger)
public ConsulContainer(ConsulConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.Consul/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.CosmosDb/CosmosDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private CosmosDbBuilder(CosmosDbConfiguration resourceConfiguration)
public override CosmosDbContainer Build()
{
Validate();
return new CosmosDbContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new CosmosDbContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.CosmosDb/CosmosDbContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class CosmosDbContainer : DockerContainer
/// Initializes a new instance of the <see cref="CosmosDbContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public CosmosDbContainer(CosmosDbConfiguration configuration, ILogger logger)
: base(configuration, logger)
public CosmosDbContainer(CosmosDbConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.CosmosDb/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.CouchDb/CouchDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CouchDbBuilder WithPassword(string password)
public override CouchDbContainer Build()
{
Validate();
return new CouchDbContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new CouchDbContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.CouchDb/CouchDbContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public sealed class CouchDbContainer : DockerContainer
/// Initializes a new instance of the <see cref="CouchDbContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public CouchDbContainer(CouchDbConfiguration configuration, ILogger logger)
: base(configuration, logger)
public CouchDbContainer(CouchDbConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.CouchDb/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.Couchbase/CouchbaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public override CouchbaseContainer Build()
}

var couchbaseBuilder = DockerResourceConfiguration.WaitStrategies.Count() > 1 ? this : WithWaitStrategy(waitStrategy);
return new CouchbaseContainer(couchbaseBuilder.DockerResourceConfiguration, TestcontainersSettings.Logger);
return new CouchbaseContainer(couchbaseBuilder.DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.Couchbase/CouchbaseContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public sealed class CouchbaseContainer : DockerContainer
/// Initializes a new instance of the <see cref="CouchbaseContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public CouchbaseContainer(CouchbaseConfiguration configuration, ILogger logger)
: base(configuration, logger)
public CouchbaseContainer(CouchbaseConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
Starting += (_, _) => Logger.LogInformation("Couchbase container is starting, performing configuration.");
Expand Down
2 changes: 1 addition & 1 deletion src/Testcontainers.DynamoDb/DynamoDbBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private DynamoDbBuilder(DynamoDbConfiguration dockerResourceConfiguration)
public override DynamoDbContainer Build()
{
Validate();
return new DynamoDbContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new DynamoDbContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
5 changes: 2 additions & 3 deletions src/Testcontainers.DynamoDb/DynamoDbContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public sealed class DynamoDbContainer : DockerContainer
/// Initializes a new instance of the <see cref="DynamoDbContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
/// <param name="logger">The logger.</param>
public DynamoDbContainer(DynamoDbConfiguration configuration, ILogger logger)
: base(configuration, logger)
public DynamoDbContainer(DynamoDbConfiguration configuration)
: base(configuration)
{
}

Expand Down
3 changes: 1 addition & 2 deletions src/Testcontainers.DynamoDb/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
global using DotNet.Testcontainers.Builders;
global using DotNet.Testcontainers.Configurations;
global using DotNet.Testcontainers.Containers;
global using JetBrains.Annotations;
global using Microsoft.Extensions.Logging;
global using JetBrains.Annotations;
2 changes: 1 addition & 1 deletion src/Testcontainers.Elasticsearch/ElasticsearchBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ElasticsearchBuilder WithPassword(string password)
public override ElasticsearchContainer Build()
{
Validate();
return new ElasticsearchContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new ElasticsearchContainer(DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
Loading

0 comments on commit 1cfc850

Please sign in to comment.