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

Serve OpenAPI spec by default #110

Merged
merged 2 commits into from
Nov 23, 2022

Conversation

olivierlemasle
Copy link
Member

@olivierlemasle olivierlemasle commented Nov 17, 2022

Resolves #109


This PR adds default OpenAPI definitions and settings, while keeping it customizable.

If the project using custom-metrics-apiserver continues to use

cmd.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(apiserver.Scheme))
cmd.OpenAPIConfig.Info.Title = "name"
cmd.OpenAPIConfig.Info.Version = "1.0.0"

then nothing changes.

However, if an OpenAPIConfig is not provided, custom-metrics-apiserver will provide a default value, with its own generated definitions, which means that the OpenAPI spec will be served.

Note 1: I have split the definitions between custom_metrics, external_metrics and "core", but it is possible to use a single generated file.

Note 2: I could have let test-adapter use its custom OpenAPI settings to show how to use it. But I don't think it's really necessary (documentation could be added, though).

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 17, 2022
Makefile Outdated Show resolved Hide resolved
pkg/cmd/builder_test.go Show resolved Hide resolved
@dgrisonnet
Copy link
Member

I very like this approach, it is a great improvement that will remove a lot of tedious work for maintainers as I don't expect many projects to have a custom OpenAPI

@dgrisonnet
Copy link
Member

/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 Nov 23, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgrisonnet, olivierlemasle

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 Nov 23, 2022
@k8s-ci-robot k8s-ci-robot merged commit d5eaee4 into kubernetes-sigs:master Nov 23, 2022
@olivierlemasle olivierlemasle deleted the openapi branch November 23, 2022 19:16
@dgrisonnet dgrisonnet mentioned this pull request Nov 28, 2022
olivierlemasle added a commit to olivierlemasle/keda that referenced this pull request Nov 29, 2022
custom-metrics-apiserver serves OpenAPI spec by default since
version [v1.25.0] (cf [PR 110]).

[v1.25.0]: https://github.com/kubernetes-sigs/custom-metrics-apiserver/releases/tag/v1.25.0
[PR 110]: kubernetes-sigs/custom-metrics-apiserver#110

In Keda Metrics Server, remove generation of
`adapter/generated/openapi/zz_generated.openapi.go` and use
OpenAPI definitions from custom-metrics-apiserver instead.

Signed-off-by: Olivier Lemasle <[email protected]>
olivierlemasle added a commit to olivierlemasle/keda that referenced this pull request Nov 29, 2022
custom-metrics-apiserver serves OpenAPI spec by default since
version [v1.25.0] (cf [PR 110]).

[v1.25.0]: https://github.com/kubernetes-sigs/custom-metrics-apiserver/releases/tag/v1.25.0
[PR 110]: kubernetes-sigs/custom-metrics-apiserver#110

In Keda Metrics Server, remove generation of
`adapter/generated/openapi/zz_generated.openapi.go` and use
OpenAPI definitions from custom-metrics-apiserver instead.

Signed-off-by: Olivier Lemasle <[email protected]>
zroubalik added a commit to kedacore/keda that referenced this pull request Nov 29, 2022
* Metrics Server: use vendored OpenAPI definitions

custom-metrics-apiserver serves OpenAPI spec by default since
version [v1.25.0] (cf [PR 110]).

[v1.25.0]: https://github.com/kubernetes-sigs/custom-metrics-apiserver/releases/tag/v1.25.0
[PR 110]: kubernetes-sigs/custom-metrics-apiserver#110

In Keda Metrics Server, remove generation of
`adapter/generated/openapi/zz_generated.openapi.go` and use
OpenAPI definitions from custom-metrics-apiserver instead.

Signed-off-by: Olivier Lemasle <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Zbynek Roubalik <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>

Signed-off-by: Olivier Lemasle <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>
Co-authored-by: Zbynek Roubalik <[email protected]>
josephangbc pushed a commit to josephangbc/keda that referenced this pull request Dec 6, 2022
* Metrics Server: use vendored OpenAPI definitions

custom-metrics-apiserver serves OpenAPI spec by default since
version [v1.25.0] (cf [PR 110]).

[v1.25.0]: https://github.com/kubernetes-sigs/custom-metrics-apiserver/releases/tag/v1.25.0
[PR 110]: kubernetes-sigs/custom-metrics-apiserver#110

In Keda Metrics Server, remove generation of
`adapter/generated/openapi/zz_generated.openapi.go` and use
OpenAPI definitions from custom-metrics-apiserver instead.

Signed-off-by: Olivier Lemasle <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Zbynek Roubalik <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>

Signed-off-by: Olivier Lemasle <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>
Co-authored-by: Zbynek Roubalik <[email protected]>
josephangbc pushed a commit to josephangbc/keda that referenced this pull request Dec 6, 2022
* Metrics Server: use vendored OpenAPI definitions

custom-metrics-apiserver serves OpenAPI spec by default since
version [v1.25.0] (cf [PR 110]).

[v1.25.0]: https://github.com/kubernetes-sigs/custom-metrics-apiserver/releases/tag/v1.25.0
[PR 110]: kubernetes-sigs/custom-metrics-apiserver#110

In Keda Metrics Server, remove generation of
`adapter/generated/openapi/zz_generated.openapi.go` and use
OpenAPI definitions from custom-metrics-apiserver instead.

Signed-off-by: Olivier Lemasle <[email protected]>

* Update CHANGELOG.md

Co-authored-by: Zbynek Roubalik <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>

Signed-off-by: Olivier Lemasle <[email protected]>
Signed-off-by: Olivier Lemasle <[email protected]>
Co-authored-by: Zbynek Roubalik <[email protected]>
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide default OpenAPI settings & definitions
3 participants