Skip to content

Commit d90861e

Browse files
Access to Actions/Variables made optional. Only works when there is a PAT.
1 parent 44f09a9 commit d90861e

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

Skyline.DataMiner.CICD.Tools.GitHubToCatalogYaml/CatalogManager.cs

+11-4
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public CatalogManager(IFileSystem fs, ILogger logger, IGitHubService service, st
3333
this.service = service;
3434
this.workspace = workspace;
3535
}
36-
3736
/// <summary>
3837
/// Processes the catalog YAML file for the specified GitHub repository. It checks and updates various fields such as ID, description, tags, title, and type.
3938
/// If no catalog file is found, it attempts to create one from the manifest file.
4039
/// </summary>
4140
/// <param name="repoName">The name of the GitHub repository to process.</param>
42-
/// <exception cref="ArgumentNullException">Thrown when <paramref name="repoName"/> is null or empty.</exception>
41+
/// <param name="catalogIdentifier">The catalog identifier to be used in processing the catalog YAML file.</param>
42+
/// <exception cref="ArgumentNullException">Thrown when <paramref name="repoName"/> or <paramref name="catalogIdentifier"/> is null or empty.</exception>
4343
/// <returns>A task that represents the asynchronous operation.</returns>
44-
public async Task ProcessCatalogYamlAsync(string repoName)
44+
public async Task ProcessCatalogYamlAsync(string repoName, string catalogIdentifier = "")
4545
{
4646
if (String.IsNullOrWhiteSpace(repoName)) throw new ArgumentNullException(nameof(repoName));
4747

@@ -57,7 +57,14 @@ public async Task ProcessCatalogYamlAsync(string repoName)
5757

5858
CatalogYaml catalogYaml = CreateCatalogYaml(deserializer, out string filePath);
5959

60-
await CheckId(catalogYaml);
60+
if (String.IsNullOrWhiteSpace(catalogIdentifier))
61+
{
62+
await CheckId(catalogYaml);
63+
}
64+
else
65+
{
66+
catalogYaml.Id = catalogIdentifier;
67+
}
6168

6269
await CheckShortDescription(catalogYaml);
6370

Skyline.DataMiner.CICD.Tools.GitHubToCatalogYaml/Program.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,27 @@ public static async Task<int> Main(string[] args)
5757
IsRequired = true
5858
};
5959

60+
var catalogIdentifier = new Option<string>(
61+
name: "--catalogIdentifier",
62+
description: "(optional) The catalog identifier. If not provided, then the provided token must be a PAT with access to Actions/Variables.")
63+
{
64+
IsRequired = false
65+
};
66+
6067
var rootCommand = new RootCommand("Extends or creates a catalog.yml file with data retrieved from GitHub")
6168
{
6269
isDebug,
6370
githubToken,
6471
githubRepository,
6572
workspace,
73+
catalogIdentifier
6674
};
6775

68-
rootCommand.SetHandler(Process, isDebug, githubToken, githubRepository, workspace);
76+
rootCommand.SetHandler(Process, isDebug, githubToken, githubRepository, workspace, catalogIdentifier);
6977

7078
return await rootCommand.InvokeAsync(args);
7179
}
72-
private static async Task<int> Process(bool isDebug, string githubToken, string githubRepository, string workspace)
80+
private static async Task<int> Process(bool isDebug, string githubToken, string githubRepository, string workspace, string catalogIdentifier)
7381
{
7482
try
7583
{
@@ -90,7 +98,7 @@ private static async Task<int> Process(bool isDebug, string githubToken, string
9098
var catalogManager = new CatalogManager(fs, logger, gitHubService, workspace);
9199

92100
// Call the method to process the catalog.yml file
93-
await catalogManager.ProcessCatalogYamlAsync(githubRepository);
101+
await catalogManager.ProcessCatalogYamlAsync(githubRepository, catalogIdentifier);
94102

95103
logger.LogInformation("Process completed successfully.");
96104
}

0 commit comments

Comments
 (0)