Skip to content
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

JSONPath selection in PrinterColumn #3069

Closed
lburgazzoli opened this issue Apr 30, 2021 · 9 comments · Fixed by #6390
Closed

JSONPath selection in PrinterColumn #3069

lburgazzoli opened this issue Apr 30, 2021 · 9 comments · Fixed by #6390
Labels
component/crd-generator Related to the CRD generator enhancement status/never-stale Waiting on feedback Issues that require feedback from User/Other community members
Milestone

Comments

@lburgazzoli
Copy link
Contributor

As today the @PrinterColumn annotation can only be set on a field, but in some case it would be nice to have the option to set in on a type, i.e. on a CustomResource

with the go sdk, one can do something like:

kubebuilder:printcolumn:name="provider",type=string,JSONPath=`.spec.runtime.provider`,description="provider"

but I don't a similar option with the java operator sdk

My use case is that I have a Java class used in both the spec and the status and I want to print the same field from spec and status but with a different name.

public class ConnectorSpec {    
    private DeploymentRef deployment;
}
public class ConnectorStatus {    
    private DeploymentRef deployment;
}

with the go sdk, I could write something like

kubebuilder:printcolumn:name=name="foo",type=string,JSONPath=`.spec.deployment.field`"
kubebuilder:printcolumn:name=name="bar",type=string,JSONPath=`.status.deployment.field`

I can workaround this by in-lining classes in the spec/status or having two distinct classes but since the information are exactly the same, it would put more maintenance

@metacosm
Copy link
Collaborator

I can think of two options at the moment: either a class level annotation allowing you to specify which path you want to add as a printer column, similarly to what the go sdk does, or make the @PrinterColumn annotation multiple so that a given field could be annotated with different values, adding a predicate field to determine how to activate a given version.

The first option is most likely simpler to implement but that decouples the annotation from the field it's targeting making it more difficult to maintain. The second option doesn't have that disadvantage but it is probably more complex to implement and possibly to understand depending on how complex the activation predicate could be.

What do you think, @iocanel @manusa?

@stale
Copy link

stale bot commented Jul 29, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale
Copy link

stale bot commented Nov 14, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Nov 14, 2021
@lburgazzoli
Copy link
Contributor Author

still relevant

@stale stale bot removed the status/stale label Nov 15, 2021
@stoetti
Copy link

stoetti commented Jan 28, 2022

Are there any plans on implementing this enhancement in the near future?

In order to build CRDs in respect common api conventions (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties) it would be really necessary to provide printer columns that are defined using a JsonPath like this .status.conditions[?(@.type=="Ready")].status

@stale
Copy link

stale bot commented Apr 28, 2022

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Apr 28, 2022
@stale stale bot closed this as completed May 5, 2022
@metacosm metacosm reopened this Oct 21, 2022
@stale stale bot removed the status/stale label Oct 21, 2022
@manusa
Copy link
Member

manusa commented Mar 5, 2024

Hi @metacosm,
What's the status of this issue? I'm planning the features to be completed in scope of v7.0.

@manusa manusa added the Waiting on feedback Issues that require feedback from User/Other community members label Mar 5, 2024
@metacosm metacosm removed their assignment Mar 6, 2024
@metacosm
Copy link
Collaborator

metacosm commented Mar 6, 2024

I haven't looked at this in a long time and probably don't have time to take it on anymore. Feel free to re-assign it to someone else.

shawkins added a commit to shawkins/kubernetes-client that referenced this issue Sep 30, 2024
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Sep 30, 2024
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Sep 30, 2024
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Oct 16, 2024
@manusa manusa added this to the 7.0.0 milestone Oct 18, 2024 — with automated-tasks
manusa pushed a commit that referenced this issue Oct 18, 2024
fix: adds an additional printer column annotation

closes: #3069

Signed-off-by: Steve Hawkins <[email protected]>
---
switching to enums for format and type

based upon Bernhard Strähle's review

Signed-off-by: Steve Hawkins <[email protected]>
---
updating to jsonPath

Signed-off-by: Steve Hawkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/crd-generator Related to the CRD generator enhancement status/never-stale Waiting on feedback Issues that require feedback from User/Other community members
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants