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

Move openapi proto parsing and indexing #10

Merged
merged 1 commit into from
Sep 1, 2017

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Aug 31, 2017

Move openapi proto parsing and indexing from main repo to this repo.
The code includes parsing and indexing logic.
They are NOT depend on any other k8s repo.

/assign @mbohlool @apelisse

@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 Aug 31, 2017
limitations under the License.
*/

// Package openapi is a collection of libraries for fetching the openapi spec
Copy link
Contributor

Choose a reason for hiding this comment

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

package proto. Also it does not fetch OpenAPI spec, right? only parsing and indexing.

return fmt.Errorf("SchemaError(%v): %v", path, err)
}

func VendorExtensionToMap(e []*openapi_v2.NamedAny) map[string]interface{} {
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc on all public methods please.

"k8s.io/kube-openapi/pkg/util/proto"
)

// groupVersionKindExtensionKey is the key used to lookup the
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not have groupVersionKindExtensionKey here. The extension is kubernetes specific. I suggest you make it configurable somehow and set it in the importer of this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind, This is in test code. It is fine. nit: I would name it something like testExtensionKey and add it to the comment that only for testing we use some kubernetes spec that has this key.

@mbohlool
Copy link
Contributor

Also please squash all commits into one.

@mengqiy
Copy link
Member Author

mengqiy commented Aug 31, 2017

Updated. Squashed. Cut the test swagger to 10% size.

kubectl OpenAPI bazel updates

Print a newline after ginkgo tests so the test infra doesn't think that they fail
Fixes #45279

Make OpenAPI GVK and Action extensions all lower-case

Get cmd uses print-column extn from Openapi schema

Get command now uses metadata x-kubernetes-print-columns, if present, in Openapi schema
to format output for a resource. This functionality is guarded by a boolean
flag 'use-openapi-print-columns'.

manually fix kubectl openapi unit test

openapi: Fetch protobuf rather than Json

This is much faster.

openapi: refactor into more generic structure

Refactor the openapi schema to be a more generic structure that can be
"visited" to get more specific types.

openapi: Remove cache mechanism

The cache will be removed and replaced with HTTP Etag caching instead.
This patch is simply removing the existing mechanism.

Revert "Merge pull request #47353 from apelisse/http-cache"

This reverts commit fc89743dca6b563063b74728c3b28100cf674d9d, reversing
changes made to 29ab38e898988c36e2de34f77fa33be556eb21bd.

Autogenerate BUILD files

Use buildozer to remove deprecated automanaged tags

Use buildozer to delete licenses() rules except under third_party/

openapi: Move Fakes to testing package

openapi: Add validation logic

This allows validation of a yaml/json object against an openapi schema.
A lot more testing would be needed to validate the logic, and also this
is not plumbed in, so it can't be used by kubectl yet.

Validate against OpenAPI schema (if available)

openapi: Use "group" to look for resources

openapi: Handle properly empty/null fileds

openapi-validation: Handle List special case

openapi validation: Ignore unknown types

This follows the exact same logic as swagger.

openapi: Change reference to be first-class

References in the openapi are currently completely hidden from the
model, and just passed through as we walk the tree. The problem is that
they can have a different description and more importantly, different
extensions.

Change them to be first-class citizen, and fully part of the model. It
means that visitors have to implement one more function and decide if
something specific should be done with references. Validation is updated
to just completely ignore them and passthrough (like it was done
before).

update pkg to not depend on other k8s repo
@apelisse
Copy link
Member

Ideally we would really like to test against the full swagger (k/k/api/openapi-spec/swagger.json) to make sure that it can be parsed entirely.

@mengqiy
Copy link
Member Author

mengqiy commented Aug 31, 2017

Ideally we would really like to test against the full swagger (k/k/api/openapi-spec/swagger.json) to make sure that it can be parsed entirely.

The openapi spec is not sync with main repo. We should not enforce it here.
We can add a simple test to make sure it can be parsed entirely in the main repo.

@apelisse
Copy link
Member

We can add a simple test to make sure it can be parsed entirely in the main repo.

sgtm

@mbohlool
Copy link
Contributor

mbohlool commented Sep 1, 2017

LGTM with assumption that this code is already code review-ed in the main repo. Thanks.

Copy link

@monopole monopole left a comment

Choose a reason for hiding this comment

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

/lgtm

k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Sep 5, 2017
Automatic merge from submit-queue (batch tested with PRs 51739, 51762)

Update vendor kube-openapi

Update vendor to pick up some change in kube-openapi. The goal is to move some generic openapi parsing and indexing code to kube-openapi repo.
Update the places that using it.

#51321 will depend on this.

fixes: #51822

kubernetes/kube-openapi#10 is the PR to move stuff to kube-openapi repo.

```release-note
NONE
```

/assign @apelisse
@mengqiy mengqiy deleted the move_parsing branch September 6, 2017 18:28
k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Sep 8, 2017
Automatic merge from submit-queue

Revert update vendor kube-openapi

Revert #51762 since #51321 are not going to get in this release.

Will revert kubernetes/kube-openapi#10 after this PR merged.

fixes: #52135

```release-note
NONE
```

/assign @apelisse @liggitt
sttts pushed a commit to sttts/kube-openapi that referenced this pull request Nov 5, 2020
sttts pushed a commit to sttts/kube-openapi that referenced this pull request Nov 5, 2020
sttts pushed a commit to sttts/kube-openapi that referenced this pull request Nov 5, 2020
* fix kubernetes#10 - add error factor must be positive

* fixed UT for new message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

6 participants