Skip to content
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

Added custom mapping for new format in TfsNodeStructureTool #2350

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@ public sealed class TfsNodeStructureToolOptions : ToolOptions, ITfsNodeStructure
/// Rules to apply to the Area Path. Is an object of NodeOptions e.g. { "Filters": ["*/**"], "Mappings": { "^oldProjectName([\\\\]?.*)$": "targetProjectA$1", } }
/// </summary>
/// <default>{"Filters": [], "Mappings": { "^migrationSource1([\\\\]?.*)$": "MigrationTest5$1" })</default>
public NodeOptions Areas { get; set; }
public NodeOptions Areas { get; set; } = new NodeOptions
{
Filters = new List<string>(),
Mappings = new Dictionary<string, string>()
};

/// <summary>
/// Rules to apply to the Area Path. Is an object of NodeOptions e.g. { "Filters": ["*/**"], "Mappings": { "^oldProjectName([\\\\]?.*)$": "targetProjectA$1", } }
/// </summary>
/// <default>{"Filters": [], "Mappings": { "^migrationSource1([\\\\]?.*)$": "MigrationTest5$1" })</default>
public NodeOptions Iterations { get; set; }
public NodeOptions Iterations { get; set; } = new NodeOptions
{
Filters = new List<string>(),
Mappings = new Dictionary<string, string>()
};

/// <summary>
/// When set to True the susyem will try to create any missing missing area or iteration paths from the revisions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"Upgrade": {
"commandName": "Project",
"commandLineArgs": "upgrade -c \"C:\\Users\\MartinHinshelwoodNKD\\source\\repos\\azure-devops-migration-tools\\docs\\_includes\\sampleConfig\\configuration-full.json\" --debugTrace"
"commandLineArgs": "upgrade -c \"C:\\Users\\MartinHinshelwoodNKD\\source\\Danlewis3.json\" --debugTrace"
},
"Execute Classic": {
"commandName": "Project",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public static void AddConfiguredEndpoints(this IServiceCollection services, ICon
{
var endpointName = endpointConfig.Key;
var endpointType = endpointConfig.GetValue<string>("EndpointType");
if (string.IsNullOrEmpty(endpointType))
{
Log.Warning("Endpoint '{EndpointName}' does not have a type configured. Skipping.", endpointName);
continue;
}
AddEndPointSingleton(services, configuration, endpointConfig, endpointName, endpointType);
}
}
Expand Down
37 changes: 37 additions & 0 deletions src/MigrationTools/Options/OptionsConfigurationUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Reflection;
Expand All @@ -24,6 +25,7 @@
using MigrationTools.Processors.Infrastructure;
using MigrationTools.Services;
using Newtonsoft.Json.Linq;
using static System.Collections.Specialized.BitVector32;

namespace MigrationTools.Options
{
Expand Down Expand Up @@ -153,12 +155,47 @@ private List<IOptions> ParseSectionCollectionWithTypePropertyNameToList(IConfigu
_logger.LogDebug("Upgrading {group} item {old} to {new}", path, optionTypeString, newOptionTypeString);
var option = GetOptionWithDefaults(configuration, newOptionTypeString);
childSection.Bind(option);
switch (optionTypeString)
{
case "TfsNodeStructureOptions":
MapTfsNodeStructureOptions(childSection, option);
_logger.LogWarning("Empty type string found in {path}", path);
break;
default:
break;
}


options.Add(option);
}

return options;
}

private void MapTfsNodeStructureOptions(IConfigurationSection section, dynamic option)
{
// Map AreaMaps from the old structure to the new Areas.Mappings
var areaMaps = section.GetSection("AreaMaps").GetChildren();
foreach (var areaMap in areaMaps)
{
var key = areaMap.Key;
var value = areaMap.Value;
option.Areas.Mappings.Add(key, value);
}

// Map IterationMaps from the old structure to the new Iterations.Mappings
var iterationMaps = section.GetSection("IterationMaps").GetChildren();
foreach (var iterationMap in iterationMaps)
{
var key = iterationMap.Key;
var value = iterationMap.Value;
option.Iterations.Mappings.Add(key, value);
}
// Now map the intermediate structure back into the original `option` object
_logger.LogDebug("Mapped TfsNodeStructureOptions to TfsNodeStructureTool structure and updated the options object.");
}


private List<IOptions> ParseV1FieldMaps(IConfiguration configuration)
{
List<IOptions> options = new List<IOptions>();
Expand Down
Loading