diff --git a/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj b/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj
index edc091fe7..8f4fbadcc 100644
--- a/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj
+++ b/src/api/Synapse.Api.Application/Synapse.Api.Application.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj b/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj
index d580075e1..485ea739a 100644
--- a/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj
+++ b/src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj b/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj
index 7d301b752..8f58ea247 100644
--- a/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj
+++ b/src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
@@ -43,7 +43,7 @@
-
+
diff --git a/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj b/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
index 5ecfa94cd..06f850c6a 100644
--- a/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
+++ b/src/api/Synapse.Api.Http/Synapse.Api.Http.csproj
@@ -8,7 +8,7 @@
Library
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj b/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj
index 52e1b5e61..d4fd6f08f 100644
--- a/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj
+++ b/src/api/Synapse.Api.Server/Synapse.Api.Server.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/cli/Synapse.Cli/Synapse.Cli.csproj b/src/cli/Synapse.Cli/Synapse.Cli.csproj
index eaea0cabb..05cdb1697 100644
--- a/src/cli/Synapse.Cli/Synapse.Cli.csproj
+++ b/src/cli/Synapse.Cli/Synapse.Cli.csproj
@@ -8,7 +8,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
@@ -33,7 +33,7 @@
-
+
diff --git a/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj b/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj
index 14055cede..a527a1ec3 100644
--- a/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj
+++ b/src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj b/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj
index d9b3f0180..58747907c 100644
--- a/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj
+++ b/src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj b/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj
index 2a4a322c3..dc7afc2bc 100644
--- a/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj
+++ b/src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
@@ -50,7 +50,7 @@
-
+
diff --git a/src/core/Synapse.Core/Synapse.Core.csproj b/src/core/Synapse.Core/Synapse.Core.csproj
index 62d668fb6..1fd685500 100644
--- a/src/core/Synapse.Core/Synapse.Core.csproj
+++ b/src/core/Synapse.Core/Synapse.Core.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
@@ -69,7 +69,7 @@
-
+
diff --git a/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj b/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj
index 5de5a7388..5c2f612f7 100644
--- a/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj
+++ b/src/correlator/Synapse.Correlator/Synapse.Correlator.csproj
@@ -8,7 +8,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/operator/Synapse.Operator/Synapse.Operator.csproj b/src/operator/Synapse.Operator/Synapse.Operator.csproj
index 407b567ea..ea2b3af3e 100644
--- a/src/operator/Synapse.Operator/Synapse.Operator.csproj
+++ b/src/operator/Synapse.Operator/Synapse.Operator.csproj
@@ -8,7 +8,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/runner/Synapse.Runner/Services/Executors/FunctionCallExecutor.cs b/src/runner/Synapse.Runner/Services/Executors/FunctionCallExecutor.cs
index 997f6bfbe..8ddfcaf5a 100644
--- a/src/runner/Synapse.Runner/Services/Executors/FunctionCallExecutor.cs
+++ b/src/runner/Synapse.Runner/Services/Executors/FunctionCallExecutor.cs
@@ -13,6 +13,7 @@
using Neuroglia;
using Neuroglia.Data.Expressions;
+using Semver;
namespace Synapse.Runner.Services.Executors;
@@ -34,6 +35,8 @@ public class FunctionCallExecutor(IServiceProvider serviceProvider, ILogger
/// Gets the service used to serialize/deserialize objects to/from YAML
@@ -55,7 +58,7 @@ public override async Task InitializeAsync(CancellationToken cancellationToken =
{
await base.InitializeAsync(cancellationToken).ConfigureAwait(false);
if (this.Task.Workflow.Definition.Use?.Functions?.TryGetValue(this.Task.Definition.Call, out var function) == true && function != null) this.Function = function;
- else if (Uri.TryCreate(this.Task.Definition.Call, UriKind.Absolute, out var uri) && (uri.IsFile || !string.IsNullOrWhiteSpace(uri.Host))) this.Function = await this.GetCustomFunctionAsync(uri, cancellationToken).ConfigureAwait(false);
+ else if (Uri.TryCreate(this.Task.Definition.Call, UriKind.Absolute, out var uri) && (uri.IsFile || !string.IsNullOrWhiteSpace(uri.Host))) this.Function = await this.GetCustomFunctionAsync(new() { Uri = uri }, cancellationToken).ConfigureAwait(false);
else if (this.Task.Definition.Call.Contains('@'))
{
var components = this.Task.Definition.Call.Split('@', StringSplitOptions.RemoveEmptyEntries);
@@ -68,16 +71,22 @@ public override async Task InitializeAsync(CancellationToken cancellationToken =
///
/// Gets the custom function at the specified uri
///
- /// The uri of that references the custom function to get
+ /// The uri of that references the custom function to get
/// A
/// The of the custom function defined at the specified uri
- protected virtual async Task GetCustomFunctionAsync(Uri uri, CancellationToken cancellationToken = default)
+ protected virtual async Task GetCustomFunctionAsync(EndpointDefinition endpoint, CancellationToken cancellationToken = default)
{
- ArgumentNullException.ThrowIfNull(uri);
+ ArgumentNullException.ThrowIfNull(endpoint);
+ var uri = endpoint.Uri;
if (!uri.OriginalString.EndsWith(CustomFunctionDefinitionFile)) uri = new Uri(uri, CustomFunctionDefinitionFile);
+ if (uri.Host.Equals(GithubHost, StringComparison.OrdinalIgnoreCase)) uri = this.TransformGithubUriToRawUri(uri);
+ else if (uri.Host.Contains(GitlabHost)) uri = this.TransformGitlabUriToRawUri(uri);
+ var authentication = endpoint.Authentication == null ? null : await this.Task.Workflow.Expressions.EvaluateAsync(endpoint.Authentication, this.Task.Input, this.Task.Arguments, cancellationToken).ConfigureAwait(false);
+ using var httpClient = this.ServiceProvider.GetRequiredService().CreateClient();
+ await httpClient.ConfigureAuthenticationAsync(this.Task.Workflow.Definition, authentication, this.ServiceProvider, cancellationToken).ConfigureAwait(false);
try
{
- using var response = await this.HttpClient.GetAsync(uri, cancellationToken).ConfigureAwait(false);
+ using var response = await httpClient.GetAsync(uri, cancellationToken).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
var yaml = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
var function = this.YamlSerializer.Deserialize(yaml)!;
@@ -85,7 +94,7 @@ protected virtual async Task GetCustomFunctionAsync(Uri uri, Can
}
catch(Exception ex)
{
- throw new ProblemDetailsException(new(ErrorType.Communication, ErrorTitle.Communication, ErrorStatus.Communication, $"Failed to load the custom function defined at '{uri}': {ex.Message}"));
+ throw new ProblemDetailsException(new(ErrorType.Communication, ErrorTitle.Communication, ErrorStatus.Communication, $"Failed to load the custom function defined at '{endpoint}': {ex.Message}"));
}
}
@@ -100,16 +109,52 @@ protected virtual async Task GetCustomFunctionAsync(string funct
{
ArgumentException.ThrowIfNullOrWhiteSpace(functionName);
ArgumentException.ThrowIfNullOrWhiteSpace(catalogName);
+ var components = functionName.Split(':', StringSplitOptions.RemoveEmptyEntries);
+ if (components.Length != 2) throw new Exception($"The specified value '{functionName}' is not a valid custom function qualified name ({{name}}:{{version}})");
+ var name = components[0];
+ var version = components[1];
+ if (!SemVersion.TryParse(version, SemVersionStyles.Strict, out _)) throw new Exception($"The specified value '{version}' is not a valid semantic version 2.0");
if (catalogName == SynapseDefaults.Tasks.CustomFunctions.Catalogs.Default)
{
- var components = functionName.Split(':', StringSplitOptions.RemoveEmptyEntries);
- if (components.Length != 2) throw new Exception($"The specified value '{functionName}' is not a valid custom function qualified name ({{name}}:{{version}})");
- var name = components[0];
- var version = components[1];
var function = await this.Task.Workflow.CustomFunctions.GetAsync(name, cancellationToken).ConfigureAwait(false) ?? throw new NullReferenceException($"Failed to find the specified custom function '{name}'");
return function.Spec.Versions.Get(version) ?? throw new NullReferenceException($"Failed to find the version '{version}' of the custom function '{name}'");
}
- else throw new NotImplementedException("Using non-default custom function catalog is not yet implemented"); //todo: implement
+ else
+ {
+ if (this.Task.Workflow.Definition.Use?.Catalogs?.TryGetValue(catalogName, out var catalog) != true || catalog == null) throw new NullReferenceException($"Failed to find a catalog with the specified name '{catalogName}'");
+ return await this.GetCustomFunctionAsync(new()
+ {
+ Uri = new(catalog.Endpoint.Uri, $"/functions/{name}/{version}"),
+ Authentication = catalog.Endpoint.Authentication
+ }, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ ///
+ /// Transforms the specified Github content into a Github raw content
+ ///
+ /// The to transform
+ /// The Github raw content
+ protected virtual Uri TransformGithubUriToRawUri(Uri uri)
+ {
+ ArgumentNullException.ThrowIfNull(uri);
+ if (uri.Host.Equals(GithubHost, StringComparison.OrdinalIgnoreCase)) return uri;
+ var rawUri = uri.AbsoluteUri.Replace(GithubHost, "raw.githubusercontent.com", StringComparison.OrdinalIgnoreCase);
+ rawUri = rawUri.Replace("/tree/", "/refs/heads/", StringComparison.OrdinalIgnoreCase);
+ return new(rawUri, UriKind.Absolute);
+ }
+
+ ///
+ /// Transforms the specified Gitlab content into a Gitlab raw content
+ ///
+ /// The to transform
+ /// The Gitlab raw content
+ protected virtual Uri TransformGitlabUriToRawUri(Uri uri)
+ {
+ ArgumentNullException.ThrowIfNull(uri);
+ if (!uri.AbsoluteUri.Contains(GitlabHost, StringComparison.OrdinalIgnoreCase)) return uri;
+ var rawUri = uri.AbsoluteUri.Replace("/-/blob/", "/-/raw/", StringComparison.OrdinalIgnoreCase);
+ return new(rawUri, UriKind.Absolute);
}
///
diff --git a/src/runner/Synapse.Runner/Synapse.Runner.csproj b/src/runner/Synapse.Runner/Synapse.Runner.csproj
index 6194999e8..9b9d7b30c 100644
--- a/src/runner/Synapse.Runner/Synapse.Runner.csproj
+++ b/src/runner/Synapse.Runner/Synapse.Runner.csproj
@@ -8,7 +8,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj b/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj
index 4cef52659..53ddf0374 100644
--- a/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj
+++ b/src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj b/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj
index 6f5a6247a..c0aed3c3e 100644
--- a/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj
+++ b/src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj b/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj
index 1b396ebd5..18b2260d4 100644
--- a/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj
+++ b/src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj b/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj
index 46dc1214c..36a78c1dc 100644
--- a/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj
+++ b/src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj
@@ -7,7 +7,7 @@
en
True
1.0.0
- alpha4.1
+ alpha5
$(VersionPrefix)
$(VersionPrefix)
The Synapse Authors
diff --git a/tests/Synapse.IntegrationTests/Synapse.IntegrationTests.csproj b/tests/Synapse.IntegrationTests/Synapse.IntegrationTests.csproj
index c7e5625bd..9cef53eac 100644
--- a/tests/Synapse.IntegrationTests/Synapse.IntegrationTests.csproj
+++ b/tests/Synapse.IntegrationTests/Synapse.IntegrationTests.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/tests/Synapse.UnitTests/Synapse.UnitTests.csproj b/tests/Synapse.UnitTests/Synapse.UnitTests.csproj
index dbe6709fb..fbcb2aa0f 100644
--- a/tests/Synapse.UnitTests/Synapse.UnitTests.csproj
+++ b/tests/Synapse.UnitTests/Synapse.UnitTests.csproj
@@ -22,8 +22,8 @@
-
-
+
+