Add in formatting pre-check. (#431)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user