Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
janstaelensskyline committed Oct 8, 2024
2 parents ed4b57e + 3cbc9f9 commit d3c21bb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 45 deletions.
36 changes: 14 additions & 22 deletions CICD.Tools.CatalogUpload.Lib/CatalogMetaDataFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
namespace Skyline.DataMiner.CICD.Tools.CatalogUpload.Lib
{
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

using Skyline.DataMiner.CICD.FileSystem;
Expand All @@ -18,12 +15,12 @@
public class CatalogMetaDataFactory : ICatalogMetaDataFactory
{
/// <summary>
/// Creates a partial CataLogMetaData using any information it can from the artifact itself. Check the items for null and complete.
/// Creates a partial <see cref="CatalogMetaData"/> using any information it can from the artifact itself. Check the items for null and complete.
/// </summary>
/// <param name="pathToArtifact">Path to the artifact.</param>
/// <param name="pathToReadme"></param>
/// <param name="pathToImages"></param>
/// <returns>An instance of <see cref="CatalogMetaData"/>.></returns>
/// <param name="pathToReadme">Optional. The path to the README file. If null, the method will attempt to locate the README.</param>
/// <param name="pathToImages">Optional. The path to the images directory. If null, no images path will be set.</param>
/// <returns>An instance of <see cref="CatalogMetaData"/>.</returns>
/// <exception cref="ArgumentNullException">Provided path should not be null</exception>
/// <exception cref="InvalidOperationException">Expected data was not present in the Artifact.</exception>
public CatalogMetaData FromArtifact(string pathToArtifact, string pathToReadme = null, string pathToImages = null)
Expand All @@ -37,11 +34,11 @@ public CatalogMetaData FromArtifact(string pathToArtifact, string pathToReadme =

if (pathToArtifact.EndsWith(".dmapp", StringComparison.InvariantCultureIgnoreCase))
{
meta = CatalogMetaDataFactory.FromDmapp(pathToArtifact);
meta = FromDmapp(pathToArtifact);
}
else if (pathToArtifact.EndsWith(".dmprotocol", StringComparison.InvariantCultureIgnoreCase))
{
meta = CatalogMetaDataFactory.FromDmprotocol(pathToArtifact);
meta = FromDmprotocol(pathToArtifact);
}
else
{
Expand Down Expand Up @@ -165,8 +162,8 @@ private static CatalogMetaData FromDmapp(string pathToDmapp)
var buildNumber = appInfo.Element("Build")?.Value;
var minimumDmaVersion = appInfo.Element("MinDmaVersion")?.Value;

// cleanup first line from descriptionFromPackage if it contains version. We dont want that hardcoded version when the version might change later.
if (!string.IsNullOrEmpty(description))
// Cleanup first line from descriptionFromPackage if it contains version. We don't want that hardcoded version when the version might change later.
if (!String.IsNullOrEmpty(description))
{
// Split the string by newlines to work with the first line
string[] lines = description.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
Expand All @@ -175,13 +172,13 @@ private static CatalogMetaData FromDmapp(string pathToDmapp)
if (lines[0].Contains("version:", StringComparison.OrdinalIgnoreCase))
{
// Remove the first line and join the remaining lines back into a single string
description = string.Join(Environment.NewLine, lines.Skip(1));
description = String.Join(Environment.NewLine, lines.Skip(1));
}
}

if (!String.IsNullOrWhiteSpace(minimumDmaVersion))
{
description = ($"Minimum DataMiner Version: {minimumDmaVersion}\r\n{description ?? ""}");
description = $"Minimum DataMiner Version: {minimumDmaVersion}\r\n{description ?? ""}";
}

if (!String.IsNullOrWhiteSpace(buildNumber))
Expand Down Expand Up @@ -210,8 +207,6 @@ private static CatalogMetaData FromDmapp(string pathToDmapp)
}

if (description.Length > 500) description = description.Substring(0, 497) + "...";


meta.Version.VersionDescription = description;
meta.ContentType = contentType;
return meta;
Expand Down Expand Up @@ -299,13 +294,10 @@ private static CatalogMetaData FromDmprotocol(string pathToDmprotocol)
var majorXml = systemXml?.Element(ns + "MajorVersions")?.Elements().FirstOrDefault(p => p.Attribute("id")?.Value == major);
var minorXml = majorXml?.Element(ns + "MinorVersions")?.Elements().FirstOrDefault(p => p.Attribute("id")?.Value == minor);

if (minorXml != null)
var allChanges = minorXml?.Element(ns + "Changes")?.Elements().ToList();
if (allChanges != null && allChanges.Any())
{
var allChanges = minorXml.Element(ns + "Changes")?.Elements();
if (allChanges != null && allChanges.Any())
{
versionDescription = string.Join(Environment.NewLine, allChanges.Select(change => $"{change.Name.LocalName}: {change.Value.Trim()}"));
}
versionDescription = String.Join(Environment.NewLine, allChanges.Select(change => $"{change.Name.LocalName}: {change.Value.Trim()}"));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions CICD.Tools.CatalogUpload.Lib/ICatalogMetaDataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
public interface ICatalogMetaDataFactory
{
/// <summary>
/// Creates a partial CataLogMetaData using any information it can from the artifact itself. Check the items for null and complete.
/// Creates a partial <see cref="CatalogMetaData"/> using any information it can from the artifact itself. Check the items for null and complete.
/// </summary>
/// <param name="pathToArtifact">Path to the artifact.</param>
/// <param name="pathToReadme"></param>
/// <param name="pathToImages"></param>
/// <returns>An instance of <see cref="CatalogMetaData"/>.></returns>
/// <exception cref="ArgumentNullException">Provided path should not be null</exception>
/// <param name="pathToReadme">Optional. The path to the README file. If null, the method will attempt to locate the README.</param>
/// <param name="pathToImages">Optional. The path to the images directory. If null, no images path will be set.</param>
/// <returns>An instance of <see cref="CatalogMetaData"/>.</returns>
/// <exception cref="ArgumentNullException">Provided path should not be null.</exception>
/// <exception cref="InvalidOperationException">Expected data was not present in the Artifact.</exception>
public CatalogMetaData FromArtifact(string pathToArtifact, string pathToReadme = null, string pathToImages = null);

Expand Down
4 changes: 0 additions & 4 deletions CICD.Tools.CatalogUpload/OptionalRegistrationArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ internal class OptionalRegistrationArgumentsBinder : BinderBase<OptionalRegistra

private readonly Option<string> uriSourceCode;
private readonly Option<string> overrideVersion;


private readonly Option<string> branch;
private readonly Option<string> committerMail;
private readonly Option<string> releaseUri;
Expand All @@ -64,7 +62,6 @@ public OptionalRegistrationArgumentsBinder(Option<string> uriSourceCode, Option<
this.catalogIdentifier = catalogIdentifier;
}


/// <summary>
/// Retrieves the bound value of <see cref="OptionalRegistrationArguments"/> from the <see cref="BindingContext"/>.
/// </summary>
Expand All @@ -86,6 +83,5 @@ protected override OptionalRegistrationArguments GetBoundValue(BindingContext bi
CatalogIdentifier = bindingContext.ParseResult.GetValueForOption(catalogIdentifier),
};
}

}
}
13 changes: 0 additions & 13 deletions CICD.Tools.CatalogUpload/Program.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
namespace Skyline.DataMiner.CICD.Tools.CatalogUpload
{
using System;
using System.CommandLine;
using System.CommandLine.Binding;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Xml.XPath;

using CICD.Tools.CatalogUpload;

using global::CICD.Tools.CatalogUpload;

using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

using Serilog;
using Serilog.Core;

using Skyline.DataMiner.CICD.FileSystem;
using Skyline.DataMiner.CICD.Tools.CatalogUpload.Lib;
using Skyline.DataMiner.CICD.Tools.Reporter;

using YamlDotNet.Core;

using static System.Net.Mime.MediaTypeNames;

/// <summary>
/// Uploads artifacts to the Skyline DataMiner catalog (https://catalog.dataminer.services).
Expand Down
1 change: 0 additions & 1 deletion CICD.Tools.CatalogUpload/Uploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ private void ApplyOptionalArguments(OptionalRegistrationArguments optionalArgume
metaData.Version.ReleaseUri = optionalArguments.ReleaseUri;
}


if (optionalArguments.CatalogIdentifier != null)
{
logger.LogDebug($"Overriding CatalogIdentifier from '{metaData.CatalogIdentifier}' to '{optionalArguments.CatalogIdentifier}'");
Expand Down

0 comments on commit d3c21bb

Please sign in to comment.