Fixes debug setting health check to correctly indicate no issue if config setting is missing
This commit is contained in:
@@ -43,6 +43,14 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
/// </summary>
|
||||
public abstract ValueComparisonType ValueComparisonType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the flag indicating if the check is considered successful if the config value is missing (defaults to false - an error - if missing)
|
||||
/// </summary>
|
||||
public virtual bool ValidIfConfigMissing
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
protected AbstractConfigCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
|
||||
{
|
||||
_textService = healthCheckContext.ApplicationContext.Services.TextService;
|
||||
@@ -132,11 +140,18 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
|
||||
public override IEnumerable<HealthCheckStatus> GetStatus()
|
||||
{
|
||||
var successMessage = string.Format(CheckSuccessMessage, FileName, XPath, Values, CurrentValue);
|
||||
|
||||
var configValue = _configurationService.GetConfigurationValue();
|
||||
if (configValue.Success == false)
|
||||
{
|
||||
var message = configValue.Result;
|
||||
return new[] { new HealthCheckStatus(message) { ResultType = StatusResultType.Error } };
|
||||
if (ValidIfConfigMissing)
|
||||
{
|
||||
return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } };
|
||||
}
|
||||
|
||||
var errorMessage = configValue.Result;
|
||||
return new[] { new HealthCheckStatus(errorMessage) { ResultType = StatusResultType.Error } };
|
||||
}
|
||||
|
||||
CurrentValue = configValue.Result;
|
||||
@@ -144,8 +159,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
|
||||
var valueFound = Values.Any(value => string.Equals(CurrentValue, value.Value, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (ValueComparisonType == ValueComparisonType.ShouldEqual && valueFound || ValueComparisonType == ValueComparisonType.ShouldNotEqual && valueFound == false)
|
||||
{
|
||||
var message = string.Format(CheckSuccessMessage, FileName, XPath, Values, CurrentValue);
|
||||
return new[] { new HealthCheckStatus(message) { ResultType = StatusResultType.Success } };
|
||||
return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } };
|
||||
}
|
||||
|
||||
// Declare the action for rectifying the config value
|
||||
|
||||
Reference in New Issue
Block a user