mirror of
https://github.com/rancher/rke.git
synced 2025-09-17 23:49:06 +00:00
Update to k8s v1.20
This commit is contained in:
66
vendor/k8s.io/kube-openapi/pkg/common/common.go
generated
vendored
66
vendor/k8s.io/kube-openapi/pkg/common/common.go
generated
vendored
@@ -26,7 +26,7 @@ import (
|
||||
|
||||
const (
|
||||
// TODO: Make this configurable.
|
||||
ExtensionPrefix = "x-kubernetes-"
|
||||
ExtensionPrefix = "x-kubernetes-"
|
||||
ExtensionV2Schema = ExtensionPrefix + "v2-schema"
|
||||
)
|
||||
|
||||
@@ -105,28 +105,34 @@ type Config struct {
|
||||
DefaultSecurity []map[string][]string
|
||||
}
|
||||
|
||||
var schemaTypeFormatMap = map[string][]string{
|
||||
"uint": {"integer", "int32"},
|
||||
"uint8": {"integer", "byte"},
|
||||
"uint16": {"integer", "int32"},
|
||||
"uint32": {"integer", "int64"},
|
||||
"uint64": {"integer", "int64"},
|
||||
"int": {"integer", "int32"},
|
||||
"int8": {"integer", "byte"},
|
||||
"int16": {"integer", "int32"},
|
||||
"int32": {"integer", "int32"},
|
||||
"int64": {"integer", "int64"},
|
||||
"byte": {"integer", "byte"},
|
||||
"float64": {"number", "double"},
|
||||
"float32": {"number", "float"},
|
||||
"bool": {"boolean", ""},
|
||||
"time.Time": {"string", "date-time"},
|
||||
"string": {"string", ""},
|
||||
"integer": {"integer", ""},
|
||||
"number": {"number", ""},
|
||||
"boolean": {"boolean", ""},
|
||||
"[]byte": {"string", "byte"}, // base64 encoded characters
|
||||
"interface{}": {"object", ""},
|
||||
type typeInfo struct {
|
||||
name string
|
||||
format string
|
||||
zero interface{}
|
||||
}
|
||||
|
||||
var schemaTypeFormatMap = map[string]typeInfo{
|
||||
"uint": {"integer", "int32", 0.},
|
||||
"uint8": {"integer", "byte", 0.},
|
||||
"uint16": {"integer", "int32", 0.},
|
||||
"uint32": {"integer", "int64", 0.},
|
||||
"uint64": {"integer", "int64", 0.},
|
||||
"int": {"integer", "int32", 0.},
|
||||
"int8": {"integer", "byte", 0.},
|
||||
"int16": {"integer", "int32", 0.},
|
||||
"int32": {"integer", "int32", 0.},
|
||||
"int64": {"integer", "int64", 0.},
|
||||
"byte": {"integer", "byte", 0},
|
||||
"float64": {"number", "double", 0.},
|
||||
"float32": {"number", "float", 0.},
|
||||
"bool": {"boolean", "", false},
|
||||
"time.Time": {"string", "date-time", ""},
|
||||
"string": {"string", "", ""},
|
||||
"integer": {"integer", "", 0.},
|
||||
"number": {"number", "", 0.},
|
||||
"boolean": {"boolean", "", false},
|
||||
"[]byte": {"string", "byte", ""}, // base64 encoded characters
|
||||
"interface{}": {"object", "", interface{}(nil)},
|
||||
}
|
||||
|
||||
// This function is a reference for converting go (or any custom type) to a simple open API type,format pair. There are
|
||||
@@ -168,12 +174,22 @@ var schemaTypeFormatMap = map[string][]string{
|
||||
// }
|
||||
// }
|
||||
//
|
||||
func GetOpenAPITypeFormat(typeName string) (string, string) {
|
||||
func OpenAPITypeFormat(typeName string) (string, string) {
|
||||
mapped, ok := schemaTypeFormatMap[typeName]
|
||||
if !ok {
|
||||
return "", ""
|
||||
}
|
||||
return mapped[0], mapped[1]
|
||||
return mapped.name, mapped.format
|
||||
}
|
||||
|
||||
// Returns the zero-value for the given type along with true if the type
|
||||
// could be found.
|
||||
func OpenAPIZeroValue(typeName string) (interface{}, bool) {
|
||||
mapped, ok := schemaTypeFormatMap[typeName]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
return mapped.zero, true
|
||||
}
|
||||
|
||||
func EscapeJsonPointer(p string) string {
|
||||
|
64
vendor/k8s.io/kube-openapi/pkg/util/proto/document.go
generated
vendored
64
vendor/k8s.io/kube-openapi/pkg/util/proto/document.go
generated
vendored
@@ -21,7 +21,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/googleapis/gnostic/OpenAPIv2"
|
||||
openapi_v2 "github.com/googleapis/gnostic/openapiv2"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
@@ -109,19 +109,39 @@ func (d *Definitions) parseReference(s *openapi_v2.Schema, path *Path) (Schema,
|
||||
if _, ok := d.models[reference]; !ok {
|
||||
return nil, newSchemaError(path, "unknown model in reference: %q", reference)
|
||||
}
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Ref{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
reference: reference,
|
||||
definitions: d,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseBaseSchema(s *openapi_v2.Schema, path *Path) BaseSchema {
|
||||
func parseDefault(def *openapi_v2.Any) (interface{}, error) {
|
||||
if def == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var i interface{}
|
||||
if err := yaml.Unmarshal([]byte(def.Yaml), &i); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (d *Definitions) parseBaseSchema(s *openapi_v2.Schema, path *Path) (BaseSchema, error) {
|
||||
def, err := parseDefault(s.GetDefault())
|
||||
if err != nil {
|
||||
return BaseSchema{}, err
|
||||
}
|
||||
return BaseSchema{
|
||||
Description: s.GetDescription(),
|
||||
Default: def,
|
||||
Extensions: VendorExtensionToMap(s.GetVendorExtension()),
|
||||
Path: *path,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// We believe the schema is a map, verify and return a new schema
|
||||
@@ -132,8 +152,12 @@ func (d *Definitions) parseMap(s *openapi_v2.Schema, path *Path) (Schema, error)
|
||||
var sub Schema
|
||||
// TODO(incomplete): this misses the boolean case as AdditionalProperties is a bool+schema sum type.
|
||||
if s.GetAdditionalProperties().GetSchema() == nil {
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sub = &Arbitrary{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
@@ -142,8 +166,12 @@ func (d *Definitions) parseMap(s *openapi_v2.Schema, path *Path) (Schema, error)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Map{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
SubType: sub,
|
||||
}, nil
|
||||
}
|
||||
@@ -165,8 +193,12 @@ func (d *Definitions) parsePrimitive(s *openapi_v2.Schema, path *Path) (Schema,
|
||||
default:
|
||||
return nil, newSchemaError(path, "Unknown primitive type: %q", t)
|
||||
}
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Primitive{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
Type: t,
|
||||
Format: s.GetFormat(),
|
||||
}, nil
|
||||
@@ -188,8 +220,12 @@ func (d *Definitions) parseArray(s *openapi_v2.Schema, path *Path) (Schema, erro
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Array{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
SubType: sub,
|
||||
}, nil
|
||||
}
|
||||
@@ -216,8 +252,12 @@ func (d *Definitions) parseKind(s *openapi_v2.Schema, path *Path) (Schema, error
|
||||
fieldOrder = append(fieldOrder, name)
|
||||
}
|
||||
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Kind{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
RequiredFields: s.GetRequired(),
|
||||
Fields: fields,
|
||||
FieldOrder: fieldOrder,
|
||||
@@ -225,8 +265,12 @@ func (d *Definitions) parseKind(s *openapi_v2.Schema, path *Path) (Schema, error
|
||||
}
|
||||
|
||||
func (d *Definitions) parseArbitrary(s *openapi_v2.Schema, path *Path) (Schema, error) {
|
||||
base, err := d.parseBaseSchema(s, path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Arbitrary{
|
||||
BaseSchema: d.parseBaseSchema(s, path),
|
||||
BaseSchema: base,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
7
vendor/k8s.io/kube-openapi/pkg/util/proto/openapi.go
generated
vendored
7
vendor/k8s.io/kube-openapi/pkg/util/proto/openapi.go
generated
vendored
@@ -77,6 +77,8 @@ type Schema interface {
|
||||
GetPath() *Path
|
||||
// Describes the field.
|
||||
GetDescription() string
|
||||
// Default for that schema.
|
||||
GetDefault() interface{}
|
||||
// Returns type extensions.
|
||||
GetExtensions() map[string]interface{}
|
||||
}
|
||||
@@ -129,6 +131,7 @@ func (p *Path) FieldPath(field string) Path {
|
||||
type BaseSchema struct {
|
||||
Description string
|
||||
Extensions map[string]interface{}
|
||||
Default interface{}
|
||||
|
||||
Path Path
|
||||
}
|
||||
@@ -141,6 +144,10 @@ func (b *BaseSchema) GetExtensions() map[string]interface{} {
|
||||
return b.Extensions
|
||||
}
|
||||
|
||||
func (b *BaseSchema) GetDefault() interface{} {
|
||||
return b.Default
|
||||
}
|
||||
|
||||
func (b *BaseSchema) GetPath() *Path {
|
||||
return &b.Path
|
||||
}
|
||||
|
2
vendor/k8s.io/kube-openapi/pkg/util/proto/validation/types.go
generated
vendored
2
vendor/k8s.io/kube-openapi/pkg/util/proto/validation/types.go
generated
vendored
@@ -210,7 +210,7 @@ func (item *primitiveItem) VisitPrimitive(schema *proto.Primitive) {
|
||||
}
|
||||
case proto.Number:
|
||||
switch item.Kind {
|
||||
case proto.Number:
|
||||
case proto.Integer, proto.Number:
|
||||
return
|
||||
}
|
||||
case proto.String:
|
||||
|
Reference in New Issue
Block a user