-
Notifications
You must be signed in to change notification settings - Fork 305
Implement Kubectl Get using generic client for any Kubernetes resource #1685
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
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot 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 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Copilot 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 |
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
|
@copilot can you refactor this to use the generic client csharp/examples/generic/Generic.cs Line 7 in 9566a3f
|
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Refactored to use GenericClient with a single generic Usage: var pod = kubectl.Get<V1Pod>("my-pod", "default");
var namespace = kubectl.Get<V1Namespace>("kube-system");
var deployment = kubectl.Get<V1Deployment>("my-deploy", "prod");Commit: 2147fb4 |
Adds
kubectl getfunctionality to retrieve any Kubernetes resource by name, similar to the kubectl CLI tool. Uses a single generic method withGenericClientinstead of separate methods for each resource type.Implementation
GetAsync<T>()method using GenericClientGet<T>()wrapper following existing patterns (Version, Cordon)The implementation extracts resource metadata (group, version, plural name) from the type's
KubernetesEntityAttributeand automatically handles both namespaced and cluster-scoped resources.Usage
The generic method works with any Kubernetes resource type that has a
KubernetesEntityAttribute, making it extensible to all supported resources without requiring additional code.Original prompt
<issue_description>Similar to the
kubectlexecutable we need to implement KubectlGet functionality which will get any known resource.This should be located in the src/KubernetesClient.Kubectl package.</issue_description>
Comments on the Issue (you are @copilot in this section)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.