@@ -55,11 +55,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Basic", "s
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Classic", "src\KubernetesClient.Classic\KubernetesClient.Classic.csproj", "{80F19E8A-F097-4AA4-A68C-D417B96BBC68}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Classic", "src\KubernetesClient.Classic\KubernetesClient.Classic.csproj", "{80F19E8A-F097-4AA4-A68C-D417B96BBC68}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KubernetesClient.Classic.Tests", "tests\KubernetesClient.Classic.Tests\KubernetesClient.Classic.Tests.csproj", "{FD90C861-56C6-4536-B7F5-AC7779296384}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Classic.Tests", "tests\KubernetesClient.Classic.Tests\KubernetesClient.Classic.Tests.csproj", "{FD90C861-56C6-4536-B7F5-AC7779296384}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csrApproval", "examples\csrApproval\csrApproval.csproj", "{F626860C-F141-45B3-9DDD-88AD3932ACAF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "csrApproval", "examples\csrApproval\csrApproval.csproj", "{F626860C-F141-45B3-9DDD-88AD3932ACAF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "restart", "examples\restart\restart.csproj", "{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "restart", "examples\restart\restart.csproj", "{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KubernetesClient.Kubectl", "src\KubernetesClient.Kubectl\KubernetesClient.Kubectl.csproj", "{21201F30-5463-4FC6-93C3-FBF157F0D46C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kubectl.Tests", "tests\Kubectl.Tests\Kubectl.Tests.csproj", "{9128F6DC-6B7A-417F-937A-90461D6989A8}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -383,6 +387,30 @@ Global
|
|||||||
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x64.Build.0 = Release|Any CPU
|
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.ActiveCfg = Release|Any CPU
|
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.Build.0 = Release|Any CPU
|
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -414,6 +442,8 @@ Global
|
|||||||
{FD90C861-56C6-4536-B7F5-AC7779296384} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}
|
{FD90C861-56C6-4536-B7F5-AC7779296384} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}
|
||||||
{F626860C-F141-45B3-9DDD-88AD3932ACAF} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
|
{F626860C-F141-45B3-9DDD-88AD3932ACAF} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
|
||||||
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
|
{973CCB4A-F344-4C4F-81A5-0F40F7F43C07} = {B70AFB57-57C9-46DC-84BE-11B7DDD34B40}
|
||||||
|
{21201F30-5463-4FC6-93C3-FBF157F0D46C} = {3D1864AA-1FFC-4512-BB13-46055E410F73}
|
||||||
|
{9128F6DC-6B7A-417F-937A-90461D6989A8} = {8AF4A5C2-F0CE-47D5-A4C5-FE4AB83CA509}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {049A763A-C891-4E8D-80CF-89DD3E22ADC7}
|
SolutionGuid = {049A763A-C891-4E8D-80CF-89DD3E22ADC7}
|
||||||
|
|||||||
7
src/KubernetesClient.Basic/GeneratedApiVersion.cs
Normal file
7
src/KubernetesClient.Basic/GeneratedApiVersion.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace k8s;
|
||||||
|
|
||||||
|
public static class GeneratedApiVersion
|
||||||
|
{
|
||||||
|
public const string AssemblyVersion = ThisAssembly.AssemblyInformationalVersion;
|
||||||
|
public const string SwaggerVersion = ThisAssembly.KubernetesSwaggerVersion;
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" />
|
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" />
|
||||||
<AdditionalFiles Include="..\..\swagger.json" Generator="api" />
|
<AdditionalFiles Include="..\..\swagger.json" Generator="api,version" />
|
||||||
<ProjectReference Include="..\KubernetesClient.Models\KubernetesClient.Models.csproj" />
|
<ProjectReference Include="..\KubernetesClient.Models\KubernetesClient.Models.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
23
src/KubernetesClient.Kubectl/Beta/AsyncKubectl.Version.cs
Normal file
23
src/KubernetesClient.Kubectl/Beta/AsyncKubectl.Version.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using k8s.Models;
|
||||||
|
|
||||||
|
namespace k8s.kubectl.beta;
|
||||||
|
|
||||||
|
public partial class AsyncKubectl
|
||||||
|
{
|
||||||
|
private const string AsssemblyVersion = ThisAssembly.AssemblyInformationalVersion;
|
||||||
|
|
||||||
|
public record KubernetesSDKVersion
|
||||||
|
{
|
||||||
|
public string ClientVersion { get; init; } = AsssemblyVersion;
|
||||||
|
|
||||||
|
public string ClientSwaggerVersion { get; init; } = GeneratedApiVersion.SwaggerVersion;
|
||||||
|
|
||||||
|
public VersionInfo ServerVersion { get; init; } = default!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<KubernetesSDKVersion> Version(CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var serverVersion = await client.GetCodeAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
return new KubernetesSDKVersion { ServerVersion = serverVersion };
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/KubernetesClient.Kubectl/Beta/AsyncKubectl.cs
Normal file
11
src/KubernetesClient.Kubectl/Beta/AsyncKubectl.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace k8s.kubectl.beta;
|
||||||
|
|
||||||
|
public partial class AsyncKubectl
|
||||||
|
{
|
||||||
|
private readonly IKubernetes client;
|
||||||
|
|
||||||
|
public AsyncKubectl(IKubernetes client)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/KubernetesClient.Kubectl/Beta/Kubectl.Version.cs
Normal file
12
src/KubernetesClient.Kubectl/Beta/Kubectl.Version.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using static k8s.kubectl.beta.AsyncKubectl;
|
||||||
|
|
||||||
|
namespace k8s.kubectl.beta;
|
||||||
|
|
||||||
|
public partial class Kubectl
|
||||||
|
{
|
||||||
|
// TODO should auto generate this
|
||||||
|
public KubernetesSDKVersion Version()
|
||||||
|
{
|
||||||
|
return client.Version().GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/KubernetesClient.Kubectl/Beta/Kubectl.cs
Normal file
11
src/KubernetesClient.Kubectl/Beta/Kubectl.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace k8s.kubectl.beta;
|
||||||
|
|
||||||
|
public partial class Kubectl
|
||||||
|
{
|
||||||
|
private readonly AsyncKubectl client;
|
||||||
|
|
||||||
|
public Kubectl(IKubernetes client)
|
||||||
|
{
|
||||||
|
this.client = new AsyncKubectl(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj
Normal file
14
src/KubernetesClient.Kubectl/KubernetesClient.Kubectl.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<RootNamespace>k8s.kubectl</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\KubernetesClient\KubernetesClient.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
7
src/KubernetesClient.Models/GeneratedModelVersion.cs
Normal file
7
src/KubernetesClient.Models/GeneratedModelVersion.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace k8s.Models;
|
||||||
|
|
||||||
|
public static class GeneratedModelVersion
|
||||||
|
{
|
||||||
|
public const string AssemblyVersion = ThisAssembly.AssemblyInformationalVersion;
|
||||||
|
public const string SwaggerVersion = ThisAssembly.KubernetesSwaggerVersion;
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" />
|
<CompilerVisibleItemMetadata Include="AdditionalFiles" MetadataName="Generator" />
|
||||||
<AdditionalFiles Include="..\..\swagger.json" Generator="model,modelext,versionconverter" />
|
<AdditionalFiles Include="..\..\swagger.json" Generator="model,modelext,versionconverter,version" />
|
||||||
<ProjectReference Include="..\LibKubernetesGenerator\LibKubernetesGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
<ProjectReference Include="..\LibKubernetesGenerator\LibKubernetesGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace LibKubernetesGenerator
|
|||||||
builder.RegisterType<ModelGenerator>();
|
builder.RegisterType<ModelGenerator>();
|
||||||
builder.RegisterType<ApiGenerator>();
|
builder.RegisterType<ApiGenerator>();
|
||||||
builder.RegisterType<VersionConverterGenerator>();
|
builder.RegisterType<VersionConverterGenerator>();
|
||||||
|
builder.RegisterType<VersionGenerator>();
|
||||||
|
|
||||||
var container = builder.Build();
|
var container = builder.Build();
|
||||||
// TODO move to Handlebars.Net
|
// TODO move to Handlebars.Net
|
||||||
@@ -100,6 +101,11 @@ namespace LibKubernetesGenerator
|
|||||||
{
|
{
|
||||||
container.Resolve<VersionConverterGenerator>().Generate(swagger, context);
|
container.Resolve<VersionConverterGenerator>().Generate(swagger, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (generators.Contains("version"))
|
||||||
|
{
|
||||||
|
container.Resolve<VersionGenerator>().Generate(swagger, context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
src/LibKubernetesGenerator/VersionGenerator.cs
Normal file
12
src/LibKubernetesGenerator/VersionGenerator.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using NSwag;
|
||||||
|
|
||||||
|
namespace LibKubernetesGenerator;
|
||||||
|
|
||||||
|
internal class VersionGenerator
|
||||||
|
{
|
||||||
|
public void Generate(OpenApiDocument swagger, GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
context.AddSource("k8sver.cs", $"// <auto-generated />\n" + "internal static partial class ThisAssembly { internal const string KubernetesSwaggerVersion = \"" + swagger.Info.Version + "\";}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -17,7 +17,7 @@ using Xunit;
|
|||||||
|
|
||||||
namespace k8s.E2E
|
namespace k8s.E2E
|
||||||
{
|
{
|
||||||
public class MnikubeTests
|
public class MinikubeTests
|
||||||
{
|
{
|
||||||
[MinikubeFact]
|
[MinikubeFact]
|
||||||
public void SimpleTest()
|
public void SimpleTest()
|
||||||
@@ -548,7 +548,7 @@ namespace k8s.E2E
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static IKubernetes CreateClient()
|
public static IKubernetes CreateClient()
|
||||||
{
|
{
|
||||||
return new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig());
|
return new Kubernetes(KubernetesClientConfiguration.BuildDefaultConfig());
|
||||||
}
|
}
|
||||||
39
tests/Kubectl.Tests/Kubectl.Tests.csproj
Normal file
39
tests/Kubectl.Tests/Kubectl.Tests.csproj
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<RootNamespace>k8s.kubectl.Tests</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
|
||||||
|
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
|
||||||
|
<PackageReference Include="Moq" Version="4.17.2" />
|
||||||
|
|
||||||
|
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\src\KubernetesClient.Kubectl\KubernetesClient.Kubectl.csproj" />
|
||||||
|
<ProjectReference Include="..\E2E.Tests\E2E.Tests.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AdditionalFiles Include="..\..\swagger.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</AdditionalFiles>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
32
tests/Kubectl.Tests/KubectlTests.Version.cs
Normal file
32
tests/Kubectl.Tests/KubectlTests.Version.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using k8s.E2E;
|
||||||
|
using System.Text.Json;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace k8s.kubectl.Tests;
|
||||||
|
|
||||||
|
public partial class KubectlTests
|
||||||
|
{
|
||||||
|
[MinikubeFact]
|
||||||
|
public void Version()
|
||||||
|
{
|
||||||
|
var client = CreateClient();
|
||||||
|
var version = client.Version();
|
||||||
|
var serverobj = version.ServerVersion;
|
||||||
|
|
||||||
|
var output = RunKubectl("version");
|
||||||
|
|
||||||
|
var serverstr = output.Split('\n').Skip(1).First().Trim();
|
||||||
|
|
||||||
|
Assert.Equal(serverstr, $"Server Version: version.Info{{Major:\"{serverobj.Major}\", Minor:\"{serverobj.Minor}\", GitVersion:\"{serverobj.GitVersion}\", GitCommit:\"{serverobj.GitCommit}\", GitTreeState:\"{serverobj.GitTreeState}\", BuildDate:\"{serverobj.BuildDate}\", GoVersion:\"{serverobj.GoVersion}\", Compiler:\"{serverobj.Compiler}\", Platform:\"{serverobj.Platform}\"}}");
|
||||||
|
|
||||||
|
dynamic? swagger = JsonSerializer.Deserialize(File.OpenRead("swagger.json"), new
|
||||||
|
{
|
||||||
|
info = new
|
||||||
|
{
|
||||||
|
version = "",
|
||||||
|
},
|
||||||
|
}.GetType());
|
||||||
|
|
||||||
|
Assert.Equal(swagger?.info.version, version.ClientSwaggerVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
tests/Kubectl.Tests/KubectlTests.cs
Normal file
50
tests/Kubectl.Tests/KubectlTests.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using k8s.E2E;
|
||||||
|
using k8s.kubectl.beta;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace k8s.kubectl.Tests;
|
||||||
|
|
||||||
|
public partial class KubectlTests
|
||||||
|
{
|
||||||
|
private Kubectl CreateClient()
|
||||||
|
{
|
||||||
|
return new Kubectl(MinikubeTests.CreateClient());
|
||||||
|
}
|
||||||
|
|
||||||
|
private string RunKubectl(string args)
|
||||||
|
{
|
||||||
|
var p = new Process
|
||||||
|
{
|
||||||
|
StartInfo = new ProcessStartInfo
|
||||||
|
{
|
||||||
|
FileName = "kubectl",
|
||||||
|
Arguments = args,
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true,
|
||||||
|
RedirectStandardError = true,
|
||||||
|
CreateNoWindow = true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
p.Start();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!p.WaitForExit((int)TimeSpan.FromSeconds(30).TotalMilliseconds))
|
||||||
|
{
|
||||||
|
throw new Exception("kubectl timed out");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.ExitCode != 0)
|
||||||
|
{
|
||||||
|
throw new Exception(p.StandardError.ReadToEnd());
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.StandardOutput.ReadToEnd();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
p.Kill(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user