-
Notifications
You must be signed in to change notification settings - Fork 303
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ayrloong The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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?
examples/clientset/Program.cs
Outdated
IKubernetes client = new Kubernetes(config); | ||
|
||
ClientSet clientSet = new ClientSet(client); | ||
var list = await clientSet.CoreV1.Pod.ListNamespacedPodAsync("default").ConfigureAwait(false); |
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.
ListAsync?
i prefer the style in your proposal, it is simpler
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.
I used x-kuberneter-action to define the method name. Can you help me see if there is any problem with this?https://github.com/kubernetes-client/csharp/pull/1627/files#diff-9501625d7da40bd1b40cb3b43406f26d00f5aa65c65f4877b1eaec2d40f792a0R169
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 |
|
||
public ResourceClient(IKubernetes kubernetes) | ||
{ | ||
Client = (Kubernetes)kubernetes; |
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.
did not quite get here,
anyway to avoid cast, why not force input Kubernetes
?
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.
Given that IKubernetes
is typically registered in the DI container, I relied on dependency injection instead of manually providing Kubernetes
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! |
This is the basic implementation based on this issue #1622
@tg123 Can you help me check if the overall structure is in compliance?