Skip to content

Commit

Permalink
chore: Favor environment configuration over properties file (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn authored May 22, 2023
1 parent 7343c73 commit 804d688
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ public IDockerRegistryAuthenticationConfiguration GetAuthConfig(string hostname)

private static string GetDefaultDockerConfigFilePath()
{
var dockerConfigDirectoryPath = PropertiesFileConfiguration.Instance.GetDockerConfig() ?? EnvironmentConfiguration.Instance.GetDockerConfig() ?? UserProfileDockerConfigDirectoryPath;
var dockerConfigDirectoryPath = EnvironmentConfiguration.Instance.GetDockerConfig() ?? PropertiesFileConfiguration.Instance.GetDockerConfig() ?? UserProfileDockerConfigDirectoryPath;
return Path.Combine(dockerConfigDirectoryPath, "config.json");
}

private static JsonDocument GetDefaultDockerAuthConfig()
{
return PropertiesFileConfiguration.Instance.GetDockerAuthConfig() ?? EnvironmentConfiguration.Instance.GetDockerAuthConfig() ?? JsonDocument.Parse("{}");
return EnvironmentConfiguration.Instance.GetDockerAuthConfig() ?? PropertiesFileConfiguration.Instance.GetDockerAuthConfig() ?? JsonDocument.Parse("{}");
}

private IDockerRegistryAuthenticationConfiguration GetUncachedAuthConfig(string hostname)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal sealed class EnvironmentEndpointAuthenticationProvider : DockerEndpoint
/// Initializes a new instance of the <see cref="EnvironmentEndpointAuthenticationProvider" /> class.
/// </summary>
public EnvironmentEndpointAuthenticationProvider()
: this(PropertiesFileConfiguration.Instance, EnvironmentConfiguration.Instance)
: this(EnvironmentConfiguration.Instance, PropertiesFileConfiguration.Instance)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal sealed class MTlsEndpointAuthenticationProvider : TlsEndpointAuthentica
/// Initializes a new instance of the <see cref="MTlsEndpointAuthenticationProvider" /> class.
/// </summary>
public MTlsEndpointAuthenticationProvider()
: this(PropertiesFileConfiguration.Instance, EnvironmentConfiguration.Instance)
: this(EnvironmentConfiguration.Instance, PropertiesFileConfiguration.Instance)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class TlsEndpointAuthenticationProvider : DockerEndpointAuthenticationP
/// Initializes a new instance of the <see cref="TlsEndpointAuthenticationProvider" /> class.
/// </summary>
public TlsEndpointAuthenticationProvider()
: this(PropertiesFileConfiguration.Instance, EnvironmentConfiguration.Instance)
: this(EnvironmentConfiguration.Instance, PropertiesFileConfiguration.Instance)
{
}

Expand Down
12 changes: 6 additions & 6 deletions src/Testcontainers/Configurations/TestcontainersSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,34 @@ static TestcontainersSettings()
[CanBeNull]
public static string DockerHostOverride { get; set; }
= DockerEndpointAuthProvider is ICustomConfiguration config
? config.GetDockerHostOverride() : PropertiesFileConfiguration.Instance.GetDockerHostOverride() ?? EnvironmentConfiguration.Instance.GetDockerHostOverride();
? config.GetDockerHostOverride() : EnvironmentConfiguration.Instance.GetDockerHostOverride() ?? PropertiesFileConfiguration.Instance.GetDockerHostOverride();

/// <summary>
/// Gets or sets the Docker socket override value.
/// </summary>
[CanBeNull]
public static string DockerSocketOverride { get; set; }
= DockerEndpointAuthProvider is ICustomConfiguration config
? config.GetDockerSocketOverride() : PropertiesFileConfiguration.Instance.GetDockerSocketOverride() ?? EnvironmentConfiguration.Instance.GetDockerSocketOverride();
? config.GetDockerSocketOverride() : EnvironmentConfiguration.Instance.GetDockerSocketOverride() ?? PropertiesFileConfiguration.Instance.GetDockerSocketOverride();

/// <summary>
/// Gets or sets a value indicating whether the <see cref="ResourceReaper" /> is enabled or not.
/// </summary>
public static bool ResourceReaperEnabled { get; set; }
= !PropertiesFileConfiguration.Instance.GetRyukDisabled() && !EnvironmentConfiguration.Instance.GetRyukDisabled();
= !EnvironmentConfiguration.Instance.GetRyukDisabled() && !PropertiesFileConfiguration.Instance.GetRyukDisabled();

/// <summary>
/// Gets or sets a value indicating whether the <see cref="ResourceReaper" /> privileged mode is enabled or not.
/// </summary>
public static bool ResourceReaperPrivilegedModeEnabled { get; set; }
= PropertiesFileConfiguration.Instance.GetRyukContainerPrivileged() || EnvironmentConfiguration.Instance.GetRyukContainerPrivileged();
= EnvironmentConfiguration.Instance.GetRyukContainerPrivileged() || PropertiesFileConfiguration.Instance.GetRyukContainerPrivileged();

/// <summary>
/// Gets or sets the <see cref="ResourceReaper" /> image.
/// </summary>
[CanBeNull]
public static IImage ResourceReaperImage { get; set; }
= PropertiesFileConfiguration.Instance.GetRyukContainerImage() ?? EnvironmentConfiguration.Instance.GetRyukContainerImage();
= EnvironmentConfiguration.Instance.GetRyukContainerImage() ?? PropertiesFileConfiguration.Instance.GetRyukContainerImage();

/// <summary>
/// Gets or sets the <see cref="ResourceReaper" /> public host port.
Expand All @@ -159,7 +159,7 @@ static TestcontainersSettings()
/// </remarks>
[CanBeNull]
public static string HubImageNamePrefix { get; set; }
= PropertiesFileConfiguration.Instance.GetHubImageNamePrefix() ?? EnvironmentConfiguration.Instance.GetHubImageNamePrefix();
= EnvironmentConfiguration.Instance.GetHubImageNamePrefix() ?? PropertiesFileConfiguration.Instance.GetHubImageNamePrefix();

/// <summary>
/// Gets or sets the logger.
Expand Down

0 comments on commit 804d688

Please sign in to comment.