community icon indicating copy to clipboard operation
community copied to clipboard

Ability to specify additional printer columns in `ack-generate` config file

Open a-hilaly opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Currently, ack-generate can produce go code with kubebuilder markers allowing CRDs to have additional print columns. However, CRDs can only have one print column per field. Ideally, we would like to have an option to specify extra print columns with something similar to:

    additionalPrinterColumns:
    - name: SYNCED
      jsonPath: .status.conditions[?(@.type=="ACK.ResourceSynced")].status

Describe the solution you'd like Ability to have multiple print columns per field.

a-hilaly avatar Apr 26 '22 16:04 a-hilaly

This feature will unblock https://github.com/aws-controllers-k8s/community/issues/1271

a-hilaly avatar Apr 26 '22 16:04 a-hilaly

I'd propose we can go ahead with adding the SYNCED column to every CRD, anyway. Let's not even make it an option for resources, just do it for everything.

RedbackThomson avatar Apr 26 '22 21:04 RedbackThomson

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

eks-bot avatar Jul 25 '22 22:07 eks-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle rotten

eks-bot avatar Aug 24 '22 22:08 eks-bot

/lifecycle frozen

a-hilaly avatar Aug 24 '22 22:08 a-hilaly

+1 on this (though SYNCED is already there with print.add_synced_column: true now. Would love to see this feature so I can reference "arbitrary" fields of the resource (from spec and status), e.g. ARN or state from an EventBridge rule and project it into a printer column.

I raised this with @A-Hilaly again, and he's definitely aware and supportive.

embano1 avatar Oct 28 '22 06:10 embano1

/assign

jljaco avatar Nov 08 '22 22:11 jljaco

Giving more context on this issue: PrinterColumns is a CRD attribute that allows extending kubectl get table result. In ACK land our CRD yaml files are generated using controller-gen which behinds the scenes relies on kubebuilder markers (Golang comments) to know how a field should be printed and injected in the kubectl get result.

For example in prometheusservice-controller, we inject this kubebuilder marker (Go comment) to instruct controller-gen to inject additionalPrinterColumns in the CRD yaml file which contains information on how to print the .spec.Alias

The feature described in this Issue, will allow ACK code-generator users to inject special kubebuilder markers to support printing nested fields, specific elements in an array/maps and doing some complex json queries in order to provide the best kubectl get experience. A good example is .status.conditions[?(@.type=="ACK.ResourceSynced")].status that will allow users to see the value of the synced condition.

There a PR that shows how we added the ability to append the AGE columns: https://github.com/aws-controllers-k8s/code-generator/pull/84/files

a-hilaly avatar Nov 30 '22 14:11 a-hilaly

This functionality is now available in the main branch of code-generator, and will be in the next release.

jljaco avatar Dec 07 '22 22:12 jljaco