Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d8a9dfac
Commit
d8a9dfac
authored
Apr 29, 2019
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiextensions: add structural x-kubernetes-* fields to validation schemas
parent
e9af72c6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
1 deletion
+75
-1
violation_exceptions.list
api/api-rules/violation_exceptions.list
+3
-0
types_jsonschema.go
...ions-apiserver/pkg/apis/apiextensions/types_jsonschema.go
+30
-0
types_jsonschema.go
...server/pkg/apis/apiextensions/v1beta1/types_jsonschema.go
+31
-0
validation.go
...apiserver/pkg/apis/apiextensions/validation/validation.go
+1
-1
validation.go
...tensions-apiserver/pkg/apiserver/validation/validation.go
+10
-0
No files found.
api/api-rules/violation_exceptions.list
View file @
d8a9dfac
...
...
@@ -30,6 +30,9 @@ API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiexten
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSON,Raw
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaProps,Ref
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaProps,Schema
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaProps,XEmbeddedResource
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaProps,XIntOrString
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaProps,XPreserveUnknownFields
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaPropsOrArray,JSONSchemas
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaPropsOrArray,Schema
API rule violation: names_match,k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1,JSONSchemaPropsOrBool,Allows
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types_jsonschema.go
View file @
d8a9dfac
...
...
@@ -55,6 +55,36 @@ type JSONSchemaProps struct {
Definitions
JSONSchemaDefinitions
ExternalDocs
*
ExternalDocumentation
Example
*
JSON
// x-kubernetes-preserve-unknown-fields stops the API server
// decoding step from pruning fields which are not specified
// in the validation schema. This affects fields recursively,
// but switches back to normal pruning behaviour if nested
// properties or additionalProperties are specified in the schema.
XPreserveUnknownFields
bool
// x-kubernetes-embedded-resource defines that the value is an
// embedded Kubernetes runtime.Object, with TypeMeta and
// ObjectMeta. The type must be object. It is allowed to further
// restrict the embedded object. Both ObjectMeta and TypeMeta
// are validated automatically. x-kubernetes-preserve-unknown-fields
// must be true.
XEmbeddedResource
bool
// x-kubernetes-int-or-string specifies that this value is
// either an integer or a string. If this is true, an empty
// type is allowed and type as child of anyOf is permitted
// if following one of the following patterns:
//
// 1) anyOf:
// - type: integer
// - type: string
// 2) allOf:
// - anyOf:
// - type: integer
// - type: string
// - ... zero or more
XIntOrString
bool
}
// JSON represents any valid JSON value.
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types_jsonschema.go
View file @
d8a9dfac
...
...
@@ -55,6 +55,37 @@ type JSONSchemaProps struct {
ExternalDocs
*
ExternalDocumentation
`json:"externalDocs,omitempty" protobuf:"bytes,35,opt,name=externalDocs"`
Example
*
JSON
`json:"example,omitempty" protobuf:"bytes,36,opt,name=example"`
Nullable
bool
`json:"nullable,omitempty" protobuf:"bytes,37,opt,name=nullable"`
// x-kubernetes-preserve-unknown-fields stops the API server
// decoding step from pruning fields which are not specified
// in the validation schema. This affects fields recursively,
// but switches back to normal pruning behaviour if nested
// properties or additionalProperties are specified in the schema.
XPreserveUnknownFields
bool
`json:"x-kubernetes-preserve-unknown-fields,omitempty" protobuf:"bytes,38,opt,name=xKubernetesPreserveUnknownFields"`
// x-kubernetes-embedded-resource defines that the value is an
// embedded Kubernetes runtime.Object, with TypeMeta and
// ObjectMeta. The type must be object. It is allowed to further
// restrict the embedded object. kind, apiVersion and metadata
// are validated automatically. x-kubernetes-preserve-unknown-fields
// is allowed to be true, but does not have to be if the object
// is fully specified (up to kind, apiVersion, metadata).
XEmbeddedResource
bool
`json:"x-kubernetes-embedded-resource,omitempty" protobuf:"bytes,39,opt,name=xKubernetesEmbeddedResource"`
// x-kubernetes-int-or-string specifies that this value is
// either an integer or a string. If this is true, an empty
// type is allowed and type as child of anyOf is permitted
// if following one of the following patterns:
//
// 1) anyOf:
// - type: integer
// - type: string
// 2) allOf:
// - anyOf:
// - type: integer
// - type: string
// - ... zero or more
XIntOrString
bool
`json:"x-kubernetes-int-or-string,omitempty" protobuf:"bytes,40,opt,name=xKubernetesIntOrString"`
}
// JSON represents any valid JSON value.
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go
View file @
d8a9dfac
...
...
@@ -786,7 +786,7 @@ func validateSimpleJSONPath(s string, fldPath *field.Path) field.ErrorList {
return
allErrs
}
var
allowedFieldsAtRootSchema
=
[]
string
{
"Description"
,
"Type"
,
"Format"
,
"Title"
,
"Maximum"
,
"ExclusiveMaximum"
,
"Minimum"
,
"ExclusiveMinimum"
,
"MaxLength"
,
"MinLength"
,
"Pattern"
,
"MaxItems"
,
"MinItems"
,
"UniqueItems"
,
"MultipleOf"
,
"Required"
,
"Items"
,
"Properties"
,
"ExternalDocs"
,
"Example"
}
var
allowedFieldsAtRootSchema
=
[]
string
{
"Description"
,
"Type"
,
"Format"
,
"Title"
,
"Maximum"
,
"ExclusiveMaximum"
,
"Minimum"
,
"ExclusiveMinimum"
,
"MaxLength"
,
"MinLength"
,
"Pattern"
,
"MaxItems"
,
"MinItems"
,
"UniqueItems"
,
"MultipleOf"
,
"Required"
,
"Items"
,
"Properties"
,
"ExternalDocs"
,
"Example"
,
"XPreserveUnknownFields"
}
func
allowedAtRootSchema
(
field
string
)
bool
{
for
_
,
v
:=
range
allowedFieldsAtRootSchema
{
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/validation.go
View file @
d8a9dfac
...
...
@@ -194,6 +194,16 @@ func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, ou
}
}
if
in
.
XPreserveUnknownFields
{
out
.
VendorExtensible
.
AddExtension
(
"x-kubernetes-preserve-unknown-fields"
,
true
)
}
if
in
.
XEmbeddedResource
{
out
.
VendorExtensible
.
AddExtension
(
"x-kubernetes-embedded-resource"
,
true
)
}
if
in
.
XIntOrString
{
out
.
VendorExtensible
.
AddExtension
(
"x-kubernetes-int-or-string"
,
true
)
}
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment