kubernetes / kube-openapi

Kubernetes OpenAPI spec generation & serving
Apache License 2.0
319 stars 208 forks source link

Adds support for CEL marker comments #445

Closed alexzielenski closed 10 months ago

alexzielenski commented 10 months ago

Adds CEL marker comments support to kube-openapi. Previous extension support only allowed strings. This PR makes use of new marker comment system introduced in #435 to emit CEL vendor extensions.

Multiline syntax is not yet supported. Proposed syntax is 1:1 with CEL CRD fields:

    // +k8s:validation:cel[0]:rule="self.length() > 0"
    // +k8s:validation:cel[0]:message="string message"
    // +k8s:validation:cel[1]:rule="self.length() % 2 == 0"
    // +k8s:validation:cel[1]:messageExpression="self + ' hello'"
    // +optional
    CELField string `json:"celField"`

There are linter errors to help keep the indexing straight

/assign @jefftree /cc @Schnides123

k8s-ci-robot commented 10 months ago

@alexzielenski: GitHub didn't allow me to request PR reviews from the following users: Schnides123.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to [this](https://github.com/kubernetes/kube-openapi/pull/445): >Adds CEL marker comments support to kube-openapi. Previous extension support only allowed strings. This PR makes use of new marker comment system introduced in #435 to emit CEL vendor extensions. > >Multiline syntax is not yet supported. Proposed syntax is 1:1 with CEL CRD fields: > >```go > // +k8s:validation:cel[0]:rule="self.length() > 0" > // +k8s:validation:cel[0]:message="string message" > // +k8s:validation:cel[1]:rule="self.length() % 2 == 0" > // +k8s:validation:cel[1]:messageExpression="self + ' hello'" > // +optional > CELField string `json:"celField"` >``` > > >/assign @jefftree >/cc @Schnides123 Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
alexzielenski commented 10 months ago

/hold

Jefftree commented 10 months ago

/lgtm /approve

k8s-ci-robot commented 10 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexzielenski, Jefftree

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: - ~~[OWNERS](https://github.com/kubernetes/kube-openapi/blob/master/OWNERS)~~ [Jefftree,alexzielenski] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
alexzielenski commented 10 months ago

squashed, @Jefftree can you re-lgtm?

alexzielenski commented 10 months ago

/hold cancel

Jefftree commented 10 months ago

/lgtm