2023-09-13 08:03:11 +00:00
using FileUtils ;
using KubernetesWorkflow ;
using Logging ;
using Utils ;
namespace Core
{
2023-09-13 08:23:05 +00:00
public interface IPluginTools : IWorkflowTool , ILogTool , IHttpFactoryTool , IFileTool
{
}
public interface IWorkflowTool
{
IStartupWorkflow CreateWorkflow ( string? namespaceOverride = null ) ;
}
public interface ILogTool
{
ILog GetLog ( ) ;
}
public interface IHttpFactoryTool
{
Http CreateHttp ( Address address , string baseUrl , Action < HttpClient > onClientCreated , string? logAlias = null ) ;
Http CreateHttp ( Address address , string baseUrl , string? logAlias = null ) ;
}
public interface IFileTool
{
IFileManager GetFileManager ( ) ;
}
internal class PluginTools : IPluginTools
2023-09-13 08:03:11 +00:00
{
private readonly ITimeSet timeSet ;
private readonly WorkflowCreator workflowCreator ;
private readonly IFileManager fileManager ;
2023-09-13 08:23:05 +00:00
private ILog log ;
2023-09-13 08:03:11 +00:00
2023-09-13 08:23:05 +00:00
public PluginTools ( ILog log , Configuration configuration , string fileManagerRootFolder , ITimeSet timeSet )
2023-09-13 08:03:11 +00:00
{
this . log = log ;
this . timeSet = timeSet ;
fileManager = new FileManager ( log , fileManagerRootFolder ) ;
workflowCreator = new WorkflowCreator ( log , configuration ) ;
}
2023-09-13 08:23:05 +00:00
public void ApplyLogPrefix ( string prefix )
{
log = new LogPrefixer ( log , prefix ) ;
}
2023-09-13 08:03:11 +00:00
public Http CreateHttp ( Address address , string baseUrl , Action < HttpClient > onClientCreated , string? logAlias = null )
{
return new Http ( log , timeSet , address , baseUrl , onClientCreated , logAlias ) ;
}
public Http CreateHttp ( Address address , string baseUrl , string? logAlias = null )
{
return new Http ( log , timeSet , address , baseUrl , logAlias ) ;
}
public IStartupWorkflow CreateWorkflow ( string? namespaceOverride = null )
{
if ( namespaceOverride ! = null ) throw new Exception ( "Namespace override is not supported in the DistTest environment. (It would mess up automatic resource cleanup.)" ) ;
return workflowCreator . CreateWorkflow ( ) ;
}
public IFileManager GetFileManager ( )
{
return fileManager ;
}
public ILog GetLog ( )
{
return log ;
}
}
}