From 937351de1998eea0437e6c21d14f2bcbe9b232f0 Mon Sep 17 00:00:00 2001 From: Ivan Josipovic <9521987+IvanJosipovic@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:03:55 -0800 Subject: [PATCH] feat(PortForwarder): Show Connection Count (#835) * feat(PortForwarder): Show Connection Count * Update cicd.yml * Update cicd.yml --- .github/workflows/cicd.yml | 4 ++++ src/KubeUI/Client/PortForwarder.cs | 6 ++++++ src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index cec1e35e..d1b43823 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -101,6 +101,10 @@ jobs: with: submodules: 'true' + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '8.x.x' + - name: Setup .NET Core uses: actions/setup-dotnet@v4 with: diff --git a/src/KubeUI/Client/PortForwarder.cs b/src/KubeUI/Client/PortForwarder.cs index b47718e9..b1b5b208 100644 --- a/src/KubeUI/Client/PortForwarder.cs +++ b/src/KubeUI/Client/PortForwarder.cs @@ -25,6 +25,9 @@ public partial class PortForwarder : ObservableObject, IEquatable [ObservableProperty] public partial string Status { get; set; } = "Initializing"; + [ObservableProperty] + public partial int Connections { get; set; } + private bool _isDisposing; public PortForwarder(ICluster cluster, string @namespace, int localPort = 0) @@ -80,6 +83,7 @@ private void ClientConnected(IAsyncResult result) private async Task HandleConnection(Socket socket) { + Connections++; var podName = Name; var podPort = Port; if (Type == "Service") @@ -102,6 +106,7 @@ private async Task HandleConnection(Socket socket) { Status = "No pods found for Service"; socket.Close(); + Connections--; return; } else @@ -151,6 +156,7 @@ private async Task HandleConnection(Socket socket) await write; socket.Close(); + Connections--; } private static bool IsPortAvailable(int port) diff --git a/src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs b/src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs index 6807756e..9a121e4a 100644 --- a/src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs +++ b/src/KubeUI/Views/Workloads/Pod/PortForwarderListView.cs @@ -26,6 +26,7 @@ protected override object Build(PortForwarderListViewModel? vm) { Binding = new Binding(nameof(PortForwarder.Name)), Header = "Name", + Width = new DataGridLength(1, DataGridLengthUnitType.Star), }, new DataGridTextColumn() { @@ -43,6 +44,11 @@ protected override object Build(PortForwarderListViewModel? vm) Header = "Local Port", }, new DataGridTextColumn() + { + Binding = new Binding(nameof(PortForwarder.Connections)), + Header = "Connections", + }, + new DataGridTextColumn() { Binding = new Binding(nameof(PortForwarder.Status)), Header = "Status",