bump(k8s.io/kube-openapi): b3a7cee44a305be0a69e1b9ac03018307287e1b0

To get https://github.com/kubernetes/kube-openapi/pull/149.
pull/564/head
Dr. Stefan Schimanski 2019-02-28 18:50:53 +01:00
parent 7514c49ec1
commit af2cedde4e
3 changed files with 34 additions and 97 deletions

28
Godeps/Godeps.json generated
View File

@ -4231,59 +4231,59 @@
},
{
"ImportPath": "k8s.io/kube-openapi/cmd/openapi-gen",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/cmd/openapi-gen/args",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/aggregator",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/builder",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/common",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/generators",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/generators/rules",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/handler",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/schemaconv",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto/testing",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto/validation",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/sets",
"Rev": "d7c86cdc46e3a4fcf892b32dd7bc3aa775e0870e"
"Rev": "b3a7cee44a305be0a69e1b9ac03018307287e1b0"
},
{
"ImportPath": "k8s.io/repo-infra/kazel",

View File

@ -54,5 +54,4 @@ func main() {
); err != nil {
log.Fatalf("OpenAPI code generation error: %v", err)
}
log.Println("Code for OpenAPI definitions generated")
}

View File

@ -23,19 +23,18 @@ import (
"fmt"
"mime"
"net/http"
"strings"
"sync"
"time"
"github.com/NYTimes/gziphandler"
restful "github.com/emicklei/go-restful"
"github.com/emicklei/go-restful"
"github.com/go-openapi/spec"
"github.com/golang/protobuf/proto"
openapi_v2 "github.com/googleapis/gnostic/OpenAPIv2"
"github.com/googleapis/gnostic/OpenAPIv2"
"github.com/googleapis/gnostic/compiler"
"github.com/json-iterator/go"
"github.com/munnerz/goautoneg"
yaml "gopkg.in/yaml.v2"
"gopkg.in/yaml.v2"
"k8s.io/kube-openapi/pkg/builder"
"k8s.io/kube-openapi/pkg/common"
@ -86,84 +85,6 @@ func NewOpenAPIService(spec *spec.Swagger) (*OpenAPIService, error) {
return o, nil
}
// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec,
// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process
// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU.
//
// BuildAndRegisterOpenAPIService builds the spec and registers a handler to provide access to it.
// Use this method if your OpenAPI spec is static. If you want to update the spec, use BuildOpenAPISpec then RegisterOpenAPIService.
func BuildAndRegisterOpenAPIService(servePath string, webServices []*restful.WebService, config *common.Config, handler common.PathHandler) (*OpenAPIService, error) {
spec, err := builder.BuildOpenAPISpec(webServices, config)
if err != nil {
return nil, err
}
o, err := NewOpenAPIService(spec)
if err != nil {
return nil, err
}
return o, o.RegisterOpenAPIService(servePath, handler)
}
// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec,
// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process
// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU.
//
// RegisterOpenAPIService registers a handler to provide access to provided swagger spec.
// Note: servePath should end with ".json" as the RegisterOpenAPIService assume it is serving a
// json file and will also serve .pb and .gz files.
//
// Deprecated: use OpenAPIService.RegisterOpenAPIService instead.
func RegisterOpenAPIService(spec *spec.Swagger, servePath string, handler common.PathHandler) (*OpenAPIService, error) {
o, err := NewOpenAPIService(spec)
if err != nil {
return nil, err
}
return o, o.RegisterOpenAPIService(servePath, handler)
}
// NOTE: [DEPRECATION] We will announce deprecation for format-separated endpoints for OpenAPI spec,
// and switch to a single /openapi/v2 endpoint in Kubernetes 1.10. The design doc and deprecation process
// are tracked at: https://docs.google.com/document/d/19lEqE9lc4yHJ3WJAJxS_G7TcORIJXGHyq3wpwcH28nU.
//
// RegisterOpenAPIService registers a handler to provide access to provided swagger spec.
// Note: servePath should end with ".json" as the RegisterOpenAPIService assume it is serving a
// json file and will also serve .pb and .gz files.
func (o *OpenAPIService) RegisterOpenAPIService(servePath string, handler common.PathHandler) error {
if !strings.HasSuffix(servePath, jsonExt) {
return fmt.Errorf("serving path must end with \"%s\"", jsonExt)
}
servePathBase := strings.TrimSuffix(servePath, jsonExt)
type fileInfo struct {
ext string
getDataAndETag func() ([]byte, string, time.Time)
}
files := []fileInfo{
{".json", o.getSwaggerBytes},
{"-2.0.0.json", o.getSwaggerBytes},
{"-2.0.0.pb-v1", o.getSwaggerPbBytes},
{"-2.0.0.pb-v1.gz", o.getSwaggerPbGzBytes},
}
for _, file := range files {
path := servePathBase + file.ext
getDataAndETag := file.getDataAndETag
handler.Handle(path, gziphandler.GzipHandler(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
data, etag, lastModified := getDataAndETag()
w.Header().Set("Etag", etag)
// ServeContent will take care of caching using eTag.
http.ServeContent(w, r, path, lastModified, bytes.NewReader(data))
}),
))
}
return nil
}
func (o *OpenAPIService) getSwaggerBytes() ([]byte, string, time.Time) {
o.rwMutex.RLock()
defer o.rwMutex.RUnlock()
@ -238,6 +159,23 @@ func jsonToYAMLValue(j interface{}) interface{} {
ret[i] = jsonToYAMLValue(j[i])
}
return ret
case float64:
// replicate the logic in https://github.com/go-yaml/yaml/blob/51d6538a90f86fe93ac480b35f37b2be17fef232/resolve.go#L151
if i64 := int64(j); j == float64(i64) {
if i := int(i64); i64 == int64(i) {
return i
}
return i64
}
if ui64 := uint64(j); j == float64(ui64) {
return ui64
}
return j
case int64:
if i := int(j); j == int64(i) {
return i
}
return j
}
return j
}