Skip to content

Commit

Permalink
Normalize line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r committed Feb 28, 2023
1 parent f828244 commit bfc5f64
Show file tree
Hide file tree
Showing 22 changed files with 1,219 additions and 1,219 deletions.
44 changes: 22 additions & 22 deletions build/docker-images/HealthChecks.UI.Image/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
using HealthChecks.UI.Image.Configuration;
using HealthChecks.UI.Image.PushService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;

namespace HealthChecks.UI.Image
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

public void ConfigureServices(IServiceCollection services)
namespace HealthChecks.UI.Image
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

public void ConfigureServices(IServiceCollection services)
{
#pragma warning disable ASP5001, CS0618 // Type or member is obsolete
services
.AddHealthChecksUI()
services
.AddHealthChecksUI()
.AddStorageProvider(Configuration)
.AddMvc()
.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
#pragma warning restore ASP5001, CS0618 // Type or member is obsolete

Expand All @@ -31,15 +31,15 @@ public void ConfigureServices(IServiceCollection services)
}
services.AddTransient<HealthChecksPushService>();
}
}
public void Configure(IApplicationBuilder app)
}
public void Configure(IApplicationBuilder app)
{
app.UseRouting()
.UseEndpoints(config =>
{
config.MapHealthChecksUI(Configuration);
config.MapDefaultControllerRoute();
});
}
}
}
});
}
}
}
80 changes: 40 additions & 40 deletions src/HealthChecks.Aws.S3/S3HealthCheck.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
using Amazon.Runtime;
using Amazon.S3;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace HealthChecks.Aws.S3;

public class S3HealthCheck : IHealthCheck
{
private readonly S3BucketOptions _bucketOptions;

public S3HealthCheck(S3BucketOptions bucketOptions)
{
Guard.ThrowIfNull(bucketOptions);
Guard.ThrowIfNull(bucketOptions.S3Config);

_bucketOptions = bucketOptions;
using Amazon.S3;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace HealthChecks.Aws.S3;

public class S3HealthCheck : IHealthCheck
{
private readonly S3BucketOptions _bucketOptions;

public S3HealthCheck(S3BucketOptions bucketOptions)
{
Guard.ThrowIfNull(bucketOptions);
Guard.ThrowIfNull(bucketOptions.S3Config);

_bucketOptions = bucketOptions;
}

/// <inheritdoc />
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
/// <inheritdoc />
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
AWSCredentials? credentials = _bucketOptions.Credentials;

if (credentials == null)
if (credentials == null)
{
#pragma warning disable CS0618 // Type or member is obsolete
if (!string.IsNullOrEmpty(_bucketOptions.AccessKey) && !string.IsNullOrEmpty(_bucketOptions.SecretKey))
{
// for backwards compatibility we create the basic credentials if the old fields are used
// but if they are not specified we fallback to using the default profile
credentials = new BasicAWSCredentials(_bucketOptions.AccessKey, _bucketOptions.SecretKey);
if (!string.IsNullOrEmpty(_bucketOptions.AccessKey) && !string.IsNullOrEmpty(_bucketOptions.SecretKey))
{
// for backwards compatibility we create the basic credentials if the old fields are used
// but if they are not specified we fallback to using the default profile
credentials = new BasicAWSCredentials(_bucketOptions.AccessKey, _bucketOptions.SecretKey);
}
#pragma warning restore CS0618 // Type or member is obsolete
}

var client = credentials != null
? new AmazonS3Client(credentials, _bucketOptions.S3Config)
}

var client = credentials != null
? new AmazonS3Client(credentials, _bucketOptions.S3Config)
: new AmazonS3Client(_bucketOptions.S3Config);

using (client)
Expand All @@ -47,14 +47,14 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
{
return _bucketOptions.CustomResponseCheck.Invoke(response)
? HealthCheckResult.Healthy()
: new HealthCheckResult(context.Registration.FailureStatus, description: "Custom response check is not satisfied.");
}
}
return HealthCheckResult.Healthy();
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
: new HealthCheckResult(context.Registration.FailureStatus, description: "Custom response check is not satisfied.");
}
}
return HealthCheckResult.Healthy();
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
68 changes: 34 additions & 34 deletions src/HealthChecks.Azure.IoTHub/IoTHubOptions.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
using Microsoft.Azure.Devices;

namespace HealthChecks.Azure.IoTHub;

public class IoTHubOptions
{
internal string ConnectionString { get; private set; } = null!;
internal bool RegistryReadCheck { get; private set; }
internal bool RegistryWriteCheck { get; private set; }
internal bool ServiceConnectionCheck { get; private set; }
internal string RegistryReadQuery { get; private set; } = null!;
internal Func<string> RegistryWriteDeviceIdFactory { get; private set; } = null!;

namespace HealthChecks.Azure.IoTHub;

public class IoTHubOptions
{
internal string ConnectionString { get; private set; } = null!;
internal bool RegistryReadCheck { get; private set; }
internal bool RegistryWriteCheck { get; private set; }
internal bool ServiceConnectionCheck { get; private set; }
internal string RegistryReadQuery { get; private set; } = null!;
internal Func<string> RegistryWriteDeviceIdFactory { get; private set; } = null!;
internal TransportType ServiceConnectionTransport { get; private set; }

public IoTHubOptions AddConnectionString(string connectionString)
{
ConnectionString = Guard.ThrowIfNull(connectionString);
return this;
}

public IoTHubOptions AddRegistryReadCheck(string query = "SELECT deviceId FROM devices")
{
RegistryReadCheck = true;
RegistryReadQuery = query;
return this;
}

public IoTHubOptions AddRegistryWriteCheck(Func<string>? deviceIdFactory = null)
{
RegistryWriteCheck = true;
RegistryWriteDeviceIdFactory = deviceIdFactory ?? (() => "health-check-registry-write-device-id");
return this;
}

public IoTHubOptions AddServiceConnectionCheck(TransportType transport = TransportType.Amqp)
{
ServiceConnectionCheck = true;
ServiceConnectionTransport = transport;
return this;
}
}
}

public IoTHubOptions AddRegistryReadCheck(string query = "SELECT deviceId FROM devices")
{
RegistryReadCheck = true;
RegistryReadQuery = query;
return this;
}

public IoTHubOptions AddRegistryWriteCheck(Func<string>? deviceIdFactory = null)
{
RegistryWriteCheck = true;
RegistryWriteDeviceIdFactory = deviceIdFactory ?? (() => "health-check-registry-write-device-id");
return this;
}

public IoTHubOptions AddServiceConnectionCheck(TransportType transport = TransportType.Amqp)
{
ServiceConnectionCheck = true;
ServiceConnectionTransport = transport;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ Task CheckWithManagement()
return managementClient.GetQueueRuntimePropertiesAsync(Options.QueueName, cancellationToken);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
}
72 changes: 36 additions & 36 deletions src/HealthChecks.Consul/ConsulHealthCheck.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
using System.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Text;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace HealthChecks.Consul;

public class ConsulHealthCheck : IHealthCheck
{
private readonly ConsulOptions _options;
private readonly Func<HttpClient> _httpClientFactory;

public ConsulHealthCheck(ConsulOptions options, Func<HttpClient> httpClientFactory)
{
_options = Guard.ThrowIfNull(options);
_httpClientFactory = Guard.ThrowIfNull(httpClientFactory);
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace HealthChecks.Consul;

public class ConsulHealthCheck : IHealthCheck
{
private readonly ConsulOptions _options;
private readonly Func<HttpClient> _httpClientFactory;

public ConsulHealthCheck(ConsulOptions options, Func<HttpClient> httpClientFactory)
{
_options = Guard.ThrowIfNull(options);
_httpClientFactory = Guard.ThrowIfNull(httpClientFactory);
}

/// <inheritdoc />
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
var client = _httpClientFactory();
/// <inheritdoc />
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
var client = _httpClientFactory();
if (_options.RequireBasicAuthentication)
{
byte[] credentials = Encoding.ASCII.GetBytes($"{_options.Username}:{_options.Password}");
string authHeaderValue = Convert.ToBase64String(credentials);

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
}
using var result = await client.GetAsync($"{(_options.RequireHttps ? "https" : "http")}://{_options.HostName}:{_options.Port}/v1/status/leader", HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

return result.IsSuccessStatusCode ? HealthCheckResult.Healthy() : new HealthCheckResult(context.Registration.FailureStatus, description: "Consul response was not a successful HTTP status code");
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
{
byte[] credentials = Encoding.ASCII.GetBytes($"{_options.Username}:{_options.Password}");
string authHeaderValue = Convert.ToBase64String(credentials);

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
}
using var result = await client.GetAsync($"{(_options.RequireHttps ? "https" : "http")}://{_options.HostName}:{_options.Port}/v1/status/leader", HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);

return result.IsSuccessStatusCode ? HealthCheckResult.Healthy() : new HealthCheckResult(context.Registration.FailureStatus, description: "Consul response was not a successful HTTP status code");
}
catch (Exception ex)
{
return new HealthCheckResult(context.Registration.FailureStatus, exception: ex);
}
}
}
34 changes: 17 additions & 17 deletions src/HealthChecks.Gcp.CloudFirestore/CloudFirestoreOptions.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using Google.Cloud.Firestore;

namespace HealthChecks.Gcp.CloudFirestore;

using Google.Cloud.Firestore;

namespace HealthChecks.Gcp.CloudFirestore;

/// <summary>
/// Represent options for <see cref="CloudFirestoreHealthCheck"/>.
/// </summary>
public class CloudFirestoreOptions
{
/// <summary>
/// Firestore Cloud database object used in your application.
/// </summary>
public FirestoreDb FirestoreDatabase { get; set; } = null!;

/// <summary>
/// Specify the root collections that needs to exist in the database.
/// </summary>
public string[]? RequiredCollections { get; set; }
}
/// </summary>
public class CloudFirestoreOptions
{
/// <summary>
/// Firestore Cloud database object used in your application.
/// </summary>
public FirestoreDb FirestoreDatabase { get; set; } = null!;

/// <summary>
/// Specify the root collections that needs to exist in the database.
/// </summary>
public string[]? RequiredCollections { get; set; }
}
Loading

0 comments on commit bfc5f64

Please sign in to comment.