-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
apiextensions-apiserver: add columns to CRD spec #60991
Conversation
/cc @kubernetes/sig-api-machinery-api-reviews |
@@ -34,6 +34,16 @@ type CustomResourceDefinitionSpec struct { | |||
Validation *CustomResourceValidation | |||
// Subresources describes the subresources for CustomResources | |||
Subresources *CustomResourceSubresources | |||
|
|||
// Columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not even belong under validation.
@@ -425,7 +425,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensions.CustomResource | |||
} | |||
|
|||
// TODO: identify how to pass printer specification from the CRD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we delete this "TODO"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/cc @yliaog |
/assign @soltysh @juanvallejo can you comment on the API? |
// Header is the header to be printed on-top of the column. | ||
Header string | ||
// Path is a simple JSON path, i.e. with array notation. | ||
Path string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to support Type string
with OpenAPI types? Currently every cell is returned as string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd start with strings, for now. We can always improve if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't actually return new cells of different types in the future unless we define it now because that would not be backwards compatible for a client that assumes strings. We need to up front force people to acknowledge non-strings if we ever want to support them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That arguments sound more like for the client side: we have to make clients aware of non-strings from the beginning. Here, it's about CRDs, i.e. whether we want to allow to return non-strings for CRs.
One related question: if the user define a column as non-string, e.g. as integer, but the cell in the CR is not convertable to integer. What should we do with that CR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lgtm, but trying this out I can't get this to work, so probably there's some more wiring needed. I can look into it tomorrow.
// Header is the header to be printed on-top of the column. | ||
Header string | ||
// Path is a simple JSON path, i.e. with array notation. | ||
Path string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd start with strings, for now. We can always improve if needed.
42365ba
to
accbd80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall state of the PR lgtm, although I'd like to hear comments from @kubernetes/sig-api-machinery-api-reviews
if err := path.Parse(parts[1]); err != nil { | ||
return c, fmt.Errorf("unrecognized column definition in 'x-kubernetes-print-columns': %v", spec) | ||
|
||
for _, col := range crdColumns { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've played a bit with the PR and the only comment that I have is this. If a CRD author specifies columns we should overwrite the default ones. This will provide a better UX for CRD authors, otherwise they might end up with unwanted columns. If you look closely here how we specify the columns for the built-in types we always specify full set, there's no defaulting. I'd imagine this being the same for CRDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we default the field to the default columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should allow them to overwrite name. I'm ok with forcing them to specify createdAt, and that would actually be better because that's an example of a date field we should handle correctly.
Defaulting the field may make sense, not 100% sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we enforce name and createAt, I suggest to rename this field to AdditionalColumns
and don't default it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even AdditionalPrinterColumns
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's default and allow them to change it later on. I don't agree with @smarterclayton here about not having the ability to drop name
field. The author should have that option, and defaulting is exactly the right place for that.
Columns []Column | ||
} | ||
|
||
type Column struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomResourceColumnDefinition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match TableColumnDefinition
in meta/v1beta1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Header is the header to be printed on-top of the column. | ||
Header string | ||
// Path is a simple JSON path, i.e. with array notation. | ||
Path string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this JSONPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cells = append(cells, cell) | ||
continue | ||
} | ||
// TODO: types.go for Cells mentiones "simple maps", but resttest.go forbid them. Clarify! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple maps was intended for things like labels, but we haven't gotten there yet. I think the important outcome is that clients must hide/handle types they don't recognize, but we have to realize that not all clients will do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have restricted the types for CRDs via validation to the primitive types for now: string, bool, integer, number.
/retest Review the full test history for this PR. Silence the bot with an |
14 similar comments
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
/retest Review the full test history for this PR. Silence the bot with an |
New changes are detected. LGTM label has been removed. |
/retest Review the full test history for this PR. Silence the bot with an |
@sttts: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Follow-up of #60269.