Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Visible="false" />
</ItemGroup>
</Project>
4 changes: 3 additions & 1 deletion examples/attach/Attach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private static async Task Main(string[] args)

private async static Task AttachToPod(IKubernetes client, V1Pod pod)
{
var webSocket = await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default", pod.Spec.Containers[0].Name);
var webSocket =
await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default",
pod.Spec.Containers[0].Name);

var demux = new StreamDemuxer(webSocket);
demux.Start();
Expand Down
4 changes: 3 additions & 1 deletion examples/exec/Exec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ private static async Task Main(string[] args)

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 webSocket =
await client.WebSocketNamespacedPodExecAsync(pod.Metadata.Name, "default", "ls",
pod.Spec.Containers[0].Name);

var demux = new StreamDemuxer(webSocket);
demux.Start();
Expand Down
1 change: 1 addition & 0 deletions examples/httpClientFactory/PodListHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogInformation(item.Metadata.Name);
}

if (list.Items.Count == 0)
{
_logger.LogInformation("Empty!");
Expand Down
5 changes: 1 addition & 4 deletions examples/httpClientFactory/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ public static async Task Main(string[] args)
{
// Learn more about generic hosts at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host
using (var host = new HostBuilder()
.ConfigureLogging((logging) =>
{
logging.AddConsole();
})
.ConfigureLogging((logging) => { logging.AddConsole(); })
.ConfigureServices((hostBuilderContext, services) =>
{
// Ideally this config would be read from the .net core config constructs,
Expand Down
4 changes: 4 additions & 0 deletions examples/labels/PodList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ private static void Main(string[] args)
{
continue;
}

var labels = new List<string>();
foreach (var key in item.Spec.Selector)
{
labels.Add(key.Key + "=" + key.Value);
}

var labelStr = string.Join(",", labels.ToArray());
Console.WriteLine(labelStr);
var podList = client.ListNamespacedPod("default", labelSelector: labelStr);
foreach (var pod in podList.Items)
{
Console.WriteLine(pod.Metadata.Name);
}

if (podList.Items.Count == 0)
{
Console.WriteLine("Empty!");
}

Console.WriteLine();
}
}
Expand Down
4 changes: 3 additions & 1 deletion examples/logs/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ private static async Task Main(string[] args)
Console.WriteLine("No pods!");
return;
}

var pod = list.Items[0];

var response = await client.ReadNamespacedPodLogWithHttpMessagesAsync(pod.Metadata.Name, pod.Metadata.NamespaceProperty, follow: true);
var response = await client.ReadNamespacedPodLogWithHttpMessagesAsync(pod.Metadata.Name,
pod.Metadata.NamespaceProperty, follow: true);
var stream = response.Body;
stream.CopyTo(Console.OpenStandardOutput());
}
Expand Down
11 changes: 4 additions & 7 deletions examples/namespace/Namespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ static void ListNamespaces(IKubernetes client)
{
Console.WriteLine(item.Metadata.Name);
}

if (list.Items.Count == 0)
{
Console.WriteLine("Empty!");
Expand All @@ -41,6 +42,7 @@ static async Task DeleteAsync(IKubernetes client, string name, int delayMillis)
{
return;
}

throw ex;
}
}
Expand All @@ -51,6 +53,7 @@ static async Task DeleteAsync(IKubernetes client, string name, int delayMillis)
{
return;
}

throw ex;
}
}
Expand All @@ -68,13 +71,7 @@ private static void Main(string[] args)

ListNamespaces(client);

var ns = new V1Namespace
{
Metadata = new V1ObjectMeta
{
Name = "test"
}
};
var ns = new V1Namespace { Metadata = new V1ObjectMeta { Name = "test" } };

var result = client.CreateNamespace(ns);
Console.WriteLine(result);
Expand Down
6 changes: 2 additions & 4 deletions examples/patch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ private static void Main(string[] args)
var name = pod.Metadata.Name;
PrintLabels(pod);

var newlabels = new Dictionary<string, string>(pod.Metadata.Labels)
{
["test"] = "test"
};
var newlabels = new Dictionary<string, string>(pod.Metadata.Labels) { ["test"] = "test" };
var patch = new JsonPatchDocument<V1Pod>();
patch.Replace(e => e.Metadata.Labels, newlabels);
client.PatchNamespacedPod(new V1Patch(patch), name, "default");
Expand All @@ -38,6 +35,7 @@ private static void PrintLabels(V1Pod pod)
{
Console.WriteLine($"{k} : {v}");
}

Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/simple/PodList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ private static void Main(string[] args)
{
Console.WriteLine(item.Metadata.Name);
}

if (list.Items.Count == 0)
{
Console.WriteLine("Empty!");
Expand Down
Loading