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

Adds support for Symbol references in defaults #419

Merged
merged 4 commits into from
Sep 1, 2023

Conversation

alexzielenski
Copy link
Contributor

@alexzielenski alexzielenski commented Aug 18, 2023

gengo's Defaulter-gen has support for symbol references to be used as defaults in the form +default=ref(package/of/symbol.Name)

This PR exposes defaults declared as symbols into the OpenAPI

depends on kubernetes/gengo#247

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 18, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 18, 2023
@alexzielenski
Copy link
Contributor Author

/cc @apelisse

pkg/generators/openapi.go Outdated Show resolved Hide resolved
pkg/generators/openapi_test.go Outdated Show resolved Hide resolved
@alexzielenski alexzielenski force-pushed the symbol-references branch 4 times, most recently from 9d24c3a to 0db7937 Compare August 29, 2023 17:15
refactor openapi test to return import lines

add symbol reference test
Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'd feel a lot better if we had an integration test though.

pkg/generators/openapi.go Outdated Show resolved Hide resolved
@alexzielenski
Copy link
Contributor Author

added integration test, removed change to mustEnforceDefault we were unsure about

Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's totally awesome 🌈

Comment on lines +673 to +692
},
"defaultedAliasSymbolReference": {
"type": "string",
"default": "SymbolConstant"
},
"externalSymbolReference": {
"type": "string",
"default": "apple"
},
"fullyQualifiedSymbolReference": {
"type": "string",
"default": "SymbolConstant"
},
"localSymbolReference": {
"type": "string",
"default": "SymbolConstant"
},
"pointerConversionSymbolReference": {
"type": "string",
"default": "apple"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool to have the end-to-end test show that we end-up with the properly resolved values injected in the openapi! (big belated thanks to @seans3 for having written the test that makes the end-to-end possible).

test/integration/testdata/defaults/default.go Show resolved Hide resolved
@apelisse
Copy link
Member

apelisse commented Sep 1, 2023

/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 Sep 1, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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 Sep 1, 2023
@k8s-ci-robot k8s-ci-robot merged commit 6c774f4 into kubernetes:master Sep 1, 2023
4 checks passed
@apelisse
Copy link
Member

apelisse commented Sep 5, 2023

@thockin !!

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.

3 participants