From 102bc901202a0533c7bded8ad55841677ff92835 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Tue, 19 Jun 2018 23:23:00 -0400 Subject: [PATCH] bump(k8s.io/kube-openapi): 91cfa479c814065e420cee7ed227db0f63a5854e --- Godeps/Godeps.json | 18 ++++----- .../Godeps/Godeps.json | 10 ++--- .../k8s.io/apimachinery/Godeps/Godeps.json | 2 +- .../src/k8s.io/apiserver/Godeps/Godeps.json | 10 ++--- .../src/k8s.io/client-go/Godeps/Godeps.json | 2 +- .../k8s.io/code-generator/Godeps/Godeps.json | 4 +- .../k8s.io/kube-aggregator/Godeps/Godeps.json | 12 +++--- staging/src/k8s.io/metrics/Godeps/Godeps.json | 2 +- .../sample-apiserver/Godeps/Godeps.json | 10 ++--- .../sample-controller/Godeps/Godeps.json | 2 +- .../kube-openapi/pkg/builder/openapi.go | 40 +++++++++++++------ .../kube-openapi/pkg/generators/openapi.go | 5 ++- 12 files changed, 66 insertions(+), 51 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 693bb939a1a..e84f40840c1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -3357,39 +3357,39 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/aggregator", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/generators", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto/testing", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto/validation", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/utils/clock", diff --git a/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json b/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json index a3ac798fa6b..0dc76fa09a2 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json @@ -2036,23 +2036,23 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/apimachinery/pkg/api/equality", diff --git a/staging/src/k8s.io/apimachinery/Godeps/Godeps.json b/staging/src/k8s.io/apimachinery/Godeps/Godeps.json index 3d8943ae9ee..b580e4b3175 100644 --- a/staging/src/k8s.io/apimachinery/Godeps/Godeps.json +++ b/staging/src/k8s.io/apimachinery/Godeps/Godeps.json @@ -180,7 +180,7 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/apiserver/Godeps/Godeps.json b/staging/src/k8s.io/apiserver/Godeps/Godeps.json index 1746ca31ad7..8a777ef756c 100644 --- a/staging/src/k8s.io/apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/apiserver/Godeps/Godeps.json @@ -1764,23 +1764,23 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/client-go/discovery", diff --git a/staging/src/k8s.io/client-go/Godeps/Godeps.json b/staging/src/k8s.io/client-go/Godeps/Godeps.json index d076c5c0112..edd6f72961a 100644 --- a/staging/src/k8s.io/client-go/Godeps/Godeps.json +++ b/staging/src/k8s.io/client-go/Godeps/Godeps.json @@ -588,7 +588,7 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/code-generator/Godeps/Godeps.json b/staging/src/k8s.io/code-generator/Godeps/Godeps.json index a4aca68986b..021cf145862 100644 --- a/staging/src/k8s.io/code-generator/Godeps/Godeps.json +++ b/staging/src/k8s.io/code-generator/Godeps/Godeps.json @@ -260,11 +260,11 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/generators", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json b/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json index 6dfae40f1dc..da5877e7a8a 100644 --- a/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json +++ b/staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json @@ -1684,27 +1684,27 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/aggregator", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/metrics/Godeps/Godeps.json b/staging/src/k8s.io/metrics/Godeps/Godeps.json index ddc8bd40d68..02d78f0f3bc 100644 --- a/staging/src/k8s.io/metrics/Godeps/Godeps.json +++ b/staging/src/k8s.io/metrics/Godeps/Godeps.json @@ -492,7 +492,7 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json b/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json index 1a7e9da2d73..4fc028225c6 100644 --- a/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json +++ b/staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json @@ -1648,23 +1648,23 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/builder", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/common", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/handler", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/staging/src/k8s.io/sample-controller/Godeps/Godeps.json b/staging/src/k8s.io/sample-controller/Godeps/Godeps.json index 8986162cf0f..077157f6a3d 100644 --- a/staging/src/k8s.io/sample-controller/Godeps/Godeps.json +++ b/staging/src/k8s.io/sample-controller/Godeps/Godeps.json @@ -1076,7 +1076,7 @@ }, { "ImportPath": "k8s.io/kube-openapi/pkg/util/proto", - "Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2" + "Rev": "91cfa479c814065e420cee7ed227db0f63a5854e" } ] } diff --git a/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go b/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go index e4fe7c62ed9..f48700d5454 100644 --- a/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go +++ b/vendor/k8s.io/kube-openapi/pkg/builder/openapi.go @@ -58,7 +58,7 @@ func BuildOpenAPIDefinitionsForResource(model interface{}, config *common.Config o := newOpenAPI(config) // We can discard the return value of toSchema because all we care about is the side effect of calling it. // All the models created for this resource get added to o.swagger.Definitions - _, err := o.toSchema(model) + _, err := o.toSchema(getCanonicalTypeName(model)) if err != nil { return nil, err } @@ -69,6 +69,21 @@ func BuildOpenAPIDefinitionsForResource(model interface{}, config *common.Config return &swagger.Definitions, nil } +// BuildOpenAPIDefinitionsForResources returns the OpenAPI spec which includes the definitions for the +// passed type names. +func BuildOpenAPIDefinitionsForResources(config *common.Config, names ...string) (*spec.Swagger, error) { + o := newOpenAPI(config) + // We can discard the return value of toSchema because all we care about is the side effect of calling it. + // All the models created for this resource get added to o.swagger.Definitions + for _, name := range names { + _, err := o.toSchema(name) + if err != nil { + return nil, err + } + } + return o.finalizeSwagger() +} + // newOpenAPI sets up the openAPI object so we can build the spec. func newOpenAPI(config *common.Config) openAPI { o := openAPI{ @@ -120,7 +135,11 @@ func (o *openAPI) finalizeSwagger() (*spec.Swagger, error) { return o.swagger, nil } -func getCanonicalizeTypeName(t reflect.Type) string { +func getCanonicalTypeName(model interface{}) string { + t := reflect.TypeOf(model) + if t.Kind() == reflect.Ptr { + t = t.Elem() + } if t.PkgPath() == "" { return t.Name() } @@ -165,12 +184,7 @@ func (o *openAPI) buildDefinitionRecursively(name string) error { // buildDefinitionForType build a definition for a given type and return a referable name to its definition. // This is the main function that keep track of definitions used in this spec and is depend on code generated // by k8s.io/kubernetes/cmd/libs/go2idl/openapi-gen. -func (o *openAPI) buildDefinitionForType(sample interface{}) (string, error) { - t := reflect.TypeOf(sample) - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - name := getCanonicalizeTypeName(t) +func (o *openAPI) buildDefinitionForType(name string) (string, error) { if err := o.buildDefinitionRecursively(name); err != nil { return "", err } @@ -321,7 +335,7 @@ func (o *openAPI) buildOperations(route restful.Route, inPathCommonParamsMap map } func (o *openAPI) buildResponse(model interface{}, description string) (spec.Response, error) { - schema, err := o.toSchema(model) + schema, err := o.toSchema(getCanonicalTypeName(model)) if err != nil { return spec.Response{}, err } @@ -366,8 +380,8 @@ func (o *openAPI) findCommonParameters(routes []restful.Route) (map[interface{}] return commonParamsMap, nil } -func (o *openAPI) toSchema(model interface{}) (_ *spec.Schema, err error) { - if openAPIType, openAPIFormat := common.GetOpenAPITypeFormat(getCanonicalizeTypeName(reflect.TypeOf(model))); openAPIType != "" { +func (o *openAPI) toSchema(name string) (_ *spec.Schema, err error) { + if openAPIType, openAPIFormat := common.GetOpenAPITypeFormat(name); openAPIType != "" { return &spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{openAPIType}, @@ -375,7 +389,7 @@ func (o *openAPI) toSchema(model interface{}) (_ *spec.Schema, err error) { }, }, nil } else { - ref, err := o.buildDefinitionForType(model) + ref, err := o.buildDefinitionForType(name) if err != nil { return nil, err } @@ -399,7 +413,7 @@ func (o *openAPI) buildParameter(restParam restful.ParameterData, bodySample int case restful.BodyParameterKind: if bodySample != nil { ret.In = "body" - ret.Schema, err = o.toSchema(bodySample) + ret.Schema, err = o.toSchema(getCanonicalTypeName(bodySample)) return ret, err } else { // There is not enough information in the body parameter to build the definition. diff --git a/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go b/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go index 13e1e0985af..2f4aff54746 100644 --- a/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go +++ b/vendor/k8s.io/kube-openapi/pkg/generators/openapi.go @@ -383,8 +383,9 @@ func (g openAPITypeWriter) generate(t *types.Type) error { if hasOpenAPIDefinitionMethods(t) { g.Do("return $.OpenAPIDefinition|raw${\n"+ "Schema: spec.Schema{\n"+ - "SchemaProps: spec.SchemaProps{\n"+ - "Type:$.type|raw${}.OpenAPISchemaType(),\n"+ + "SchemaProps: spec.SchemaProps{\n", args) + g.generateDescription(t.CommentLines) + g.Do("Type:$.type|raw${}.OpenAPISchemaType(),\n"+ "Format:$.type|raw${}.OpenAPISchemaFormat(),\n"+ "},\n"+ "},\n"+