Skip to content

Commit fc3decf

Browse files
committed
Renamed settings related to Licensing component's use of RabbitMQ management API
Removed unnecessary LINQ usage when working with DbConnectionStringBuilder in ServiceControlAppConfig
1 parent d276e59 commit fc3decf

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

src/ServiceControlInstaller.Engine/Configuration/ServiceControl/ServiceControlAppConfig.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace ServiceControlInstaller.Engine.Configuration.ServiceControl
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.Data.Common;
65
using System.IO;
7-
using System.Linq;
86
using Instances;
97

108
public class ServiceControlAppConfig : AppConfig
@@ -41,9 +39,9 @@ protected override void UpdateSettings()
4139
settings.RemoveIfRetired(ServiceControlSettings.AuditLogQueue, version);
4240
settings.RemoveIfRetired(ServiceControlSettings.ForwardAuditMessages, version);
4341
settings.RemoveIfRetired(ServiceControlSettings.InternalQueueName, version);
44-
settings.RemoveIfRetired(ServiceControlSettings.RabbitMqManagementApiUrl, version);
45-
settings.RemoveIfRetired(ServiceControlSettings.RabbitMqManagementApiUsername, version);
46-
settings.RemoveIfRetired(ServiceControlSettings.RabbitMqManagementApiPassword, version);
42+
settings.RemoveIfRetired(ServiceControlSettings.LicensingComponentRabbitMqManagementApiUrl, version);
43+
settings.RemoveIfRetired(ServiceControlSettings.LicensingComponentRabbitMqManagementApiUsername, version);
44+
settings.RemoveIfRetired(ServiceControlSettings.LicensingComponentRabbitMqManagementApiPassword, version);
4745

4846
RemoveRavenDB35Settings(settings, version);
4947
}
@@ -71,42 +69,38 @@ public override void SetTransportType(string transportTypeName)
7169

7270
string UpdateConnectionString()
7371
{
74-
var kvpList = new DbConnectionStringBuilder { ConnectionString = details.ConnectionString }
75-
.OfType<KeyValuePair<string, object>>()
76-
.Select(kvp => new KeyValuePair<string, string>(kvp.Key, kvp.Value.ToString()))
77-
.ToList();
72+
var connectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = details.ConnectionString };
7873

79-
MigrateRabbitMqManagementApiSettings(kvpList);
74+
MigrateLicensingComponentRabbitMqManagementApiSettings(connectionStringBuilder);
8075

81-
return string.Join(";", kvpList.Select(kvp => $"{kvp.Key}={kvp.Value}"));
76+
return connectionStringBuilder.ConnectionString;
8277
}
8378

84-
void MigrateRabbitMqManagementApiSettings(IList<KeyValuePair<string, string>> connectionStringPairs)
79+
void MigrateLicensingComponentRabbitMqManagementApiSettings(DbConnectionStringBuilder connectionStringBuilder)
8580
{
86-
if (!details.TransportPackage.Name.Contains("rabbitmq", StringComparison.OrdinalIgnoreCase) ||
87-
connectionStringPairs.Any(kvp => kvp.Key.Equals("ManagementApiUrl", StringComparison.OrdinalIgnoreCase) || kvp.Key.Equals("ManagementApiUserName", StringComparison.OrdinalIgnoreCase)))
81+
if (!details.TransportPackage.Name.Contains("rabbitmq", StringComparison.OrdinalIgnoreCase))
8882
{
8983
return;
9084
}
9185

9286
var settings = Config.AppSettings.Settings;
9387

94-
var legacySetting = settings["LicensingComponent/RabbitMQ/ApiUrl"];
95-
if (legacySetting is not null)
88+
var legacySetting = settings[ServiceControlSettings.LicensingComponentRabbitMqManagementApiUrl.Name];
89+
if (legacySetting is not null && !connectionStringBuilder.ContainsKey("ManagementApiUrl"))
9690
{
97-
connectionStringPairs.Add(new KeyValuePair<string, string>("ManagementApiUrl", legacySetting.Value));
91+
connectionStringBuilder.Add("ManagementApiUrl", legacySetting.Value);
9892
}
9993

100-
legacySetting = settings["LicensingComponent/RabbitMQ/UserName"];
101-
if (legacySetting is not null)
94+
legacySetting = settings[ServiceControlSettings.LicensingComponentRabbitMqManagementApiUsername.Name];
95+
if (legacySetting is not null && !connectionStringBuilder.ContainsKey("ManagementApiUserName"))
10296
{
103-
connectionStringPairs.Add(new KeyValuePair<string, string>("ManagementApiUserName", legacySetting.Value));
97+
connectionStringBuilder.Add("ManagementApiUserName", legacySetting.Value);
10498
}
10599

106-
legacySetting = settings["LicensingComponent/RabbitMQ/Password"];
107-
if (legacySetting is not null)
100+
legacySetting = settings[ServiceControlSettings.LicensingComponentRabbitMqManagementApiPassword.Name];
101+
if (legacySetting is not null && !connectionStringBuilder.ContainsKey("ManagementApiPassword"))
108102
{
109-
connectionStringPairs.Add(new KeyValuePair<string, string>("ManagementApiPassword", legacySetting.Value));
103+
connectionStringBuilder.Add("ManagementApiPassword", legacySetting.Value);
110104
}
111105
}
112106

src/ServiceControlInstaller.Engine/Configuration/ServiceControl/SettingsList.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ public static class ServiceControlSettings
9090
SupportedFrom = new SemanticVersion(4, 17, 0)
9191
};
9292

93-
public static readonly SettingInfo RabbitMqManagementApiUrl = new()
93+
public static readonly SettingInfo LicensingComponentRabbitMqManagementApiUrl = new()
9494
{
9595
Name = "LicensingComponent/RabbitMQ/ApiUrl",
9696
RemovedFrom = new SemanticVersion(6, 5, 0)
9797
};
9898

99-
public static readonly SettingInfo RabbitMqManagementApiUsername = new()
99+
public static readonly SettingInfo LicensingComponentRabbitMqManagementApiUsername = new()
100100
{
101101
Name = "LicensingComponent/RabbitMQ/UserName",
102102
RemovedFrom = new SemanticVersion(6, 5, 0)
103103
};
104104

105-
public static readonly SettingInfo RabbitMqManagementApiPassword = new()
105+
public static readonly SettingInfo LicensingComponentRabbitMqManagementApiPassword = new()
106106
{
107107
Name = "LicensingComponent/RabbitMQ/Password",
108108
RemovedFrom = new SemanticVersion(6, 5, 0)

0 commit comments

Comments
 (0)