Skip to content

🐛 Fix flattening chains of references to references#428

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:masterfrom
skaslev:ref-chain
Jun 1, 2020
Merged

🐛 Fix flattening chains of references to references#428
k8s-ci-robot merged 1 commit intokubernetes-sigs:masterfrom
skaslev:ref-chain

Conversation

@skaslev
Copy link
Copy Markdown

@skaslev skaslev commented Apr 1, 2020

Without this change running controller-gen on Knative's APIs
results in unexpanded reference for the Conditions[1] type in
the generated OpenAPI schema:

conditions:
  $ref: '#/definitions/knative.dev~1pkg~1apis~0Conditions'

After this change Conditions gets properly flattened and no references
are present in the resulting schema.

Fixes #324

[1] https://github.com/knative/pkg/blob/ce05a3de31ed80e98862a0ea024977097fd0e4a5/apis/duck/v1/status_types.go#L34

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 1, 2020
@skaslev
Copy link
Copy Markdown
Author

skaslev commented Apr 1, 2020

/assign @DirectXMan12

Comment thread pkg/crd/schema_visitor.go
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 5, 2020
@skaslev
Copy link
Copy Markdown
Author

skaslev commented May 5, 2020

@DirectXMan12 Thank you for the review.

Can you take another look?

@skaslev skaslev requested a review from DirectXMan12 May 5, 2020 15:43
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2020
@DirectXMan12
Copy link
Copy Markdown
Contributor

pushed an extra test, plus a test for circular references

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 27, 2020
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, skaslev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 27, 2020
@skaslev
Copy link
Copy Markdown
Author

skaslev commented May 28, 2020

Thanks for doing this. Seems that it didn't land because of a misspelling in the test:

pkg/crd/flatten_type_test.go:112:35: `ciruclar` is a misspelling of `circular` (misspell)
		It("should not infinite-loop on ciruclar references", func() {

Without this change running controller-gen on Knative's APIs
results in unexpanded reference for the Conditions[1] type in
the generated OpenAPI schema:

    conditions:
      $ref: '#/definitions/knative.dev~1pkg~1apis~0Conditions'

After this change Conditions gets properly flattened and no references
are present in the resulting schema.

[1] https://github.com/knative/pkg/blob/ce05a3de31ed80e98862a0ea024977097fd0e4a5/apis/duck/v1/status_types.go#L34

EDIT(directxman12): added test for circular references.
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2020
@DirectXMan12
Copy link
Copy Markdown
Contributor

gah, thanks for fixing the typo

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 1, 2020
@k8s-ci-robot k8s-ci-robot merged commit 288676b into kubernetes-sigs:master Jun 1, 2020
@skaslev skaslev deleted the ref-chain branch June 3, 2020 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

controller-tools creates schema with '$ref' which is not supported in k8s

3 participants