Skip to content

Commit

Permalink
Fixes format warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidJGapCR committed Sep 27, 2024
1 parent 75240db commit fbb87dc
Show file tree
Hide file tree
Showing 88 changed files with 253 additions and 368 deletions.
10 changes: 8 additions & 2 deletions src/EdFi.Tools.ApiPublisher.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using EdFi.Tools.ApiPublisher.Core.Registration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Polly.RateLimit;
using Serilog;
using System;
using System.Collections.Generic;
Expand All @@ -22,8 +23,8 @@
using System.Threading.Tasks;

namespace EdFi.Tools.ApiPublisher.Cli
{
internal class Program
{
internal class Program
{
private static readonly ILogger _logger = Log.ForContext(typeof(Program));

Expand Down Expand Up @@ -174,6 +175,11 @@ private static async Task<int> Main(string[] args)
_logger.Information($"Processing complete.");
return 0;
}
catch (RateLimitRejectedException ex)
{
_logger.Fatal(ex, ex.Message);
return -1;
}
catch (Exception ex)
{
_logger.Error($"Processing failed: {string.Join(" ", GetExceptionMessages(ex))}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private async Task<JObject> GetParameterValueAsync(
string sourceConnectionName)
{
string parameterName = $"{ConfigurationStoreHelper.Key(sourceConnectionName)}/lastChangeVersionsProcessed";

var getRequest = new GetParameterRequest
{
Name = parameterName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace EdFi.Tools.ApiPublisher.ConfigurationStore.Aws;
public class Plugin : IPlugin
{
private const string ConfigurationProviderName = "awsParameterStore";

public void ApplyConfiguration(string[] args, IConfigurationBuilder configBuilder)
{
// Nothing to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.Plaintext
{
public class PlainTextJsonFileNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
public class PlainTextJsonFileNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
{
public ApiConnectionDetails GetNamedApiConnectionDetails(
string apiConnectionName,
Expand All @@ -18,9 +18,9 @@ public ApiConnectionDetails GetNamedApiConnectionDetails(
var config = new ConfigurationBuilder()
.AddJsonFile("plainTextNamedConnections.json")
.Build();

var connections = config.Get<PlainTextNamedConnectionConfiguration>();

return connections.Connections?
.Where(details => details.Name != null)
.FirstOrDefault(details => details.Name!.Equals(apiConnectionName, StringComparison.OrdinalIgnoreCase))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.Plaintext
{
internal class PlainTextNamedConnectionConfiguration
internal class PlainTextNamedConnectionConfiguration
{
public ApiConnectionDetails[] Connections { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.Plaintext
{
public class PlaintextChangeVersionProcessedWriter : IChangeVersionProcessedWriter
public class PlaintextChangeVersionProcessedWriter : IChangeVersionProcessedWriter
{
private readonly ILogger _logger = Log.Logger.ForContext(typeof(PlaintextChangeVersionProcessedWriter));

public Task SetProcessedChangeVersionAsync(
string sourceConnectionName,
string targetConnectionName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.Configuration
{
public static class ConfigurationBuilderExtensions
public static class ConfigurationBuilderExtensions
{
public static IConfigurationBuilder AddConfigurationStoreForPostgreSql(
this IConfigurationBuilder builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql.Modules
{
public class PluginModule : Module
public class PluginModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<PostgreSqlConfigurationChangeVersionProcessedWriter>()
.As<IChangeVersionProcessedWriter>()
.SingleInstance();

builder.RegisterType<PostgreSqlConfigurationNamedApiConnectionDetailsReader>()
.As<INamedApiConnectionDetailsReader>()
.SingleInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql;
public class Plugin : IPlugin
{
private const string ConfigurationProviderName = "postgreSql";

public void ApplyConfiguration(string[] args, IConfigurationBuilder configBuilder)
{
// Nothing to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgreSqlConfigurationChangeVersionProcessedWriter : IChangeVersionProcessedWriter
public class PostgreSqlConfigurationChangeVersionProcessedWriter : IChangeVersionProcessedWriter
{
public async Task SetProcessedChangeVersionAsync(
string sourceConnectionName,
Expand All @@ -37,7 +37,7 @@ public async Task SetProcessedChangeVersionAsync(
postgresConfiguration.ConnectionString,
postgresConfiguration.EncryptionPassword,
ConfigurationStoreHelper.Key(sourceConnectionName));

var currentParameter = new JObject();

if (configurationValues.TryGetValue("lastChangeVersionsProcessed", out string changeVersionsJson))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgreSqlConfigurationNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
public class PostgreSqlConfigurationNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
{
public ApiConnectionDetails GetNamedApiConnectionDetails(
string apiConnectionName,
IConfigurationSection configurationStoreSection)
{
var postgresConfiguration = configurationStoreSection.Get<PostgresConfigurationStore>().PostgreSql;
if (string.IsNullOrWhiteSpace(postgresConfiguration?.EncryptionPassword))

if (string.IsNullOrWhiteSpace(postgresConfiguration?.EncryptionPassword))
{
throw new Exception("The PostgreSQL Configuration Store encryption key for storing API keys and secrets was not provided.");
}

// Load named connection information from PostgreSQL configuration store
var config = new ConfigurationBuilder()
.AddConfigurationStoreForPostgreSql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgreSqlConfigurationProvider : ConfigurationProvider
public class PostgreSqlConfigurationProvider : ConfigurationProvider
{
private readonly PostgreSqlConfigurationSource _postgreSqlConfigurationSource;

Expand All @@ -20,8 +20,8 @@ public override void Load()
{
var settings = new PostgreSqlConfigurationValuesProvider()
.GetConfigurationValues(
_postgreSqlConfigurationSource.ConnectionString,
_postgreSqlConfigurationSource.EncryptionPassword,
_postgreSqlConfigurationSource.ConnectionString,
_postgreSqlConfigurationSource.EncryptionPassword,
_postgreSqlConfigurationSource.ConfigurationKeyPrefix);

Data = settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgreSqlConfigurationSource : IConfigurationSource
public class PostgreSqlConfigurationSource : IConfigurationSource
{
public string ConfigurationKeyPrefix { get; }
public string ConnectionString { get; }
Expand All @@ -20,7 +20,7 @@ public PostgreSqlConfigurationSource(string configurationKeyPrefix, string conne
ConnectionString = connectionString;
EncryptionPassword = encryptionPassword;
}

public IConfigurationProvider Build(IConfigurationBuilder builder)
{
return new PostgreSqlConfigurationProvider(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgreSqlConfigurationValuesProvider
public class PostgreSqlConfigurationValuesProvider
{
public IDictionary<string, string> GetConfigurationValues(
string connectionString,
string encryptionPassword,
string connectionString,
string encryptionPassword,
string configurationKeyPrefix)
{
using var conn = new NpgsqlConnection(connectionString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.PostgreSql
{
public class PostgresConfigurationStore
public class PostgresConfigurationStore
{
public PostgresConfiguration PostgreSql { get; set; }
}

public class PostgresConfiguration
public class PostgresConfiguration
{
public string ConnectionString { get; set; }
public string EncryptionPassword { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.Configuration
{
public static class ConfigurationBuilderExtensions
public static class ConfigurationBuilderExtensions
{
public static IConfigurationBuilder AddConfigurationStoreForSqlServer(
this IConfigurationBuilder builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer.Modules
{
public class PluginModule : Module
public class PluginModule : Module
{
protected override void Load(ContainerBuilder builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer;
public class Plugin : IPlugin
{
private const string ConfigurationProviderName = "sqlServer";

public void ApplyConfiguration(string[] args, IConfigurationBuilder configBuilder)
{
// Nothing to do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer
{
public class SqlServerConfigurationStore
public class SqlServerConfigurationStore
{
public SqlServerConfiguration SqlServer { get; set; }
}

public class SqlServerConfiguration
{
public string ConnectionString { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer
{
public class SqlServerConfigurationChangeVersionProcessedWriter : IChangeVersionProcessedWriter
public class SqlServerConfigurationChangeVersionProcessedWriter : IChangeVersionProcessedWriter
{
public async Task SetProcessedChangeVersionAsync(
string sourceConnectionName,
Expand Down Expand Up @@ -44,7 +44,7 @@ public async Task SetProcessedChangeVersionAsync(
using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SingleRow).ConfigureAwait(false))
{
var currentParameter = new JObject();

if (await reader.ReadAsync().ConfigureAwait(false))
{
string changeVersionsJson = reader.GetString("ConfigurationValue");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer
{
public class SqlServerConfigurationNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
public class SqlServerConfigurationNamedApiConnectionDetailsReader : INamedApiConnectionDetailsReader
{
public ApiConnectionDetails GetNamedApiConnectionDetails(
string apiConnectionName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer
{
public class SqlServerConfigurationProvider : ConfigurationProvider
public class SqlServerConfigurationProvider : ConfigurationProvider
{
private readonly SqlServerConfigurationSource _sqlServerConfigurationSource;

Expand Down Expand Up @@ -51,7 +51,7 @@ public override void Load()
{
key = key.Substring(_sqlServerConfigurationSource.ConfigurationKey.Length);
}

settings.Add(key, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace EdFi.Tools.ApiPublisher.ConfigurationStore.SqlServer
{
public class SqlServerConfigurationSource : IConfigurationSource
public class SqlServerConfigurationSource : IConfigurationSource
{
public string ConfigurationKey { get; }
public string ConnectionString { get; }
Expand All @@ -18,7 +18,7 @@ public SqlServerConfigurationSource(string configurationKey, string connectionSt
ConfigurationKey = configurationKey.TrimEnd('/') + '/';
ConnectionString = connectionString;
}

public IConfigurationProvider Build(IConfigurationBuilder builder)
{
return new SqlServerConfigurationProvider(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ public async Task<IEnumerable<StreamResourcePageMessage<TProcessDataMessage>>> P

pageMessages.Add(pageMessage);
offsetOnWindow -= limit;
if (isLastOne)
break;
if (offsetOnWindow < 0)
{
limitOnWindow = limit + (int)offsetOnWindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace EdFi.Tools.ApiPublisher.Connections.Sqlite.Configuration;
public class SqliteConnectionDetails : SourceConnectionDetailsBase, ITargetConnectionDetails
{
public string File { get; set; }

public override bool IsFullyDefined() => !string.IsNullOrEmpty(File);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public SavePublishingOperationMetadataFinalizationActivity(
_publishingOperationMetadataCollector = publishingOperationMetadataCollector;
_createConnection = createConnection;
}

public async Task Execute()
{
await using var connection = _createConnection();

await connection.OpenAsync();

await CreatePublishingMetadataTableAsync();
Expand Down Expand Up @@ -73,11 +73,11 @@ async Task SavePublishingOperationMetadataAsync()
INSERT INTO PublishingMetadata(CurrentChangeVersion, SourceVersionMetadata, TargetVersionMetadata, MinChangeVersion, MaxChangeVersion)
VALUES ($changeVersion, $sourceVersionMetadata, $targetVersionMetadata, $minChangeVersion, $maxChangeVersion);";

cmd.Parameters.AddWithValue("$changeVersion", metadata.CurrentChangeVersion ?? (object) DBNull.Value);
cmd.Parameters.AddWithValue("$sourceVersionMetadata", metadata.SourceVersionMetadata?.ToString() ?? (object) DBNull.Value);
cmd.Parameters.AddWithValue("$targetVersionMetadata", metadata.TargetVersionMetadata?.ToString() ?? (object) DBNull.Value);
cmd.Parameters.AddWithValue("$minChangeVersion", metadata.ChangeWindow?.MinChangeVersion ?? (object) DBNull.Value);
cmd.Parameters.AddWithValue("$maxChangeVersion", metadata.ChangeWindow?.MaxChangeVersion ?? (object) DBNull.Value);
cmd.Parameters.AddWithValue("$changeVersion", metadata.CurrentChangeVersion ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("$sourceVersionMetadata", metadata.SourceVersionMetadata?.ToString() ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("$targetVersionMetadata", metadata.TargetVersionMetadata?.ToString() ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("$minChangeVersion", metadata.ChangeWindow?.MinChangeVersion ?? (object)DBNull.Value);
cmd.Parameters.AddWithValue("$maxChangeVersion", metadata.ChangeWindow?.MaxChangeVersion ?? (object)DBNull.Value);

await cmd.ExecuteNonQueryAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<JObject> GetVersionMetadata()

if (rawValue != null)
{
return JObject.Parse((string) rawValue);
return JObject.Parse((string)rawValue);
}

return null;
Expand Down
Loading

0 comments on commit fbb87dc

Please sign in to comment.