-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from NoxOrg/feature/nox_solution
Feature/nox solution
- Loading branch information
Showing
71 changed files
with
725 additions
and
699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Cli Sample Solution definition | ||
# | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/NoxOrg/Nox/main/src/Nox.Core/Schemas/NoxConfiguration.json | ||
# | ||
|
||
# | ||
|
||
name: CliDemo | ||
|
||
description: A Cli Demo Nox Configuration | ||
environments: | ||
|
||
- name: dev | ||
description: Used for development and testing | ||
|
||
- name: test | ||
description: Test environment | ||
|
||
- name: uat | ||
description: For them end users to check it works | ||
|
||
- name: prod | ||
description: Production environment used for, well - the real thing! | ||
isProduction: true | ||
|
||
versionControl: | ||
provider: azureDevops | ||
host: https://dev.azure.com/iwgplc | ||
folders: | ||
sourceCode: /src | ||
containers: /docker | ||
|
||
team: | ||
|
||
- name: Andre Sharpe | ||
userName: andre.sharpe@iwgplc.com | ||
roles: [architect, owner, administrator, developer, manager] | ||
|
||
- name: Jan Schutte | ||
userName: jan.schutte@iwgplc.com | ||
roles: [architect, administrator, developer, devOpsEngineer] | ||
|
||
- name: Anton Du Plessis | ||
userName: anton.duplessis@iwgplc.com | ||
roles: [projectManager] | ||
|
||
- name: Morne Van Zyl | ||
userName: morne.vanzyl@iwgplc.com | ||
roles: [technicalWriter] | ||
|
||
- name: Dmytro Dorodnykh | ||
userName: dmytro.dorodnykh@iwgplc.com | ||
roles: [developer] | ||
|
||
- name: Oleksandr Vlasenko | ||
userName: oleksandr.vlasenko@regus.com | ||
roles: [architect, developer] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Nox.Cli.Abstractions.Constants; | ||
|
||
public static class FileExtension | ||
{ | ||
public const string WorkflowDefinition = @"*.workflow.nox.yaml"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System.Text.RegularExpressions; | ||
using Nox.Cli.Abstractions.Exceptions; | ||
|
||
namespace Nox.Cli.Abstractions.Helpers; | ||
|
||
public static class YamlHelper | ||
{ | ||
private static readonly Regex _referenceRegex = new(@"\$ref\S*:\s*(?<variable>[\w:\.\/\\]+\b[\w\-\.\/]+)\s*", RegexOptions.Compiled | RegexOptions.IgnoreCase, TimeSpan.FromSeconds(5)); | ||
|
||
/// <summary> | ||
/// Resolve $ref <path> tags in a yaml source yaml file. <br/> | ||
/// Loads the source yaml file, resolves the $ref's and replaces them with the yaml from the files specified in <path><br/> | ||
/// Note: This call is recursive, all $refs in the yaml hierarchy will be resolved. | ||
/// Note: child nodes are added at the same indentation as the $ref tag. | ||
/// </summary> | ||
/// <param name="path">Full or relative path to the source yaml file.</param> | ||
/// <returns></returns> | ||
public static string ResolveYamlReferences(string path) | ||
{ | ||
var sourceFullPath = Path.GetFullPath(path); | ||
if (!File.Exists(sourceFullPath)) throw new NoxCliException($"Yaml file {path} does not exist!"); | ||
var sourcePath = Path.GetDirectoryName(sourceFullPath); | ||
|
||
var sourceLines = File.ReadAllLines(path); | ||
var outputLines = ResolveYamlReferences(sourceLines.ToList(), sourcePath!).Result; | ||
|
||
return string.Join('\n', outputLines.ToArray()); | ||
} | ||
|
||
/// <summary> | ||
/// Resolve $ref <path> tags in a yaml source yaml file. <br/> | ||
/// Loads the source yaml file, resolves the $ref's and replaces them with the yaml from the files specified in <path><br/> | ||
/// Note: This call is recursive, all $refs in the yaml hierarchy will be resolved. | ||
/// Note: child nodes are added at the same indentation as the $ref tag. | ||
/// </summary> | ||
/// <param name="path">Full or relative path to the source yaml file.</param> | ||
/// <returns></returns> | ||
public static async Task<string> ResolveYamlReferencesAsync(string path) | ||
{ | ||
var sourceFullPath = Path.GetFullPath(path); | ||
if (!File.Exists(sourceFullPath)) throw new NoxCliException($"Yaml file {path} does not exist!"); | ||
var sourcePath = Path.GetDirectoryName(sourceFullPath); | ||
|
||
var sourceLines = await File.ReadAllLinesAsync(path); | ||
var outputLines = await ResolveYamlReferences(sourceLines.ToList(), sourcePath!); | ||
|
||
return string.Join('\n', outputLines.ToArray()); | ||
} | ||
|
||
private static async Task<List<string>> ResolveYamlReferences(List<string> sourceLines, string path) | ||
{ | ||
var outputLines = new List<string>(); | ||
foreach (var sourceLine in sourceLines) | ||
{ | ||
if (!sourceLine.TrimStart().StartsWith('#')) | ||
{ | ||
var match = _referenceRegex.Match(sourceLine); | ||
if (match.Success) | ||
{ | ||
var padding = new string(' ', match.Index); | ||
var childPath = match.Groups[1].Value; | ||
if (!Path.IsPathRooted(childPath)) childPath = Path.Combine(path!, childPath); | ||
if (!File.Exists(childPath)) throw new NoxCliException($"Referenced yaml file does not exist for reference: {match.Groups[1].Value}"); | ||
var childLines = await File.ReadAllLinesAsync(childPath); | ||
foreach (var childLine in childLines) | ||
{ | ||
outputLines.Add(padding + childLine); | ||
} | ||
} | ||
else | ||
{ | ||
outputLines.Add(sourceLine); | ||
} | ||
} | ||
else | ||
{ | ||
outputLines.Add(sourceLine); | ||
} | ||
} | ||
|
||
if (outputLines.Any(ol => ol.Contains("$ref:") && !ol.TrimStart().StartsWith('#'))) | ||
{ | ||
outputLines = await ResolveYamlReferences(outputLines, path); | ||
} | ||
|
||
return outputLines; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.