-
Notifications
You must be signed in to change notification settings - Fork 305
Implementing a more modular API #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a more modular API in response to the referenced issue by reorganizing and extending the client set generation functionality while also fixing a minor parameter naming typo.
- Corrected the websocket protocol parameter typo in test and client code.
- Introduced a new ClientSetGenerator to modularize client generation.
- Adjusted access modifiers (from protected to internal) for key HTTP methods and classes.
Reviewed Changes
Copilot reviewed 10 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/KubernetesClient.Tests/PodExecTests.cs | Fixed a typo in the websocket protocol parameter name. |
src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs | Minor formatting adjustments during container registrations. |
src/LibKubernetesGenerator/ClientSetGenerator.cs | Added client set generation functionality with parameter renaming logic for duplicates. |
src/KubernetesClient/Kubernetes.cs | Changed method access modifier from protected to internal. |
src/KubernetesClient/Kubernetes.WebSocket.cs | Fixed parameter typo for the websocket protocol name. |
src/KubernetesClient/GenericClient.cs | Introduced a minor format change with no functional impact. |
src/KubernetesClient/ClientSets/ResourceClient.cs | Added a new abstract resource client. |
src/KubernetesClient/ClientSets/ClientSet.cs | Introduced a new partial ClientSet class for client grouping. |
src/KubernetesClient/AbstractKubernetes.cs | Updated access modifiers for core HTTP methods and inner classes. |
examples/clientset/Program.cs | Added an example to illustrate how the new client set can be used. |
Files not reviewed (7)
- examples/clientset/clientset.csproj: Language not supported
- src/KubernetesClient.Aot/KubernetesClient.Aot.csproj: Language not supported
- src/KubernetesClient.Classic/KubernetesClient.Classic.csproj: Language not supported
- src/LibKubernetesGenerator/templates/Client.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/ClientExtensions.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/ClientSet.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/GroupClient.cs.template: Language not supported
Comments suppressed due to low confidence (2)
src/LibKubernetesGenerator/ClientSetGenerator.cs:30
- [nitpick] Consider renaming the variable 'i' to a more descriptive name (e.g. 'dupCounter') to improve code clarity when handling duplicate parameter names.
var i = 1;
tests/KubernetesClient.Tests/PodExecTests.cs:69
- The parameter name 'webSocketSubProtocol' is now correctly spelled. Verify that all references and tests have been updated accordingly.
webSocketSubProtocol: WebSocketProtocol.ChannelWebSocketProtocol,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding [deprecated] to older style?
I think it can be marked as obsolete/deprecated after a few versions |
Currently, the I've been tracking the Kubernetes OpenAPI Swagger specifications in the GitHub repository and noticed the recent addition of a In the latest commit, I've introduced the https://raw.githubusercontent.com/kubernetes/kubernetes/refs/heads/master/api/openapi-spec/swagger.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cloud you please also cleanup new style warnings?
i will take a deeper look at large files, please allow me more time to review
thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a more modular API by updating naming consistency, adding new source generator components, and introducing new client set implementations along with corresponding tests and examples.
- Corrects inconsistent parameter naming (e.g., webSocketSubProtol to webSocketSubProtocol)
- Registers and implements a new ClientSetGenerator to modularize client creation
- Adds new client set classes and an example demonstrating usage
Reviewed Changes
Copilot reviewed 8 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/KubernetesClient.Tests/PodExecTests.cs | Fixes a typo in a parameter name for consistency in websocket protocol usage. |
src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs | Registers the new ClientSetGenerator for source generation. |
src/LibKubernetesGenerator/GeneralNameHelper.cs | Introduces GetActionName and updates script imports accordingly. |
src/LibKubernetesGenerator/ClientSetGenerator.cs | Adds a new generator class for client sets with parameter deduplication logic; consider clarifying variable naming. |
src/KubernetesClient/Kubernetes.WebSocket.cs | Updates parameter naming to ensure consistency with naming conventions. |
src/KubernetesClient/ClientSets/ResourceClient.cs | Adds an abstract base class for resource clients. |
src/KubernetesClient/ClientSets/ClientSet.cs | Adds a partial class for client set management. |
examples/clientset/Program.cs | Provides an example to demonstrate the usage of the new client set API. |
Files not reviewed (8)
- Directory.Packages.props: Language not supported
- examples/clientset/clientset.csproj: Language not supported
- src/KubernetesClient.Aot/KubernetesClient.Aot.csproj: Language not supported
- src/KubernetesClient.Classic/KubernetesClient.Classic.csproj: Language not supported
- src/LibKubernetesGenerator/LibKubernetesGenerator.target: Language not supported
- src/LibKubernetesGenerator/templates/Client.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/ClientSet.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/GroupClient.cs.template: Language not supported
Comments suppressed due to low confidence (1)
src/LibKubernetesGenerator/ClientSetGenerator.cs:29
- [nitpick] The variable name 'name' is ambiguous in this context as it represents a collection of parameter names. Consider renaming it to 'seenParameterNames' or a similarly descriptive identifier.
var name = new HashSet<string>();
I'm on vacation this week so might not get to these changes right away. I'll go through them all once I'm back next week. Really appreciate you taking the time to review! |
Warning style code cleared |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, some comments
and also, could you please add some basic pod CRUD tests in E2E?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a more modular API by introducing a new ClientSet along with updates to the code-generation tools and websocket methods.
- Fixed websocket parameter naming typos.
- Added a new ClientSetGenerator and integrated its usage into code generation.
- Added an end-to-end test for the new ClientSet functionality (note a potential typo in hardcoded string values).
Reviewed Changes
Copilot reviewed 9 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/KubernetesClient.Tests/PodExecTests.cs | Fixed a typo in the parameter name for websocket protocol. |
tests/E2E.Tests/MinikubeTests.cs | Introduced a new ClientSetTest method; potential spelling issues in pod name and label values. |
src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs | Registered the new ClientSetGenerator for code generation. |
src/LibKubernetesGenerator/GeneralNameHelper.cs | Renamed GetMethodName to GetOperationId and added a new GetActionName helper. |
src/LibKubernetesGenerator/ClientSetGenerator.cs | Added a new class to generate client set code. |
src/KubernetesClient/Kubernetes.WebSocket.cs | Fixed websocket parameter naming issues in multiple methods. |
src/KubernetesClient/ClientSets/ResourceClient.cs | Added a new abstract ResourceClient base class. |
src/KubernetesClient/ClientSets/ClientSet.cs | Added a new partial ClientSet class. |
examples/clientset/Program.cs | Provided an example demonstrating the new ClientSet usage. |
Files not reviewed (11)
- Directory.Packages.props: Language not supported
- examples/clientset/clientset.csproj: Language not supported
- src/KubernetesClient.Aot/KubernetesClient.Aot.csproj: Language not supported
- src/KubernetesClient.Classic/KubernetesClient.Classic.csproj: Language not supported
- src/LibKubernetesGenerator/LibKubernetesGenerator.target: Language not supported
- src/LibKubernetesGenerator/templates/Client.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/ClientSet.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/GroupClient.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/IOperations.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/Operations.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template: Language not supported
Comments suppressed due to low confidence (2)
tests/E2E.Tests/MinikubeTests.cs:592
- [nitpick] The podName value 'k8scsharp-e2e-clinetset-pod' appears to contain a typo ('clinetset' should likely be 'clientset'). Consider updating it for clarity.
var podName = "k8scsharp-e2e-clinetset-pod";
tests/E2E.Tests/MinikubeTests.cs:643
- [nitpick] The label value 'clinetset-test-jsonpatch' appears to contain a typo ('clinetset' should likely be 'clientset'). Consider correcting it.
var newLabels = new Dictionary<string, string>(pod.Metadata.Labels) { ["test"] = "clinetset-test-jsonpatch" };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a modular ClientSet API for the C# Kubernetes client by adding a generator, client classes, tests, and an example.
- Register and invoke a new
ClientSetGenerator
in the source generator pipeline - Define
ResourceClient
base andClientSet
partial classes and fix WebSocket parameter naming - Add an end-to-end
ClientSetTest
and a console example demonstrating CRUD viaClientSet
Reviewed Changes
Copilot reviewed 9 out of 20 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
tests/KubernetesClient.Tests/PodExecTests.cs | Fix typo in WebSocket method parameter name |
tests/E2E.Tests/MinikubeTests.cs | Add ClientSetTest covering create, list, patch, put, delete |
src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs | Register ClientSetGenerator for code generation |
src/LibKubernetesGenerator/ClientSetGenerator.cs | Implement logic to generate group clients and ClientSet |
src/LibKubernetesGenerator/GeneralNameHelper.cs | Import new naming helpers GetOperationId and GetActionName |
src/KubernetesClient/Kubernetes.WebSocket.cs | Correct webSocketSubProtocol parameter across overloads |
src/KubernetesClient/ClientSets/ResourceClient.cs | Add abstract ResourceClient base class |
src/KubernetesClient/ClientSets/ClientSet.cs | Add empty partial ClientSet class |
examples/clientset/Program.cs | Provide sample usage of generated ClientSet |
Files not reviewed (11)
- Directory.Packages.props: Language not supported
- examples/clientset/clientset.csproj: Language not supported
- src/KubernetesClient.Aot/KubernetesClient.Aot.csproj: Language not supported
- src/KubernetesClient.Classic/KubernetesClient.Classic.csproj: Language not supported
- src/LibKubernetesGenerator/LibKubernetesGenerator.target: Language not supported
- src/LibKubernetesGenerator/templates/Client.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/ClientSet.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/GroupClient.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/IOperations.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/Operations.cs.template: Language not supported
- src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template: Language not supported
Comments suppressed due to low confidence (1)
src/LibKubernetesGenerator/ClientSetGenerator.cs:31
- [nitpick] The variable name
i
is ambiguous. Consider renaming toduplicateSuffix
orsuffixCounter
for clarity.
var i = 1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a more modular ClientSet API by adding a generator for client sets, renaming generated methods to use operation IDs, and wiring up new ClientSet
and ResourceClient
base classes. It also adds an end-to-end test for ClientSet
operations and corrects a typo in WebSocket parameter naming.
- Add
ClientSetGenerator
and new Scriban templates for group clients, resource clients, and client sets - Rename generated extension and interface methods to use
OperationId
instead of original method names - Introduce base classes
ResourceClient
andClientSet
, register the generator, and add an E2E test forClientSet
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/KubernetesClient.Tests/PodExecTests.cs | Fix typo in WebSocket parameter name |
tests/E2E.Tests/MinikubeTests.cs | Add ClientSetTest E2E test and necessary usings |
src/LibKubernetesGenerator/templates/OperationsExtensions.cs.template | Rename extension methods to use GetOperationId |
src/LibKubernetesGenerator/templates/Operations.cs.template | Update generated implementations to use OperationId |
src/LibKubernetesGenerator/templates/IOperations.cs.template | Rename interface methods to use OperationId |
src/LibKubernetesGenerator/templates/GroupClient.cs.template | New template for API group clients |
src/LibKubernetesGenerator/templates/ClientSet.cs.template | New template for the aggregated ClientSet |
src/LibKubernetesGenerator/templates/Client.cs.template | New template for individual resource clients |
src/LibKubernetesGenerator/LibKubernetesGenerator.target | Add Scriban dependency |
src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs | Register ClientSetGenerator in source generator |
src/LibKubernetesGenerator/GeneralNameHelper.cs | Add GetOperationId and GetActionName helper imports |
src/LibKubernetesGenerator/ClientSetGenerator.cs | Implement ClientSetGenerator logic |
src/KubernetesClient/Kubernetes.WebSocket.cs | Correct WebSocket parameter name to webSocketSubProtocol |
src/KubernetesClient/ClientSets/ResourceClient.cs | Add ResourceClient base class |
src/KubernetesClient/ClientSets/ClientSet.cs | Add ClientSet base class |
src/KubernetesClient.Classic/KubernetesClient.Classic.csproj | Include new client-set source files |
src/KubernetesClient.Aot/KubernetesClient.Aot.csproj | Include new client-set source files |
examples/clientset/clientset.csproj | Example project file created (no references yet) |
examples/clientset/Program.cs | Example usage of the new ClientSet |
Comments suppressed due to low confidence (4)
examples/clientset/Program.cs:6
- [nitpick] Namespace names should use PascalCase by convention; consider renaming
clientset
toClientSet
or similar.
namespace clientset
tests/E2E.Tests/MinikubeTests.cs:19
- LINQ methods (
Any
,All
) andDictionary<,>
requireusing System.Linq;
andusing System.Collections.Generic;
imports at the top of this file.
using k8s.ClientSets;
examples/clientset/clientset.csproj:1
- The example project has no
ProjectReference
orPackageReference
for the KubernetesClient libraries, so it will not compile as-is. Add references to the generated client assemblies or NuGet packages.
<Project Sdk="Microsoft.NET.Sdk">
tests/E2E.Tests/MinikubeTests.cs:588
- [nitpick] The
ClientSetTest
method is quite long and covers multiple scenarios. Consider splitting it into smaller, focused test methods or extracting reusable helper methods to improve readability and maintainability.
[MinikubeFact]
/LGTM thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ayrloong, tg123 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f1125e9
into
kubernetes-client:master
Thank you very much for your help @tg123 |
This is the basic implementation based on this issue #1622
@tg123 Can you help me check if the overall structure is in compliance?