cs-codex-dist-tests/Framework/Core/CoreInterface.cs

57 lines
1.8 KiB
C#
Raw Normal View History

2023-09-14 13:26:46 +00:00
using KubernetesWorkflow;
using KubernetesWorkflow.Types;
2023-09-14 13:26:46 +00:00
namespace Core
{
public sealed class CoreInterface
{
private readonly EntryPoint entryPoint;
internal CoreInterface(EntryPoint entryPoint)
{
this.entryPoint = entryPoint;
}
public T GetPlugin<T>() where T : IProjectPlugin
{
return entryPoint.GetPlugin<T>();
}
2023-09-14 13:26:46 +00:00
2023-09-25 06:47:19 +00:00
public IKnownLocations GetKnownLocations()
{
return entryPoint.Tools.CreateWorkflow().GetAvailableLocations();
}
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 msg = $"Downloading container log for '{container.Name}'";
entryPoint.Tools.GetLog().Log(msg);
var logHandler = new WriteToFileLogHandler(entryPoint.Tools.GetLog(), msg);
2023-09-14 13:26:46 +00:00
workflow.DownloadContainerLog(container, logHandler, tailLines);
2024-07-29 09:02:24 +00:00
return new DownloadedLog(logHandler, container.Name);
2023-09-14 13:26:46 +00:00
}
2023-09-15 10:25:10 +00:00
2023-09-15 10:36:35 +00:00
public string ExecuteContainerCommand(IHasContainer containerSource, string command, params string[] args)
{
return ExecuteContainerCommand(containerSource.Container, command, args);
}
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; }
}
}