mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-03 14:03:09 +00:00
37 lines
739 B
C#
37 lines
739 B
C#
|
|
using k8s;
|
|||
|
|
|
|||
|
|
namespace KubernetesWorkflow
|
|||
|
|
{
|
|||
|
|
public class K8sClient
|
|||
|
|
{
|
|||
|
|
private readonly Kubernetes client;
|
|||
|
|
private static readonly object clientLock = new object();
|
|||
|
|
|
|||
|
|
public K8sClient(KubernetesClientConfiguration config)
|
|||
|
|
{
|
|||
|
|
client = new Kubernetes(config);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Run(Action<Kubernetes> action)
|
|||
|
|
{
|
|||
|
|
lock (clientLock)
|
|||
|
|
{
|
|||
|
|
action(client);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public T Run<T>(Func<Kubernetes, T> action)
|
|||
|
|
{
|
|||
|
|
lock (clientLock)
|
|||
|
|
{
|
|||
|
|
return action(client);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Dispose()
|
|||
|
|
{
|
|||
|
|
client.Dispose();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|