-
Notifications
You must be signed in to change notification settings - Fork 0
VCST-3900: Environment settings comparison #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
fe68fcc
Models, setting providers, controller for external requests (draft)
yuskithedeveloper 57f80d3
Models, setting providers
yuskithedeveloper b7ac441
Comments
yuskithedeveloper c89cb63
Api key authorization
yuskithedeveloper c93b0b1
AbstractTypeFactory
yuskithedeveloper 677b923
Compare client, models, controller (draft)
yuskithedeveloper b2004ea
Comparison result, models
yuskithedeveloper c4ad9b7
Hashed api key
yuskithedeveloper 6f3b4a6
Settings comparison
yuskithedeveloper 051a1e2
Api environments list
yuskithedeveloper ff77414
Hashed api key
yuskithedeveloper 8ae3879
App setting sample
yuskithedeveloper a703a44
SettingsCompareService logic
yuskithedeveloper 8e0c0da
environments-list blade
yuskithedeveloper e752d14
environments-comparison blade
yuskithedeveloper fb5ee38
environments-comparison blade
yuskithedeveloper 1bef81d
environments-comparison blade (table layout)
yuskithedeveloper bda6b34
environments-comparison blade, error and scope styles
yuskithedeveloper fa27098
environments-comparison blade, changing comparison base
yuskithedeveloper 58ed2be
environments-comparison blade, changing comparison base
yuskithedeveloper dae9d09
Numbers comparison fix
yuskithedeveloper 65485f9
Refactoring (SonarQube)
yuskithedeveloper 67868e4
Refactoring (SonarQube)
yuskithedeveloper c5497b8
Providers support for multiple setting scopes
yuskithedeveloper 9ce39ec
BOPIS secret setting magic literal removed
yuskithedeveloper 8a36f9c
Secret settings null value handling
yuskithedeveloper 698ca73
Settings ordering
yuskithedeveloper 66654ff
ComparableAppSettingsProvider
yuskithedeveloper ba3bc84
ComparableEnvironmentVariablesProvider
yuskithedeveloper 5b076fb
hosting environment, .net and server info
yuskithedeveloper cf416a1
ComparableModulesProvider
yuskithedeveloper 7cd6616
Minor UI changes
yuskithedeveloper 8a06a42
Not found settings handling
yuskithedeveloper ba5a794
Object setting type values handling
yuskithedeveloper a164139
Showing differences only
yuskithedeveloper 68f5637
Localizations
yuskithedeveloper 58c151a
Minor style changes
yuskithedeveloper fbd8fdd
Readme (by Cursor)
yuskithedeveloper 1e66ea3
Add screenshot to README
yuskithedeveloper a7199e2
Settings group empty name workaround
yuskithedeveloper ece7e92
Merge branch 'feat/VCST-3900-environments-compare-initial' of https:/…
yuskithedeveloper fc0fd2f
Refactoring
yuskithedeveloper 8af0002
Refactoring
yuskithedeveloper 2ee7a8e
No data label
yuskithedeveloper db486c8
Refactoring
yuskithedeveloper d18bab8
Refactoring
yuskithedeveloper 9585d5d
Refactoring
yuskithedeveloper 353fe96
Refactoring
yuskithedeveloper 48a52a8
Export API
yuskithedeveloper 666fbf4
Export blade toolbar button
yuskithedeveloper e1c4c1e
README.md
yuskithedeveloper 9dde791
Empty appSettings.json section handling
yuskithedeveloper 5944bbf
Add setup and usage guide to README
OlegoO 6b9a82f
Refactor authentication to use Virto Commerce API key-based authentic…
OlegoO 0430038
feat: Add ComparableStoreSettingsProvider to retrieve and compare store
OlegoO 541de19
feat: Add configuration whitelist and refactor settings.
OlegoO d53a917
Refactor CSS and update environments-list.js
OlegoO f44dd5a
fix: Add search feature and update permissions.
OlegoO 60f9bdf
settings and ui refactoring
OlegoO 76008bc
Update README with new screenshots
OlegoO 5a3c16c
Update README for environment configuration changes
OlegoO 22ff6ae
Refactor EnvironmentResponseItem instantiation.
OlegoO 1963c98
feat: Add environment settings view
OlegoO 829714d
Add setting descriptions and toggle functionality.
OlegoO 92cb34e
Update yaml settings in README.md
kutasinaelena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Empty file.
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparableEnvironment.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparableEnvironment | ||
| { | ||
| public string Name { get; set; } | ||
|
|
||
| public string Url { get; set; } | ||
|
|
||
| public string ApiKey { get; set; } | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparableEnvironmentSettings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparableEnvironmentSettings | ||
| { | ||
| public string EnvironmentName { get; set; } | ||
|
|
||
| public IList<ComparableSettingScope> SettingScopes { get; set; } = new List<ComparableSettingScope>(); | ||
|
|
||
| public string ErrorMessage { get; set; } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparableSetting.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparableSetting | ||
| { | ||
| public string Name { get; set; } | ||
|
|
||
| public object Value { get; set; } | ||
|
|
||
| public bool IsSecret { get; set; } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparableSettingGroup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparableSettingGroup | ||
| { | ||
| public string GroupName { get; set; } | ||
|
|
||
| public IList<ComparableSetting> Settings { get; set; } = new List<ComparableSetting>(); | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparableSettingScope.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparableSettingScope | ||
| { | ||
| /// <summary> | ||
| /// Scope of the settings, e.g. "Platform", "AppSettings" | ||
| /// </summary> | ||
| public string ScopeName { get; set; } | ||
|
|
||
| public string ProviderName { get; set; } | ||
|
|
||
| public string ErrorMessage { get; set; } | ||
|
|
||
| public IList<ComparableSettingGroup> SettingGroups { get; set; } = new List<ComparableSettingGroup>(); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparedEnvironmentSetting.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparedEnvironmentSetting | ||
| { | ||
| public string Name { get; set; } | ||
|
|
||
| public IList<ComparedEnvironmentSettingValue> ComparedValues { get; set; } = new List<ComparedEnvironmentSettingValue>(); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparedEnvironmentSettingGroup.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparedEnvironmentSettingGroup | ||
| { | ||
| public string GroupName { get; set; } | ||
|
|
||
| public IList<ComparedEnvironmentSetting> Settings { get; set; } = new List<ComparedEnvironmentSetting>(); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparedEnvironmentSettingScope.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparedEnvironmentSettingScope | ||
| { | ||
| public string ScopeName { get; set; } | ||
|
|
||
| public IList<ComparedEnvironmentSettingGroup> SettingGroups { get; set; } = new List<ComparedEnvironmentSettingGroup>(); | ||
| } |
12 changes: 12 additions & 0 deletions
12
src/VirtoCommerce.EnvironmentsCompare.Core/Models/ComparedEnvironmentSettingValue.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class ComparedEnvironmentSettingValue | ||
| { | ||
| public string EnvironmentName { get; set; } | ||
|
|
||
| public object Value { get; set; } | ||
|
|
||
| public bool EqualsBaseValue { get; set; } | ||
|
|
||
| public string ErrorMessage { get; set; } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/VirtoCommerce.EnvironmentsCompare.Core/Models/SettingsComparisonResult.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| public class SettingsComparisonResult | ||
| { | ||
| public IList<ComparedEnvironmentSettingScope> SettingScopes { get; set; } = new List<ComparedEnvironmentSettingScope>(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Services/IComparableSettingsMasterProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
|
|
||
| public interface IComparableSettingsMasterProvider | ||
| { | ||
| Task<IList<ComparableSettingScope>> GetAllComparableSettingsAsync(); | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/VirtoCommerce.EnvironmentsCompare.Core/Services/IComparableSettingsProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
|
|
||
| public interface IComparableSettingsProvider | ||
| { | ||
| Task<ComparableSettingScope> GetComparableSettingsAsync(); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Services/IEnvironmentsCompareClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
|
|
||
| public interface IEnvironmentsCompareClient | ||
| { | ||
| Task<IList<ComparableEnvironmentSettings>> GetSettingsAsync(IList<ComparableEnvironment> comparableEnvironments); | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Services/IEnvironmentsCompareSettingsService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
|
|
||
| public interface IEnvironmentsCompareSettingsService | ||
| { | ||
| string SelfApiKey { get; } | ||
| IList<ComparableEnvironment> ComparableEnvironments { get; } | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/VirtoCommerce.EnvironmentsCompare.Core/Services/ISettingsCompareService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
|
|
||
| public interface ISettingsCompareService | ||
| { | ||
| Task<SettingsComparisonResult> CompareAsync(IList<string> environmentNames, string baseEnvironmentName = null); | ||
| } |
Empty file.
39 changes: 39 additions & 0 deletions
39
src/VirtoCommerce.EnvironmentsCompare.Data/Services/ComparableAppSettingsProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.Configuration; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
| using VirtoCommerce.Platform.Core.Common; | ||
| using VirtoCommerce.Platform.Core.Settings; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Data.Services; | ||
|
|
||
| public class ComparableAppSettingsProvider(IConfiguration configuration) : IComparableSettingsProvider | ||
| { | ||
| public Task<ComparableSettingScope> GetComparableSettingsAsync() | ||
| { | ||
| var result = AbstractTypeFactory<ComparableSettingScope>.TryCreateInstance(); | ||
| result.ScopeName = "AppSettings"; | ||
|
|
||
| var connectionStringsGroup = AbstractTypeFactory<ComparableSettingGroup>.TryCreateInstance(); | ||
| connectionStringsGroup.GroupName = "ConnectionStrings"; | ||
| result.SettingGroups.Add(connectionStringsGroup); | ||
|
|
||
| var connectionStringSetting = AbstractTypeFactory<ComparableSetting>.TryCreateInstance(); | ||
| connectionStringSetting.Name = "ConnectionStrings.VirtoCommerce"; | ||
| connectionStringSetting.Value = configuration.GetValue<string>("ConnectionStrings:VirtoCommerce"); | ||
| connectionStringSetting.IsSecret = true; | ||
| connectionStringsGroup.Settings.Add(connectionStringSetting); | ||
|
|
||
| var virtoCommerceGroup = AbstractTypeFactory<ComparableSettingGroup>.TryCreateInstance(); | ||
| virtoCommerceGroup.GroupName = "VirtoCommerce"; | ||
| result.SettingGroups.Add(virtoCommerceGroup); | ||
|
|
||
| var licenseActivationUrlSetting = AbstractTypeFactory<ComparableSetting>.TryCreateInstance(); | ||
| licenseActivationUrlSetting.Name = "VirtoCommerce.LicenseActivationUrl"; | ||
| licenseActivationUrlSetting.Value = configuration.GetValue<string>("VirtoCommerce:LicenseActivationUrl"); | ||
| licenseActivationUrlSetting.IsSecret = false; | ||
| virtoCommerceGroup.Settings.Add(licenseActivationUrlSetting); | ||
|
|
||
| return Task.FromResult(result); | ||
| } | ||
| } |
78 changes: 78 additions & 0 deletions
78
src/VirtoCommerce.EnvironmentsCompare.Data/Services/ComparablePlatformSettingsProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
| using VirtoCommerce.Platform.Core.Common; | ||
| using VirtoCommerce.Platform.Core.Settings; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Data.Services; | ||
|
|
||
| public class ComparablePlatformSettingsProvider(ISettingsManager settingsManager) : IComparableSettingsProvider | ||
| { | ||
| public async Task<ComparableSettingScope> GetComparableSettingsAsync() | ||
| { | ||
| var result = AbstractTypeFactory<ComparableSettingScope>.TryCreateInstance(); | ||
| result.ScopeName = "PlatformSettings"; | ||
|
|
||
| foreach (var group in settingsManager.AllRegisteredSettings | ||
| .Where(x => !x.GroupName.IsNullOrEmpty()) | ||
| .GroupBy(x => x.GroupName)) | ||
| { | ||
| var resultGroup = AbstractTypeFactory<ComparableSettingGroup>.TryCreateInstance(); | ||
| resultGroup.GroupName = group.Key; | ||
| result.SettingGroups.Add(resultGroup); | ||
|
|
||
| foreach (var setting in group) | ||
| { | ||
| var resultSetting = AbstractTypeFactory<ComparableSetting>.TryCreateInstance(); | ||
| resultSetting.Name = setting.Name; | ||
| resultSetting.Value = await GetSettingValueAsync(setting); | ||
| resultSetting.IsSecret = IsSettingSecret(setting); | ||
| resultGroup.Settings.Add(resultSetting); | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| protected async Task<object> GetSettingValueAsync(SettingDescriptor settingDescriptor) | ||
| { | ||
| if (settingDescriptor.ValueType == SettingValueType.Boolean) | ||
| { | ||
| return await settingsManager.GetValueAsync<bool>(settingDescriptor); | ||
| } | ||
|
|
||
| if (settingDescriptor.ValueType == SettingValueType.Integer || settingDescriptor.ValueType == SettingValueType.PositiveInteger) | ||
| { | ||
| return await settingsManager.GetValueAsync<int>(settingDescriptor); | ||
| } | ||
|
|
||
| if (settingDescriptor.ValueType == SettingValueType.Decimal) | ||
| { | ||
| return await settingsManager.GetValueAsync<decimal>(settingDescriptor); | ||
| } | ||
|
|
||
| if (settingDescriptor.ValueType == SettingValueType.DateTime) | ||
| { | ||
| return await settingsManager.GetValueAsync<DateTime>(settingDescriptor); | ||
| } | ||
|
|
||
| if (settingDescriptor.ValueType == SettingValueType.Json) | ||
| { | ||
| return await settingsManager.GetValueAsync<string>(settingDescriptor); | ||
| } | ||
|
|
||
| if ((settingDescriptor.ValueType == SettingValueType.SecureString || settingDescriptor.ValueType == SettingValueType.ShortText || settingDescriptor.ValueType == SettingValueType.LongText)) | ||
| { | ||
| return await settingsManager.GetValueAsync<string>(settingDescriptor); | ||
| } | ||
|
|
||
| return null;//TODO: handle other types | ||
| } | ||
|
|
||
| protected virtual bool IsSettingSecret(SettingDescriptor setting) | ||
| { | ||
| return setting.ValueType == SettingValueType.SecureString || setting.Name.EqualsIgnoreCase("Shipping.Bopis.GoogleMaps.ApiKey");//TODO: implement some flag in SettingDescriptor | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
src/VirtoCommerce.EnvironmentsCompare.Data/Services/ComparableSettingsMasterProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Models; | ||
| using VirtoCommerce.EnvironmentsCompare.Core.Services; | ||
| using VirtoCommerce.Platform.Core.Common; | ||
|
|
||
| namespace VirtoCommerce.EnvironmentsCompare.Data.Services; | ||
|
|
||
| public class ComparableSettingsMasterProvider(IEnumerable<IComparableSettingsProvider> comparableSettingsProviders) : IComparableSettingsMasterProvider | ||
| { | ||
| public async Task<IList<ComparableSettingScope>> GetAllComparableSettingsAsync() | ||
| { | ||
| var result = new List<ComparableSettingScope>(); | ||
|
|
||
| foreach (var provider in comparableSettingsProviders) | ||
| { | ||
| result.Add(await GetSettingsFromProviderAsync(provider)); | ||
| } | ||
|
|
||
| HideSecretSettings(result.SelectMany(x => x.SettingGroups).SelectMany(x => x.Settings)); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| protected async Task<ComparableSettingScope> GetSettingsFromProviderAsync(IComparableSettingsProvider comparableSettingsProvider) | ||
| { | ||
| ComparableSettingScope result; | ||
|
|
||
| try | ||
| { | ||
| result = await comparableSettingsProvider.GetComparableSettingsAsync(); | ||
|
|
||
| if (result == null) | ||
| { | ||
| throw new InvalidOperationException("The provider returned null settings group"); | ||
| } | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| result = AbstractTypeFactory<ComparableSettingScope>.TryCreateInstance(); | ||
| result.ErrorMessage = ex.Message; | ||
| } | ||
|
|
||
| result.ProviderName = comparableSettingsProvider.GetType().FullName; | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| protected virtual void HideSecretSettings(IEnumerable<ComparableSetting> settings) | ||
| { | ||
| foreach (var setting in settings.Where(x => x.IsSecret)) | ||
| { | ||
| setting.Value = $"HASH: {setting.Value?.GetSHA1Hash()}"; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.