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
|
|
|
|
|
{
|
2023-09-21 08:33:09 +00:00
|
|
|
|
void Decommission(bool deleteKubernetesResources, bool deleteTrackedFiles);
|
2023-09-13 08:23:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IWorkflowTool
|
|
|
|
|
{
|
|
|
|
|
IStartupWorkflow CreateWorkflow(string? namespaceOverride = null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ILogTool
|
|
|
|
|
{
|
|
|
|
|
ILog GetLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IHttpFactoryTool
|
|
|
|
|
{
|
2023-09-14 13:40:15 +00:00
|
|
|
|
IHttp CreateHttp(Address address, string baseUrl, Action<HttpClient> onClientCreated, string? logAlias = null);
|
2023-10-10 16:08:21 +00:00
|
|
|
|
IHttp CreateHttp(Address address, string baseUrl, Action<HttpClient> onClientCreated, ITimeSet timeSet, string? logAlias = null);
|
2023-09-14 13:40:15 +00:00
|
|
|
|
IHttp CreateHttp(Address address, string baseUrl, string? logAlias = null);
|
2023-09-13 08:23:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-14 13:40:15 +00:00
|
|
|
|
internal PluginTools(ILog log, WorkflowCreator workflowCreator, string fileManagerRootFolder, ITimeSet timeSet)
|
2023-09-13 08:03:11 +00:00
|
|
|
|
{
|
|
|
|
|
this.log = log;
|
2023-09-13 09:59:21 +00:00
|
|
|
|
this.workflowCreator = workflowCreator;
|
2023-09-13 08:03:11 +00:00
|
|
|
|
this.timeSet = timeSet;
|
|
|
|
|
fileManager = new FileManager(log, fileManagerRootFolder);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 08:23:05 +00:00
|
|
|
|
public void ApplyLogPrefix(string prefix)
|
|
|
|
|
{
|
|
|
|
|
log = new LogPrefixer(log, prefix);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-14 13:40:15 +00:00
|
|
|
|
public IHttp CreateHttp(Address address, string baseUrl, Action<HttpClient> onClientCreated, string? logAlias = null)
|
2023-09-13 08:03:11 +00:00
|
|
|
|
{
|
2023-10-10 16:08:21 +00:00
|
|
|
|
return CreateHttp(address, baseUrl, onClientCreated, timeSet, logAlias);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IHttp CreateHttp(Address address, string baseUrl, Action<HttpClient> onClientCreated, ITimeSet ts, string? logAlias = null)
|
|
|
|
|
{
|
|
|
|
|
return new Http(log, ts, address, baseUrl, onClientCreated, logAlias);
|
2023-09-13 08:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-14 13:40:15 +00:00
|
|
|
|
public IHttp CreateHttp(Address address, string baseUrl, string? logAlias = null)
|
2023-09-13 08:03:11 +00:00
|
|
|
|
{
|
|
|
|
|
return new Http(log, timeSet, address, baseUrl, logAlias);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IStartupWorkflow CreateWorkflow(string? namespaceOverride = null)
|
|
|
|
|
{
|
2023-09-13 12:37:53 +00:00
|
|
|
|
return workflowCreator.CreateWorkflow(namespaceOverride);
|
2023-09-13 08:03:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-21 08:33:09 +00:00
|
|
|
|
public void Decommission(bool deleteKubernetesResources, bool deleteTrackedFiles)
|
|
|
|
|
{
|
|
|
|
|
if (deleteKubernetesResources) CreateWorkflow().DeleteNamespace();
|
|
|
|
|
if (deleteTrackedFiles) fileManager.DeleteAllFiles();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 08:03:11 +00:00
|
|
|
|
public IFileManager GetFileManager()
|
|
|
|
|
{
|
|
|
|
|
return fileManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ILog GetLog()
|
|
|
|
|
{
|
|
|
|
|
return log;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|