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

Allow multiple feedConfigs per category when publishing from manifests #3693

Merged
merged 1 commit into from
Aug 15, 2019
Merged
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
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