Skip to content

Commit 7c672dd

Browse files
Cleanup for SQ
1 parent 08ab184 commit 7c672dd

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed

Sdk/Tasks/DmappCreation.cs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace Skyline.DataMiner.Sdk.Tasks
1717
using Skyline.DataMiner.Sdk.Helpers;
1818
using Skyline.DataMiner.Sdk.SubTasks;
1919

20-
using Path = Alphaleonis.Win32.Filesystem.Path;
2120
using Task = Microsoft.Build.Utilities.Task;
2221

2322
public class DmappCreation : Task, ICancelableTask

Sdk/Tasks/PublishToCatalog.cs

+21-25
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ namespace Skyline.DataMiner.Sdk.Tasks
44
{
55
using System;
66
using System.Diagnostics;
7-
using System.IO.Compression;
87
using System.Threading;
98

109
using Microsoft.Build.Framework;
1110
using Microsoft.Extensions.Configuration;
12-
using Microsoft.Extensions.Configuration.EnvironmentVariables;
13-
using Microsoft.Extensions.Configuration.UserSecrets;
1411

1512
using Nito.AsyncEx.Synchronous;
1613

1714
using Skyline.DataMiner.CICD.FileSystem;
18-
using Skyline.DataMiner.Net.SLConfiguration;
1915
using Skyline.DataMiner.Sdk.CatalogService;
2016

2117
using static Skyline.DataMiner.Sdk.CatalogService.HttpCatalogService;
@@ -30,6 +26,8 @@ public class PublishToCatalog : Task, ICancelableTask
3026

3127
public string BaseOutputPath { get; set; }
3228

29+
public string CatalogPublishKeyName { get; set; }
30+
3331
public string Configuration { get; set; }
3432

3533
public string PackageId { get; set; }
@@ -38,12 +36,10 @@ public class PublishToCatalog : Task, ICancelableTask
3836

3937
public string ProjectDirectory { get; set; }
4038

41-
public string VersionComment { get; set; }
42-
43-
public string CatalogPublishKeyName { get; set; }
44-
4539
public string UserSecretsId { get; set; }
4640

41+
public string VersionComment { get; set; }
42+
4743
#endregion Properties set from targets file
4844

4945
/// <summary>
@@ -82,7 +78,6 @@ public override bool Execute()
8278
Log.LogMessage(MessageImportance.High, $"Found Package: {packagePath}.");
8379
Log.LogMessage(MessageImportance.High, $"Found Catalog Information: {catalogInfoPath}.");
8480

85-
8681
var builder = new ConfigurationBuilder();
8782

8883
if (!String.IsNullOrWhiteSpace(UserSecretsId))
@@ -115,25 +110,26 @@ public override bool Execute()
115110
// Request if Version already exists? If not, then release a new version?
116111
// If Version already exists, update the ReadMe & Images.
117112

118-
var cts = new CancellationTokenSource();
119-
var catalogService = CatalogServiceFactory.CreateWithHttp(new System.Net.Http.HttpClient());
120-
byte[] catalogData = fs.File.ReadAllBytes(catalogInfoPath);
121-
Log.LogMessage(MessageImportance.High, $"Registering Catalog Metadata...");
122-
var catalogResult = catalogService.RegisterCatalogAsync(catalogData, organizationKey, cts.Token).WaitAndUnwrapException();
123-
Log.LogMessage(MessageImportance.High, $"Done");
124-
125-
try
113+
using (var cts = new CancellationTokenSource())
126114
{
127-
Log.LogMessage(MessageImportance.High, $"Uploading new version to {catalogResult.ArtifactId}...");
128-
byte[] packageData = fs.File.ReadAllBytes(packagePath);
129-
catalogService.UploadVersionAsync(packageData, fs.Path.GetFileName(packagePath), organizationKey, catalogResult.ArtifactId, PackageVersion, VersionComment, cts.Token).WaitAndUnwrapException();
115+
var catalogService = CatalogServiceFactory.CreateWithHttp(new System.Net.Http.HttpClient());
116+
byte[] catalogData = fs.File.ReadAllBytes(catalogInfoPath);
117+
Log.LogMessage(MessageImportance.High, $"Registering Catalog Metadata...");
118+
var catalogResult = catalogService.RegisterCatalogAsync(catalogData, organizationKey, cts.Token).WaitAndUnwrapException();
130119
Log.LogMessage(MessageImportance.High, $"Done");
131-
}
132-
catch (VersionAlreadyExistsException)
133-
{
134-
Log.LogWarning("Version already exists! Only catalog details were updated.");
135-
}
136120

121+
try
122+
{
123+
Log.LogMessage(MessageImportance.High, $"Uploading new version to {catalogResult.ArtifactId}...");
124+
byte[] packageData = fs.File.ReadAllBytes(packagePath);
125+
catalogService.UploadVersionAsync(packageData, fs.Path.GetFileName(packagePath), organizationKey, catalogResult.ArtifactId, PackageVersion, VersionComment, cts.Token).WaitAndUnwrapException();
126+
Log.LogMessage(MessageImportance.High, $"Done");
127+
}
128+
catch (VersionAlreadyExistsException)
129+
{
130+
Log.LogWarning("Version already exists! Only catalog details were updated.");
131+
}
132+
}
137133
if (cancel)
138134
{
139135
return false;

0 commit comments

Comments
 (0)