Fix some compilation warnings (#1010)
* Fixe some summary warning * Fixed more warning * Uniformed example projects code * Uniformed test projects code * Fix OperatingSystems enum and GenericType summaries
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace attach
|
||||
{
|
||||
@@ -18,7 +18,7 @@ namespace attach
|
||||
await AttachToPod(client, pod).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async static Task AttachToPod(IKubernetes client, V1Pod pod)
|
||||
private static async Task AttachToPod(IKubernetes client, V1Pod pod)
|
||||
{
|
||||
var webSocket =
|
||||
await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using k8s;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace cp
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System.Net;
|
||||
using Json.Patch;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Json.Patch;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
|
||||
string GenerateCertificate(string name)
|
||||
{
|
||||
@@ -18,10 +18,10 @@ string GenerateCertificate(string name)
|
||||
var distinguishedName = new X500DistinguishedName(name);
|
||||
|
||||
using var rsa = RSA.Create(4096);
|
||||
var request = new CertificateRequest(distinguishedName, rsa, HashAlgorithmName.SHA256,RSASignaturePadding.Pkcs1);
|
||||
var request = new CertificateRequest(distinguishedName, rsa, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
|
||||
|
||||
request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DataEncipherment | X509KeyUsageFlags.KeyEncipherment | X509KeyUsageFlags.DigitalSignature , false));
|
||||
request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection { new ("1.3.6.1.5.5.7.3.1") }, false));
|
||||
request.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.DataEncipherment | X509KeyUsageFlags.KeyEncipherment | X509KeyUsageFlags.DigitalSignature, false));
|
||||
request.CertificateExtensions.Add(new X509EnhancedKeyUsageExtension(new OidCollection { new("1.3.6.1.5.5.7.3.1") }, false));
|
||||
request.CertificateExtensions.Add(sanBuilder.Build());
|
||||
var csr = request.CreateSigningRequest();
|
||||
var pemKey = "-----BEGIN CERTIFICATE REQUEST-----\r\n" +
|
||||
@@ -36,7 +36,7 @@ IKubernetes client = new Kubernetes(config);
|
||||
Console.WriteLine("Starting Request!");
|
||||
var name = "demo";
|
||||
var x509 = GenerateCertificate(name);
|
||||
var encodedCsr= Encoding.UTF8.GetBytes(x509);
|
||||
var encodedCsr = Encoding.UTF8.GetBytes(x509);
|
||||
|
||||
var request = new V1CertificateSigningRequest
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace exec
|
||||
{
|
||||
@@ -18,7 +18,7 @@ namespace exec
|
||||
await ExecInPod(client, pod).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async static Task ExecInPod(IKubernetes client, V1Pod pod)
|
||||
private static async Task ExecInPod(IKubernetes client, V1Pod pod)
|
||||
{
|
||||
var webSocket =
|
||||
await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace exec
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using k8s;
|
||||
|
||||
namespace simple
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
|
||||
namespace logs
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
|
||||
namespace @namespace
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace patch
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
|
||||
namespace portforward
|
||||
{
|
||||
@@ -21,9 +21,10 @@ namespace portforward
|
||||
await Forward(client, pod);
|
||||
}
|
||||
|
||||
private async static Task Forward(IKubernetes client, V1Pod pod) {
|
||||
private static async Task Forward(IKubernetes client, V1Pod pod)
|
||||
{
|
||||
// Note this is single-threaded, it won't handle concurrent requests well...
|
||||
var webSocket = await client.WebSocketNamespacedPodPortForwardAsync(pod.Metadata.Name, "default", new int[] {80}, "v4.channel.k8s.io");
|
||||
var webSocket = await client.WebSocketNamespacedPodPortForwardAsync(pod.Metadata.Name, "default", new int[] { 80 }, "v4.channel.k8s.io");
|
||||
var demux = new StreamDemuxer(webSocket, StreamType.PortForward);
|
||||
demux.Start();
|
||||
|
||||
@@ -38,23 +39,29 @@ namespace portforward
|
||||
Socket handler = null;
|
||||
|
||||
// Note this will only accept a single connection
|
||||
var accept = Task.Run(() => {
|
||||
while (true) {
|
||||
var accept = Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
handler = listener.Accept();
|
||||
var bytes = new byte[4096];
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
int bytesRec = handler.Receive(bytes);
|
||||
stream.Write(bytes, 0, bytesRec);
|
||||
if (bytesRec == 0 || Encoding.ASCII.GetString(bytes,0,bytesRec).IndexOf("<EOF>") > -1) {
|
||||
if (bytesRec == 0 || Encoding.ASCII.GetString(bytes, 0, bytesRec).IndexOf("<EOF>") > -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var copy = Task.Run(() => {
|
||||
var copy = Task.Run(() =>
|
||||
{
|
||||
var buff = new byte[4096];
|
||||
while (true) {
|
||||
while (true)
|
||||
{
|
||||
var read = stream.Read(buff, 0, 4096);
|
||||
handler.Send(buff, read, 0);
|
||||
}
|
||||
@@ -62,7 +69,8 @@ namespace portforward
|
||||
|
||||
await accept;
|
||||
await copy;
|
||||
if (handler != null) {
|
||||
if (handler != null)
|
||||
{
|
||||
handler.Close();
|
||||
}
|
||||
listener.Close();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using k8s;
|
||||
using k8s.Monitoring;
|
||||
using Prometheus;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
|
||||
namespace prom
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Json.Patch;
|
||||
using Json.Patch;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System.Text.Json;
|
||||
|
||||
async Task RestartDaemonSetAsync(string name, string @namespace, IKubernetes client)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using k8s;
|
||||
using System;
|
||||
|
||||
namespace simple
|
||||
{
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
|
||||
namespace watch
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private async static Task Main(string[] args)
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using k8s;
|
||||
using k8s.Models;
|
||||
|
||||
namespace yaml
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private async static Task Main(string[] args)
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
var typeMap = new Dictionary<String, Type>();
|
||||
typeMap.Add("v1/Pod", typeof(V1Pod));
|
||||
@@ -17,7 +17,8 @@ namespace yaml
|
||||
|
||||
var objects = await KubernetesYaml.LoadAllFromFileAsync(args[0], typeMap);
|
||||
|
||||
foreach (var obj in objects) {
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
Console.WriteLine(obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace k8s
|
||||
/// <returns>the metrics <see cref="PodMetricsList"/></returns>
|
||||
public static async Task<NodeMetricsList> GetKubernetesNodesMetricsAsync(this IKubernetes kubernetes)
|
||||
{
|
||||
if (kubernetes is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kubernetes));
|
||||
}
|
||||
|
||||
var customObject = (JsonElement)await kubernetes.CustomObjects.GetClusterCustomObjectAsync("metrics.k8s.io", "v1beta1", "nodes", string.Empty).ConfigureAwait(false);
|
||||
return customObject.Deserialize<NodeMetricsList>();
|
||||
}
|
||||
@@ -26,6 +31,11 @@ namespace k8s
|
||||
/// <returns>the metrics <see cref="PodMetricsList"/></returns>
|
||||
public static async Task<PodMetricsList> GetKubernetesPodsMetricsAsync(this IKubernetes kubernetes)
|
||||
{
|
||||
if (kubernetes is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kubernetes));
|
||||
}
|
||||
|
||||
var customObject = (JsonElement)await kubernetes.CustomObjects.GetClusterCustomObjectAsync("metrics.k8s.io", "v1beta1", "pods", string.Empty).ConfigureAwait(false);
|
||||
return customObject.Deserialize<PodMetricsList>();
|
||||
}
|
||||
@@ -38,6 +48,11 @@ namespace k8s
|
||||
/// <returns>the metrics <see cref="PodMetricsList"/></returns>
|
||||
public static async Task<PodMetricsList> GetKubernetesPodsMetricsByNamespaceAsync(this IKubernetes kubernetes, string namespaceParameter)
|
||||
{
|
||||
if (kubernetes is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(kubernetes));
|
||||
}
|
||||
|
||||
var customObject = (JsonElement)await kubernetes.CustomObjects.GetNamespacedCustomObjectAsync("metrics.k8s.io", "v1beta1", namespaceParameter, "pods", string.Empty).ConfigureAwait(false);
|
||||
return customObject.Deserialize<PodMetricsList>();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Models;
|
||||
|
||||
namespace k8s.LeaderElection.ResourceLock
|
||||
{
|
||||
@@ -15,6 +15,11 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.ReadNamespacedConfigMapAsync(name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
@@ -22,6 +27,11 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.CreateNamespacedConfigMapAsync(obj, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
@@ -29,8 +39,12 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
return client.CoreV1.ReplaceNamespacedConfigMapAsync(obj, name, namespaceParameter,
|
||||
cancellationToken: cancellationToken);
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.ReplaceNamespacedConfigMapAsync(obj, name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Models;
|
||||
|
||||
namespace k8s.LeaderElection.ResourceLock
|
||||
{
|
||||
@@ -13,18 +13,33 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
|
||||
protected override Task<V1Endpoints> ReadMetaObjectAsync(IKubernetes client, string name, string namespaceParameter, CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.ReadNamespacedEndpointsAsync(name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task<V1Endpoints> CreateMetaObjectAsync(IKubernetes client, V1Endpoints obj, string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.CreateNamespacedEndpointsAsync(obj, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task<V1Endpoints> ReplaceMetaObjectAsync(IKubernetes client, V1Endpoints obj, string name, string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoreV1.ReplaceNamespacedEndpointsAsync(obj, name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Models;
|
||||
|
||||
namespace k8s.LeaderElection.ResourceLock
|
||||
{
|
||||
@@ -14,6 +14,11 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
protected override Task<V1Lease> ReadMetaObjectAsync(IKubernetes client, string name, string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoordinationV1.ReadNamespacedLeaseAsync(name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
@@ -61,12 +66,22 @@ namespace k8s.LeaderElection.ResourceLock
|
||||
protected override Task<V1Lease> CreateMetaObjectAsync(IKubernetes client, V1Lease obj, string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoordinationV1.CreateNamespacedLeaseAsync(obj, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
protected override Task<V1Lease> ReplaceMetaObjectAsync(IKubernetes client, V1Lease obj, string name, string namespaceParameter,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (client is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(client));
|
||||
}
|
||||
|
||||
return client.CoordinationV1.ReplaceNamespacedLeaseAsync(obj, name, namespaceParameter, cancellationToken: cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using Json.Patch;
|
||||
using k8s.Autorest;
|
||||
using k8s.LeaderElection;
|
||||
using k8s.LeaderElection.ResourceLock;
|
||||
using k8s.Models;
|
||||
using Nito.AsyncEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Json.Patch;
|
||||
using k8s.LeaderElection;
|
||||
using k8s.LeaderElection.ResourceLock;
|
||||
using k8s.Models;
|
||||
using k8s.Autorest;
|
||||
using Nito.AsyncEx;
|
||||
using Xunit;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace k8s.E2E
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using k8s.Models;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using k8s.Models;
|
||||
|
||||
namespace k8s.tests;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class BasicTests
|
||||
// TODO: fail to setup asp.net core 6 on net48
|
||||
private class DummyHttpServer : System.IDisposable
|
||||
{
|
||||
private TcpListener server;
|
||||
private readonly TcpListener server;
|
||||
private readonly Task loop;
|
||||
private volatile bool running = false;
|
||||
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
using k8s.Authentication;
|
||||
using k8s.Autorest;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using k8s.Models;
|
||||
using k8s.Tests.Mock;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Pkcs;
|
||||
using Org.BouncyCastle.Security;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -9,17 +20,6 @@ using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Authentication;
|
||||
using k8s.Exceptions;
|
||||
using k8s.KubeConfigModels;
|
||||
using k8s.Models;
|
||||
using k8s.Tests.Mock;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Https;
|
||||
using k8s.Autorest;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Pkcs;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
||||
@@ -244,8 +244,7 @@ namespace k8s.Tests
|
||||
/// Tests a call to <see cref="ByteBuffer.Read(byte[], int, int)"/> when no data is available; and makes
|
||||
/// sure the call blocks until data is available.
|
||||
/// </summary>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous unit test.</placeholder></returns>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous unit test.</placeholder></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
|
||||
[Fact]
|
||||
public async Task ReadBlocksUntilDataAvailableTest()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using k8s.KubeConfigModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using k8s.KubeConfigModels;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using FluentAssertions;
|
||||
using k8s.Authentication;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using k8s.Authentication;
|
||||
|
||||
namespace k8s.Tests
|
||||
{
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Check if host is properly loaded, per context
|
||||
/// </summary>
|
||||
/// <param name="context">Context to retreive the configuration</param>
|
||||
/// <param name="host">Host to check</param>
|
||||
[Theory]
|
||||
[InlineData("federal-context", "https://horse.org:4443")]
|
||||
[InlineData("queen-anne-context", "https://pig.org:443")]
|
||||
@@ -46,6 +48,8 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Check if namespace is properly loaded, per context
|
||||
/// </summary>
|
||||
/// <param name="context">Context to retreive the configuration</param>
|
||||
/// <param name="namespace">Namespace to check</param>
|
||||
[Theory]
|
||||
[InlineData("federal-context", "chisel-ns")]
|
||||
[InlineData("queen-anne-context", "saw-ns")]
|
||||
@@ -59,8 +63,8 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Checks if user-based token is loaded properly from the config file, per context
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="context">Context to retreive the configuration</param>
|
||||
/// <param name="token">User authentication token</param>
|
||||
[Theory]
|
||||
[InlineData("queen-anne-context", "black-token")]
|
||||
public void ContextUserToken(string context, string token)
|
||||
@@ -92,7 +96,7 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Checks for loading of elliptical curve keys
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="context">Context to retreive the configuration</param>
|
||||
[Theory]
|
||||
[InlineData("elliptic-context")]
|
||||
public void ContextEllipticKey(string context)
|
||||
@@ -383,11 +387,10 @@ namespace k8s.Tests
|
||||
[Fact]
|
||||
public void DefaultConfigurationAsStreamLoaded()
|
||||
{
|
||||
using (var stream = File.OpenRead("assets/kubeconfig.yml"))
|
||||
{
|
||||
var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(stream);
|
||||
Assert.NotNull(cfg.Host);
|
||||
}
|
||||
using var stream = File.OpenRead("assets/kubeconfig.yml");
|
||||
|
||||
var cfg = KubernetesClientConfiguration.BuildConfigFromConfigFile(stream);
|
||||
Assert.NotNull(cfg.Host);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -408,7 +411,7 @@ namespace k8s.Tests
|
||||
{
|
||||
var path = Path.GetFullPath("assets/kubeconfig.cluster-extensions.yml");
|
||||
|
||||
var cfg = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(path)).ConfigureAwait(false);
|
||||
_ = await KubernetesClientConfiguration.BuildConfigFromConfigFileAsync(new FileInfo(path)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using k8s.LeaderElection;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.LeaderElection;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
||||
@@ -26,11 +26,6 @@ namespace k8s.Tests.Logging
|
||||
/// </param>
|
||||
public TestOutputLogger(ITestOutputHelper testOutput, string loggerCategory, LogLevel minLogLevel)
|
||||
{
|
||||
if (testOutput == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(testOutput));
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(loggerCategory))
|
||||
{
|
||||
throw new ArgumentException(
|
||||
@@ -38,7 +33,7 @@ namespace k8s.Tests.Logging
|
||||
nameof(loggerCategory));
|
||||
}
|
||||
|
||||
TestOutput = testOutput;
|
||||
TestOutput = testOutput ?? throw new ArgumentNullException(nameof(testOutput));
|
||||
LoggerCategory = loggerCategory;
|
||||
MinLogLevel = minLogLevel;
|
||||
}
|
||||
@@ -61,6 +56,7 @@ namespace k8s.Tests.Logging
|
||||
/// <summary>
|
||||
/// Emit a log entry.
|
||||
/// </summary>
|
||||
/// <typeparam name="TState">Type of state to log.</typeparam>
|
||||
/// <param name="level">
|
||||
/// The log entry's level.
|
||||
/// </param>
|
||||
@@ -124,6 +120,7 @@ namespace k8s.Tests.Logging
|
||||
/// <summary>
|
||||
/// Begin a logical operation scope.
|
||||
/// </summary>
|
||||
/// <typeparam name="TState">Type of state to log.</typeparam>
|
||||
/// <param name="state">
|
||||
/// An identifier for the scope.
|
||||
/// </param>
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Tests.Logging;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@@ -10,6 +6,10 @@ using Microsoft.AspNetCore.Hosting.Server.Features;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace k8s.Tests.Mock
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace k8s.Tests.Mock
|
||||
private WebSocketCloseStatus? closeStatus;
|
||||
private string closeStatusDescription;
|
||||
private WebSocketState state;
|
||||
private string subProtocol;
|
||||
private ConcurrentQueue<MessageData> receiveBuffers = new ConcurrentQueue<MessageData>();
|
||||
private AsyncAutoResetEvent receiveEvent = new AsyncAutoResetEvent(false);
|
||||
private readonly string subProtocol;
|
||||
private readonly ConcurrentQueue<MessageData> receiveBuffers = new ConcurrentQueue<MessageData>();
|
||||
private readonly AsyncAutoResetEvent receiveEvent = new AsyncAutoResetEvent(false);
|
||||
private bool disposedValue;
|
||||
|
||||
public MockWebSocket(string subProtocol = null)
|
||||
|
||||
@@ -20,12 +20,7 @@ namespace k8s.Tests.Mock.Server.Controllers
|
||||
/// </param>
|
||||
public PodExecController(WebSocketTestAdapter webSocketTestAdapter)
|
||||
{
|
||||
if (webSocketTestAdapter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(webSocketTestAdapter));
|
||||
}
|
||||
|
||||
WebSocketTestAdapter = webSocketTestAdapter;
|
||||
WebSocketTestAdapter = webSocketTestAdapter ?? throw new ArgumentNullException(nameof(webSocketTestAdapter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,8 +37,7 @@ namespace k8s.Tests.Mock.Server.Controllers
|
||||
/// <param name="podName">
|
||||
/// The target pod's name.
|
||||
/// </param>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
[Route("namespaces/{kubeNamespace}/pods/{podName}/exec")]
|
||||
public async Task<IActionResult> Exec(string kubeNamespace, string podName)
|
||||
{
|
||||
|
||||
@@ -21,12 +21,7 @@ namespace k8s.Tests.Mock.Server.Controllers
|
||||
/// </param>
|
||||
public PodPortForwardController(WebSocketTestAdapter webSocketTestAdapter)
|
||||
{
|
||||
if (webSocketTestAdapter == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(webSocketTestAdapter));
|
||||
}
|
||||
|
||||
WebSocketTestAdapter = webSocketTestAdapter;
|
||||
WebSocketTestAdapter = webSocketTestAdapter ?? throw new ArgumentNullException(nameof(webSocketTestAdapter));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,8 +41,7 @@ namespace k8s.Tests.Mock.Server.Controllers
|
||||
/// <param name="ports">
|
||||
/// The port(s) to forward to the pod.
|
||||
/// </param>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||
[Route("namespaces/{kubeNamespace}/pods/{podName}/portforward")]
|
||||
public async Task<IActionResult> Exec(string kubeNamespace, string podName, IEnumerable<string> ports)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using k8s.Authentication;
|
||||
using k8s.Exceptions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -5,8 +5,13 @@ namespace k8s.Tests
|
||||
[Flags]
|
||||
public enum OperatingSystems
|
||||
{
|
||||
/// <summary>Windows operating system.</summary>
|
||||
Windows = 1,
|
||||
|
||||
/// <summary>Linux operating system.</summary>
|
||||
Linux = 2,
|
||||
|
||||
/// <summary>OSX operating system.</summary>
|
||||
OSX = 4,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
* These tests are for the netcoreapp2.1 version of the client (there are separate tests for netstandard that don't actually connect to a server).
|
||||
*/
|
||||
|
||||
using k8s.Models;
|
||||
using k8s.Autorest;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -42,8 +42,7 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Verify that the client can request execution of a command in a pod's default container, with only the STDOUT stream enabled.
|
||||
/// </summary>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous unit test.</placeholder></returns>
|
||||
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous unit test.</placeholder></returns>
|
||||
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
|
||||
[Fact(DisplayName = "Can exec in pod's default container, STDOUT only")]
|
||||
public async Task ExecDefaultContainerStdOut()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using k8s.Models;
|
||||
using System;
|
||||
using Xunit;
|
||||
using static k8s.Models.ResourceQuantity.SuffixFormat;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using k8s.Tests.Mock;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.WebSockets;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Tests.Mock;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using FluentAssertions;
|
||||
using k8s.Authentication;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using k8s.Authentication;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Xunit;
|
||||
using AutoMapper;
|
||||
using FluentAssertions;
|
||||
using k8s.Versioning;
|
||||
using AutoMapper;
|
||||
using Xunit;
|
||||
|
||||
namespace k8s.Tests
|
||||
{
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
using k8s.Models;
|
||||
using k8s.Tests.Mock;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Nito.AsyncEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -7,10 +11,6 @@ using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using k8s.Models;
|
||||
using k8s.Tests.Mock;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Nito.AsyncEx;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using k8s.Autorest;
|
||||
using k8s.Tests.Logging;
|
||||
using k8s.Tests.Mock.Server;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using k8s.Autorest;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.WebSockets;
|
||||
@@ -107,7 +107,7 @@ namespace k8s.Tests
|
||||
/// <summary>
|
||||
/// Configure logging for the test server.
|
||||
/// </summary>
|
||||
/// <param name="services">
|
||||
/// <param name="logging">
|
||||
/// The logger factory to configure.
|
||||
/// </param>
|
||||
protected virtual void ConfigureTestServerLogging(ILoggingBuilder logging)
|
||||
@@ -276,9 +276,6 @@ namespace k8s.Tests
|
||||
/// <param name="webSocket">
|
||||
/// The target <see cref="WebSocket"/>.
|
||||
/// </param>
|
||||
/// <param name="text">
|
||||
/// The text to send.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// A tuple containing the received text, 0-based substream index, and total bytes received.
|
||||
/// </returns>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
|
||||
|
||||
namespace k8s.E2E
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user