-
Notifications
You must be signed in to change notification settings - Fork 441
🐛 Fix validation errors happening in v1.18 #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
pkg: add default: "TCP" to api/core/v1.Procotol scheme. cronjob_types: add DefaultedObject required field and use NestedObject type for EmbeddedResource. Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dgrisonnet The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @dgrisonnet! |
/assign @mengqiy |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@@ -110,7 +110,7 @@ type CronJobSpec struct { | |||
DefaultedSlice []string `json:"defaultedSlice"` | |||
|
|||
// This tests that object defaulting can be performed. | |||
// +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {bar: false}}} | |||
// +kubebuilder:default={{nested: {foo: "baz", bar: true}},{nested: {foo: "baz", bar: false}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to add the extra nested object?
@@ -119,7 +119,7 @@ type CronJobSpec struct { | |||
|
|||
// +kubebuilder:validation:EmbeddedResource | |||
// +kubebuilder:validation:nullable | |||
EmbeddedResource runtime.RawExtension `json:"embeddedResource"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was testing an arbitrary embedded object, which would mean we should set x-kubernetes-preserve-unknown-fields: true
, right?
"k8s.io/api/core/v1": func(p *Parser, pkg *loader.Package) { | ||
p.Schemata[TypeIdent{Name: "Protocol", Package: pkg}] = apiext.JSONSchemaProps{ | ||
Type: "string", | ||
Default: &apiext.JSON{Raw: []byte(strconv.Quote("TCP"))}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't quite right... the default isn't inherent to the type, it's contextual (Protocol inside ServicePort and ContainerPort defaults to "TCP", but other uses might not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you suggest we do here then?
I thought @jennybuckley was working on an upstream solution. Is this until that lands? or ? |
Closing as #480 was merged. |
This PR intends to fix validation errors happening when creating generated controllers in Kubernetes v1.18.
In order to fix embeddedResource, and defaultedObject required value errors, this PR adds the missing values inside of
cronjob_types.go
.For the protocol validation errors, this PR injects the default Protocol value inside of the scheme.
Fixes #438