go.mod: bump client-go and api machinerie

I had to run `make generate`.
Some API functions got additional parameters `Options` and `Context`.
I used empty options and `context.TODO()` for now.

Signed-off-by: leonnicolas <leonloechner@gmx.de>
This commit is contained in:
leonnicolas
2021-05-15 12:08:31 +02:00
parent f2c37b9de6
commit a3bf13711c
2386 changed files with 419055 additions and 183398 deletions

View File

@@ -24,6 +24,12 @@ import (
"github.com/go-openapi/spec"
)
const (
// TODO: Make this configurable.
ExtensionPrefix = "x-kubernetes-"
ExtensionV2Schema = ExtensionPrefix + "v2-schema"
)
// OpenAPIDefinition describes single type. Normally these definitions are auto-generated using gen-openapi.
type OpenAPIDefinition struct {
Schema spec.Schema
@@ -43,6 +49,10 @@ type OpenAPIDefinitionGetter interface {
OpenAPIDefinition() *OpenAPIDefinition
}
type OpenAPIV3DefinitionGetter interface {
OpenAPIV3Definition() *OpenAPIDefinition
}
type PathHandler interface {
Handle(path string, handler http.Handler)
}
@@ -95,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
@@ -158,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 {
@@ -172,3 +198,11 @@ func EscapeJsonPointer(p string) string {
p = strings.Replace(p, "/", "~1", -1)
return p
}
func EmbedOpenAPIDefinitionIntoV2Extension(main OpenAPIDefinition, embedded OpenAPIDefinition) OpenAPIDefinition {
if main.Schema.Extensions == nil {
main.Schema.Extensions = make(map[string]interface{})
}
main.Schema.Extensions[ExtensionV2Schema] = embedded.Schema
return main
}