-
Notifications
You must be signed in to change notification settings - Fork 600
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
Ce overrides validation #5730
Ce overrides validation #5730
Conversation
aa3f1f2
to
b3903cd
Compare
Codecov Report
@@ Coverage Diff @@
## main #5730 +/- ##
==========================================
- Coverage 82.68% 82.65% -0.03%
==========================================
Files 200 202 +2
Lines 6261 6326 +65
==========================================
+ Hits 5177 5229 +52
- Misses 750 758 +8
- Partials 334 339 +5
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
@@ -94,6 +94,7 @@ func (cs *PingSourceSpec) Validate(ctx context.Context) *apis.FieldError { | |||
} | |||
} | |||
} | |||
errs = errs.Also(cs.SourceSpec.Validate(ctx)) |
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.
Can we do this for all other sources as well?
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.
Sure, but, I don't know exactly where that should be. If you can give me a hand with this :)
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.
Sure, we need to go through every file in pkg/apis/sources/<version>/*_validation.go
, and check if the embedded SourceSpec
is validated, if not then we add the same check that you added for the PingSource
(line 97).
For example, for ApiServerSource
, we don't validate SourceSpec
[1], so we need to add the check errs = errs.Also(cs.SourceSpec.Validate(ctx))
here
Also, if we can add simple unit tests for each source to prevent regression that would be great too.
Hope this helps, thanks!
[1]
eventing/pkg/apis/sources/v1/apiserver_validation.go
Lines 39 to 77 in 407f3cb
func (cs *ApiServerSourceSpec) Validate(ctx context.Context) *apis.FieldError { | |
var errs *apis.FieldError | |
// Validate mode, if can be empty or set as certain value | |
switch cs.EventMode { | |
case ReferenceMode, ResourceMode: | |
// EventMode is valid. | |
default: | |
errs = errs.Also(apis.ErrInvalidValue(cs.EventMode, "mode")) | |
} | |
// Validate sink | |
errs = errs.Also(cs.Sink.Validate(ctx).ViaField("sink")) | |
if len(cs.Resources) == 0 { | |
errs = errs.Also(apis.ErrMissingField("resources")) | |
} | |
for i, res := range cs.Resources { | |
_, err := schema.ParseGroupVersion(res.APIVersion) | |
if err != nil { | |
errs = errs.Also(apis.ErrInvalidValue(res.APIVersion, "apiVersion").ViaFieldIndex("resources", i)) | |
} | |
if strings.TrimSpace(res.Kind) == "" { | |
errs = errs.Also(apis.ErrMissingField("kind").ViaFieldIndex("resources", i)) | |
} | |
} | |
if cs.ResourceOwner != nil { | |
_, err := schema.ParseGroupVersion(cs.ResourceOwner.APIVersion) | |
if err != nil { | |
errs = errs.Also(apis.ErrInvalidValue(cs.ResourceOwner.APIVersion, "apiVersion").ViaField("owner")) | |
} | |
if strings.TrimSpace(cs.ResourceOwner.Kind) == "" { | |
errs = errs.Also(apis.ErrMissingField("kind").ViaField("owner")) | |
} | |
} | |
return errs | |
} |
logs-conf.log
Outdated
@@ -0,0 +1,10295 @@ | |||
=== RUN TestChannelAddressableResolverClusterRoleTest |
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.
Please remove this.
The following is the coverage report on the affected files.
|
/retest |
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.
Thanks!
Can you add a release note in the PR body?
There is an example in the PR template in the .github
folder.
/lgtm
/approve
/kind bug
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gabo1208, pierDipi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes #5638
Release Note