Skip to content

Commit

Permalink
Allow multiple feedConfigs per category when publishing from manifests (
Browse files Browse the repository at this point in the history
  • Loading branch information
riarenas authored and JohnTortugo committed Aug 15, 2019
1 parent 26f4a39 commit dd41d5b
Showing 1 changed file with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class PublishArtifactsInManifest : MSBuild.Task
[Required]
public string NugetPath { get; set; }

private readonly Dictionary<string, FeedConfig> FeedConfigs = new Dictionary<string, FeedConfig>();
private readonly Dictionary<string, List<FeedConfig>> FeedConfigs = new Dictionary<string, List<FeedConfig>>();

private readonly Dictionary<string, List<PackageArtifactModel>> PackagesByCategory = new Dictionary<string, List<PackageArtifactModel>>();

Expand Down Expand Up @@ -138,7 +138,12 @@ public async Task<bool> ExecuteAsync()
Log.LogError($"Invalid FeedConfig entry. TargetURL='{feedConfig.TargetFeedURL}' Type='{feedConfig.Type}' Token='{feedConfig.FeedKey}'");
}

FeedConfigs.Add(fc.ItemSpec.Trim().ToUpper(), feedConfig);
string categoryKey = fc.ItemSpec.Trim().ToUpper();
if (!FeedConfigs.TryGetValue(categoryKey, out var feedsList))
{
FeedConfigs[categoryKey] = new List<FeedConfig>();
}
FeedConfigs[categoryKey].Add(feedConfig);
}

// Return errors from parsing FeedConfig
Expand Down Expand Up @@ -168,21 +173,24 @@ private async Task HandlePackagePublishingAsync(IMaestroApi client, Maestro.Clie
var category = packagesPerCategory.Key;
var packages = packagesPerCategory.Value;

if (FeedConfigs.TryGetValue(category, out FeedConfig feedConfig))
if (FeedConfigs.TryGetValue(category, out List<FeedConfig> feedConfigsForCategory))
{
var feedType = feedConfig.Type.ToUpper();

if (feedType.Equals("AZDONUGETFEED"))
{
await PublishPackagesToAzDoNugetFeedAsync(packages, client, buildInformation, feedConfig);
}
else if (feedType.Equals("AZURESTORAGEFEED"))
{
await PublishPackagesToAzureStorageNugetFeedAsync(packages, client, buildInformation, feedConfig);
}
else
foreach (var feedConfig in feedConfigsForCategory)
{
Log.LogError($"Unknown target feed type for category '{category}': '{feedType}'.");
var feedType = feedConfig.Type.ToUpper();

if (feedType.Equals("AZDONUGETFEED"))
{
await PublishPackagesToAzDoNugetFeedAsync(packages, client, buildInformation, feedConfig);
}
else if (feedType.Equals("AZURESTORAGEFEED"))
{
await PublishPackagesToAzureStorageNugetFeedAsync(packages, client, buildInformation, feedConfig);
}
else
{
Log.LogError($"Unknown target feed type for category '{category}': '{feedType}'.");
}
}
}
else
Expand All @@ -199,21 +207,24 @@ private async Task HandleBlobPublishingAsync(IMaestroApi client, Maestro.Client.
var category = blobsPerCategory.Key;
var blobs = blobsPerCategory.Value;

if (FeedConfigs.TryGetValue(category, out FeedConfig feedConfig))
if (FeedConfigs.TryGetValue(category, out List<FeedConfig> feedConfigsForCategory))
{
var feedType = feedConfig.Type.ToUpper();

if (feedType.Equals("AZDONUGETFEED"))
{
await PublishBlobsToAzDoNugetFeedAsync(blobs, client, buildInformation, feedConfig);
}
else if (feedType.Equals("AZURESTORAGEFEED"))
{
await PublishBlobsToAzureStorageNugetFeedAsync(blobs, client, buildInformation, feedConfig);
}
else
foreach (var feedConfig in feedConfigsForCategory)
{
Log.LogError($"Unknown target feed type for category '{category}': '{feedType}'.");
var feedType = feedConfig.Type.ToUpper();

if (feedType.Equals("AZDONUGETFEED"))
{
await PublishBlobsToAzDoNugetFeedAsync(blobs, client, buildInformation, feedConfig);
}
else if (feedType.Equals("AZURESTORAGEFEED"))
{
await PublishBlobsToAzureStorageNugetFeedAsync(blobs, client, buildInformation, feedConfig);
}
else
{
Log.LogError($"Unknown target feed type for category '{category}': '{feedType}'.");
}
}
}
else
Expand Down

0 comments on commit dd41d5b

Please sign in to comment.