@@ -35,8 +35,8 @@ public class FunctionCallExecutor(IServiceProvider serviceProvider, ILogger<Func
3535{
3636
3737 const string CustomFunctionDefinitionFile = "function.yaml" ;
38- const string GithubHost = "github.com" ;
39- const string GitlabHost = "gitlab" ;
38+ const string GitHubHost = "github.com" ;
39+ const string GitLabHost = "gitlab" ;
4040
4141 /// <summary>
4242 /// Gets the service used to serialize/deserialize objects to/from YAML
@@ -65,6 +65,15 @@ public override async Task InitializeAsync(CancellationToken cancellationToken =
6565 if ( components . Length != 2 ) throw new NotSupportedException ( $ "Unknown/unsupported function '{ this . Task . Definition . Call } '") ;
6666 this . Function = await this . GetCustomFunctionAsync ( components [ 0 ] , components [ 1 ] , cancellationToken ) . ConfigureAwait ( false ) ;
6767 }
68+ else if ( this . Task . Definition . Call . Contains ( ':' ) )
69+ {
70+ var components = this . Task . Definition . Call . Split ( ':' , StringSplitOptions . RemoveEmptyEntries ) ;
71+ if ( components . Length != 2 ) throw new Exception ( $ "The specified value '{ this . Task . Definition . Call } ' is not a valid custom function qualified name ({{name}}:{{version}})") ;
72+ var functionName = components [ 0 ] ;
73+ var functionVersion = components [ 1 ] ;
74+ uri = new Uri ( $ "https://github.com/serverlessworkflow/catalog/tree/main/functions/{ functionName } /{ functionVersion } /{ CustomFunctionDefinitionFile } ") ;
75+ this . Function = await this . GetCustomFunctionAsync ( new ( ) { Uri = uri } , cancellationToken ) . ConfigureAwait ( false ) ;
76+ }
6877 else throw new NotSupportedException ( $ "Unknown/unsupported function '{ this . Task . Definition . Call } '") ;
6978 }
7079
@@ -79,8 +88,8 @@ protected virtual async Task<TaskDefinition> GetCustomFunctionAsync(EndpointDefi
7988 ArgumentNullException . ThrowIfNull ( endpoint ) ;
8089 var uri = endpoint . Uri ;
8190 if ( ! uri . OriginalString . EndsWith ( CustomFunctionDefinitionFile ) ) uri = new Uri ( uri , CustomFunctionDefinitionFile ) ;
82- if ( uri . Host . Equals ( GithubHost , StringComparison . OrdinalIgnoreCase ) ) uri = this . TransformGithubUriToRawUri ( uri ) ;
83- else if ( uri . Host . Contains ( GitlabHost ) ) uri = this . TransformGitlabUriToRawUri ( uri ) ;
91+ if ( uri . Host . Equals ( GitHubHost , StringComparison . OrdinalIgnoreCase ) ) uri = this . TransformGithubUriToRawUri ( uri ) ;
92+ else if ( uri . Host . Contains ( GitLabHost ) ) uri = this . TransformGitlabUriToRawUri ( uri ) ;
8493 var authentication = endpoint . Authentication == null ? null : await this . Task . Workflow . Expressions . EvaluateAsync < AuthenticationPolicyDefinition > ( endpoint . Authentication , this . Task . Input , this . Task . Arguments , cancellationToken ) . ConfigureAwait ( false ) ;
8594 using var httpClient = this . ServiceProvider . GetRequiredService < IHttpClientFactory > ( ) . CreateClient ( ) ;
8695 await httpClient . ConfigureAuthenticationAsync ( authentication , this . ServiceProvider , this . Task . Workflow . Definition , cancellationToken ) . ConfigureAwait ( false ) ;
@@ -138,8 +147,8 @@ protected virtual async Task<TaskDefinition> GetCustomFunctionAsync(string funct
138147 protected virtual Uri TransformGithubUriToRawUri ( Uri uri )
139148 {
140149 ArgumentNullException . ThrowIfNull ( uri ) ;
141- if ( uri . Host . Equals ( GithubHost , StringComparison . OrdinalIgnoreCase ) ) return uri ;
142- var rawUri = uri . AbsoluteUri . Replace ( GithubHost , "raw.githubusercontent.com" , StringComparison . OrdinalIgnoreCase ) ;
150+ if ( ! uri . Host . Equals ( GitHubHost , StringComparison . OrdinalIgnoreCase ) ) return uri ;
151+ var rawUri = uri . AbsoluteUri . Replace ( GitHubHost , "raw.githubusercontent.com" , StringComparison . OrdinalIgnoreCase ) ;
143152 rawUri = rawUri . Replace ( "/tree/" , "/refs/heads/" , StringComparison . OrdinalIgnoreCase ) ;
144153 return new ( rawUri , UriKind . Absolute ) ;
145154 }
@@ -152,7 +161,7 @@ protected virtual Uri TransformGithubUriToRawUri(Uri uri)
152161 protected virtual Uri TransformGitlabUriToRawUri ( Uri uri )
153162 {
154163 ArgumentNullException . ThrowIfNull ( uri ) ;
155- if ( ! uri . AbsoluteUri . Contains ( GitlabHost , StringComparison . OrdinalIgnoreCase ) ) return uri ;
164+ if ( ! uri . Host . Equals ( GitLabHost , StringComparison . OrdinalIgnoreCase ) ) return uri ;
156165 var rawUri = uri . AbsoluteUri . Replace ( "/-/blob/" , "/-/raw/" , StringComparison . OrdinalIgnoreCase ) ;
157166 return new ( rawUri , UriKind . Absolute ) ;
158167 }
0 commit comments