bump(k8s.io/kube-openapi): 91cfa479c814065e420cee7ed227db0f63a5854e

This commit is contained in:
Jordan Liggitt 2018-06-19 23:23:00 -04:00
parent debc5387fe
commit 102bc90120
No known key found for this signature in database
GPG Key ID: 39928704103C7229
12 changed files with 66 additions and 51 deletions

18
Godeps/Godeps.json generated
View File

@ -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",

View File

@ -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",

View File

@ -180,7 +180,7 @@
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
"Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2"
"Rev": "91cfa479c814065e420cee7ed227db0f63a5854e"
}
]
}

View File

@ -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",

View File

@ -588,7 +588,7 @@
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
"Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2"
"Rev": "91cfa479c814065e420cee7ed227db0f63a5854e"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -492,7 +492,7 @@
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
"Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2"
"Rev": "91cfa479c814065e420cee7ed227db0f63a5854e"
}
]
}

View File

@ -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"
}
]
}

View File

@ -1076,7 +1076,7 @@
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
"Rev": "8a9b82f00b3a86eac24681da3f9fe6c34c01cea2"
"Rev": "91cfa479c814065e420cee7ed227db0f63a5854e"
}
]
}

View File

@ -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.

View File

@ -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"+