Add in formatting pre-check. (#431)

This commit is contained in:
Brendan Burns
2020-04-22 12:15:45 -07:00
committed by GitHub
parent 56b7f76d6c
commit c1de779933
32 changed files with 125 additions and 81 deletions

View File

@@ -21,7 +21,8 @@ namespace attach
await AttachToPod(client, pod);
}
private async static Task AttachToPod(IKubernetes client, V1Pod pod) {
private async static Task AttachToPod(IKubernetes client, V1Pod pod)
{
var webSocket = await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default", pod.Spec.Containers[0].Name);
var demux = new StreamDemuxer(webSocket);

View File

@@ -18,7 +18,8 @@ namespace exec
await ExecInPod(client, pod);
}
private async static Task ExecInPod(IKubernetes client, V1Pod pod) {
private async static Task ExecInPod(IKubernetes client, V1Pod pod)
{
var webSocket = await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls", pod.Spec.Containers[0].Name);
var demux = new StreamDemuxer(webSocket);

View File

@@ -14,7 +14,8 @@ namespace logs
Console.WriteLine("Starting Request!");
var list = client.ListNamespacedPod("default");
if (list.Items.Count == 0) {
if (list.Items.Count == 0)
{
Console.WriteLine("No pods!");
return;
}

View File

@@ -8,34 +8,47 @@ namespace @namespace
{
class NamespaceExample
{
static void ListNamespaces(IKubernetes client) {
static void ListNamespaces(IKubernetes client)
{
var list = client.ListNamespace();
foreach (var item in list.Items) {
foreach (var item in list.Items)
{
Console.WriteLine(item.Metadata.Name);
}
if (list.Items.Count == 0) {
if (list.Items.Count == 0)
{
Console.WriteLine("Empty!");
}
}
static async Task DeleteAsync(IKubernetes client, string name, int delayMillis) {
while (true) {
static async Task DeleteAsync(IKubernetes client, string name, int delayMillis)
{
while (true)
{
await Task.Delay(delayMillis);
try
{
await client.ReadNamespaceAsync(name);
} catch (AggregateException ex) {
foreach (var innerEx in ex.InnerExceptions) {
if (innerEx is Microsoft.Rest.HttpOperationException) {
}
catch (AggregateException ex)
{
foreach (var innerEx in ex.InnerExceptions)
{
if (innerEx is Microsoft.Rest.HttpOperationException)
{
var code = ((Microsoft.Rest.HttpOperationException)innerEx).Response.StatusCode;
if (code == HttpStatusCode.NotFound) {
if (code == HttpStatusCode.NotFound)
{
return;
}
throw ex;
}
}
} catch (Microsoft.Rest.HttpOperationException ex) {
if (ex.Response.StatusCode == HttpStatusCode.NotFound) {
}
catch (Microsoft.Rest.HttpOperationException ex)
{
if (ex.Response.StatusCode == HttpStatusCode.NotFound)
{
return;
}
throw ex;
@@ -43,7 +56,8 @@ namespace @namespace
}
}
static void Delete(IKubernetes client, string name, int delayMillis) {
static void Delete(IKubernetes client, string name, int delayMillis)
{
DeleteAsync(client, name, delayMillis).Wait();
}