* gen v1.23.0 * fix converter * bump ver * update readme runtime * fix warning * update dep ver * newtonjson -> system.text.json * generate for new json api * readme lf * dotnet fmt * dotnet fmt tests/ * dotnet fmt * Revert "dotnet fmt" This reverts commit e14c59076143fe2218ed899295a00762f0ea2bd6. * fix err introduce by dotnet fmt * fix test * remove deprecated /watch api * generate code after /watch removed * remove /watch related code * trim Microsoft.Rest.Serialization
68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using k8s.Models;
|
|
using k8s.Util.Common.Generic;
|
|
|
|
namespace k8s.Tests.Util
|
|
{
|
|
internal static class Helpers
|
|
{
|
|
public static IEnumerable<V1Pod> CreatePods(int cnt)
|
|
{
|
|
var pods = new List<V1Pod>();
|
|
for (var i = 0; i < cnt; i++)
|
|
{
|
|
pods.Add(new V1Pod()
|
|
{
|
|
ApiVersion = "Pod/V1",
|
|
Kind = "Pod",
|
|
Metadata = new V1ObjectMeta()
|
|
{
|
|
Name = Guid.NewGuid().ToString(),
|
|
NamespaceProperty = "the-namespace",
|
|
ResourceVersion = DateTime.Now.Ticks.ToString(),
|
|
},
|
|
});
|
|
}
|
|
|
|
return pods;
|
|
}
|
|
|
|
public static V1PodList CreatePodList(int cnt)
|
|
{
|
|
return new V1PodList()
|
|
{
|
|
ApiVersion = "Pod/V1",
|
|
Kind = "Pod",
|
|
Metadata = new V1ListMeta()
|
|
{
|
|
ResourceVersion = DateTime.Now.Ticks.ToString(),
|
|
},
|
|
Items = CreatePods(cnt).ToList(),
|
|
};
|
|
}
|
|
|
|
public static Kubernetes BuildApiClient(Uri hostAddress)
|
|
{
|
|
return new Kubernetes(new KubernetesClientConfiguration { Host = hostAddress.ToString() })
|
|
{
|
|
HttpClient =
|
|
{
|
|
Timeout = Timeout.InfiniteTimeSpan,
|
|
},
|
|
};
|
|
}
|
|
|
|
public static GenericKubernetesApi BuildGenericApi(Uri hostAddress)
|
|
{
|
|
return new GenericKubernetesApi(
|
|
apiGroup: "pod",
|
|
apiVersion: "v1",
|
|
resourcePlural: "pods",
|
|
apiClient: BuildApiClient(hostAddress));
|
|
}
|
|
}
|
|
}
|