2023-09-14 13:26:46 +00:00
|
|
|
|
using KubernetesWorkflow;
|
|
|
|
|
|
|
|
|
|
namespace Core
|
2023-09-12 12:50:18 +00:00
|
|
|
|
{
|
2023-09-13 06:55:04 +00:00
|
|
|
|
public sealed class CoreInterface
|
2023-09-12 12:50:18 +00:00
|
|
|
|
{
|
2023-09-13 06:55:04 +00:00
|
|
|
|
private readonly EntryPoint entryPoint;
|
2023-09-12 12:50:18 +00:00
|
|
|
|
|
2023-09-13 06:55:04 +00:00
|
|
|
|
internal CoreInterface(EntryPoint entryPoint)
|
2023-09-12 12:50:18 +00:00
|
|
|
|
{
|
2023-09-13 06:55:04 +00:00
|
|
|
|
this.entryPoint = entryPoint;
|
2023-09-12 12:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 06:55:04 +00:00
|
|
|
|
public T GetPlugin<T>() where T : IProjectPlugin
|
2023-09-12 12:50:18 +00:00
|
|
|
|
{
|
2023-09-13 06:55:04 +00:00
|
|
|
|
return entryPoint.GetPlugin<T>();
|
2023-09-12 12:50:18 +00:00
|
|
|
|
}
|
2023-09-14 13:26:46 +00:00
|
|
|
|
|
|
|
|
|
public IDownloadedLog DownloadLog(IHasContainer containerSource, int? tailLines = null)
|
|
|
|
|
{
|
|
|
|
|
return DownloadLog(containerSource.Container, tailLines);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IDownloadedLog DownloadLog(RunningContainer container, int? tailLines = null)
|
|
|
|
|
{
|
|
|
|
|
var workflow = entryPoint.Tools.CreateWorkflow();
|
|
|
|
|
var file = entryPoint.Tools.GetLog().CreateSubfile();
|
2023-09-14 13:40:15 +00:00
|
|
|
|
entryPoint.Tools.GetLog().Log($"Downloading container log for '{container.Name}' to file '{file.FullFilename}'...");
|
2023-09-14 13:26:46 +00:00
|
|
|
|
var logHandler = new LogDownloadHandler(container.Name, file);
|
|
|
|
|
workflow.DownloadContainerLog(container, logHandler, tailLines);
|
|
|
|
|
return logHandler.DownloadLog();
|
|
|
|
|
}
|
2023-09-15 10:25:10 +00:00
|
|
|
|
|
|
|
|
|
public string ExecuteContainerCommand(RunningContainer container, string command, params string[] args)
|
|
|
|
|
{
|
|
|
|
|
var workflow = entryPoint.Tools.CreateWorkflow();
|
|
|
|
|
return workflow.ExecuteCommand(container, command, args);
|
|
|
|
|
}
|
2023-09-14 13:26:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IHasContainer
|
|
|
|
|
{
|
|
|
|
|
RunningContainer Container { get; }
|
2023-09-12 12:50:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|