kubernetes / apiserver

Library for writing a Kubernetes-style API server.
Apache License 2.0
647 stars 400 forks source link

Update gnostic to the latest version #65

Closed nicolehanjing closed 3 years ago

nicolehanjing commented 3 years ago

Context: google/gnostic#195 gnostic upgrade from yaml.v2 to yaml.v3 breaks some clients

Can we use apiserver with the latest github.com/googleapis/gnostic (0.5.0 or later)? There is an incompatibility between yaml v2 used by apiserver and yaml v3 used by gnostic since version 0.5.0

Without this fix, it is impossible to import this library and controller-runtime v0.8.3 error log:

# k8s.io/apiserver/pkg/util/openapi
../../../pkg/mod/k8s.io/apiserver@v0.20.2/pkg/util/openapi/proto.go:43:36: cannot use info (type "gopkg.in/yaml.v2".MapSlice) as type *"gopkg.in/yaml.v3".Node in argument to openapi_v2.NewDocument

To fix this, as suggested in google/gnostic#195, we could replace this line with the ParseDocument functions defined in openapiv2/document.go and openapiv3/document.go. That would make the calling code look like this:

document, err := openapi_v2.ParseDocument(b)

where b is a []byte of the JSON or YAML file to be parsed.

Samze commented 3 years ago

I also ran into this trying to use this library with controller runtime v0.8.x

mcbenjemaa commented 3 years ago

/assign