gateway-api
gateway-api copied to clipboard
Implemented `gwctl describe policycrds`
What type of PR is this? Add one of the following kinds: /area gwctl /kind feature /cc @gauravkghildiyal
What this PR does / why we need it:
Implement gwctl describe policycrds
command
Which issue(s) this PR fixes: Fixes https://github.com/kubernetes-sigs/gateway-api/issues/2870
Does this PR introduce a user-facing change?:
Implemented command `gwctl describe policycrds`
Hi @Devaansh-Kumar. Thanks for your PR.
I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test
on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test
label.
I understand the commands that are listed here.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
/assign
@gauravkghildiyal I have resolved the above issues, just reconfirm this comment once: https://github.com/kubernetes-sigs/gateway-api/pull/2872#discussion_r1535330070
@gauravkghildiyal I have resolved the above issues, please review
@Devaansh-Kumar I see you pushed some new changes...is https://github.com/kubernetes-sigs/gateway-api/pull/2872/files#r1534775341 still a work in progress?
/ok-to-test
@Devaansh-Kumar I see you pushed some new changes...is https://github.com/kubernetes-sigs/gateway-api/pull/2872/files#r1534775341 still a work in progress?
/ok-to-test
@gauravkghildiyal I have already left a comment on that thread before, I think I have already solved it but maybe you are asking for something else that I dont understand.
You had told to not print out Labels
and Annotations
twice as they appear in Metadata
as well. So I changed the code to only print Metadata
. Am I missing something?
Am I missing something?
Can we try to get those outside Metadata please, as per the original plan. I'm hoping it won't be too challenging now (correct me if I'm wrong)
Am I missing something?
Can we try to get those outside Metadata please, as per the original plan. I'm hoping it won't be too challenging now (correct me if I'm wrong)
Ok, now I understood what you wanted. You want me to parse the entire *metav1.ObjectMeta
struct and not include label
and annotations
, right?
@gauravkghildiyal I have tried out your suggested change here by creating a new function ExcludeFieldsFromStruct
to remove fields from a struct. I put this in a seperate file so that we can use this in the future as well.
@Devaansh-Kumar
How about something like this:
type policyCrdDescribeView struct {
Name string `json:",omitempty"`
Namespace string `json:",omitempty"`
APIVersion string `json:",omitempty"`
Kind string `json:",omitempty"`
Labels map[string]string `json:",omitempty"`
Annotations map[string]string `json:",omitempty"`
Metadata *metav1.ObjectMeta `json:",omitempty"`
Spec *apiextensionsv1.CustomResourceDefinitionSpec `json:",omitempty"`
Status *apiextensionsv1.CustomResourceDefinitionStatus `json:",omitempty"`
}
.
.
.
metadata := crd.ObjectMeta.DeepCopy()
// Remove fields which are printed independently from the metadata.
metadata.Name = ""
metadata.Namespace = ""
metadata.Labels = nil
metadata.Annotations = nil
views := []policyCrdDescribeView{
{
Name: crd.Name,
Namespace: crd.Namespace,
},
{
APIVersion: crd.APIVersion,
Kind: crd.Kind,
},
{
Labels: crd.Labels,
Annotations: crd.Annotations,
},
{
Metadata: metadata,
},
{
Spec: &crd.Spec,
},
{
Status: &crd.Status,
},
}
I guess you won't need the ExcludeFieldsFromStruct
then? The intent was/is:
- To avoid duplication
- And show important fields at the top level (like kubectl), instead of within metadata.
/label tide/merge-method-squash
@gauravkghildiyal I have made the necessary changes, please review
Thanks for getting this through @Devaansh-Kumar
/lgtm /approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: Devaansh-Kumar, gauravkghildiyal
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~gwctl/OWNERS~~ [gauravkghildiyal]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment