gateway-api icon indicating copy to clipboard operation
gateway-api copied to clipboard

Implemented `gwctl describe policycrds`

Open Devaansh-Kumar opened this issue 11 months ago • 4 comments

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`

Devaansh-Kumar avatar Mar 14 '24 12:03 Devaansh-Kumar

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.

k8s-ci-robot avatar Mar 14 '24 12:03 k8s-ci-robot

/assign

gauravkghildiyal avatar Mar 21 '24 21:03 gauravkghildiyal

@gauravkghildiyal I have resolved the above issues, just reconfirm this comment once: https://github.com/kubernetes-sigs/gateway-api/pull/2872#discussion_r1535330070

Devaansh-Kumar avatar Mar 22 '24 10:03 Devaansh-Kumar

@gauravkghildiyal I have resolved the above issues, please review

Devaansh-Kumar avatar Mar 28 '24 07:03 Devaansh-Kumar

@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 avatar Apr 02 '24 04:04 gauravkghildiyal

@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?

Devaansh-Kumar avatar Apr 02 '24 05:04 Devaansh-Kumar

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)

gauravkghildiyal avatar Apr 02 '24 05:04 gauravkghildiyal

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?

Devaansh-Kumar avatar Apr 02 '24 06:04 Devaansh-Kumar

@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 avatar Apr 02 '24 07:04 Devaansh-Kumar

@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.

gauravkghildiyal avatar Apr 03 '24 04:04 gauravkghildiyal

/label tide/merge-method-squash

gauravkghildiyal avatar Apr 03 '24 04:04 gauravkghildiyal

@gauravkghildiyal I have made the necessary changes, please review

Devaansh-Kumar avatar Apr 03 '24 06:04 Devaansh-Kumar

Thanks for getting this through @Devaansh-Kumar

/lgtm /approve

gauravkghildiyal avatar Apr 04 '24 02:04 gauravkghildiyal

[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

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Apr 04 '24 02:04 k8s-ci-robot