Repository navigation
Add more defaulting and validation for DomainMapping - #9915
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9915 +/- ##
==========================================
+ Coverage 87.79% 87.82% +0.02%
==========================================
Files 183 183
Lines 8613 8630 +17
==========================================
+ Hits 7562 7579 +17
Misses 802 802
Partials 249 249
Continue to review full report at Codecov.
|
| if ref.Name == "" { | ||
| // validateMetadata validates the metadata section of a DomainMapping. | ||
| func (dm *DomainMapping) validateMetadata(ctx context.Context) (errs *apis.FieldError) { | ||
| if dm.Name == "" { |
There was a problem hiding this comment.
can this even in theory be empty?
There was a problem hiding this comment.
yeah, it can be empty if GenerateName is passed, but actually it'd be way clearer to check that instead of checking name isn't empty: fixed.
|
|
||
| // For now, ref must be a serving.knative.dev/v1 Service. | ||
| if spec.Ref.Kind != "Service" { | ||
| errs = errs.Also(apis.ErrGeneric(`must be "Service"`, "ref.kind")) |
There was a problem hiding this comment.
think the final argument does this already
There was a problem hiding this comment.
Well ref is already part of the parent error. I'd just do errs.Also(errs.ViaField()...) or along those lines :)
There was a problem hiding this comment.
I think this is fine as-is. 🤷
There was a problem hiding this comment.
you mean like errs = errs.Also(apis.ErrGeneric('must be "Service"', "kind").ViaField("ref"))? Can do, seems to be a bit wordier without much benefit - or are you thinking of something else?
There was a problem hiding this comment.
Yeah, it's just that "ref.kind" is internal knowledge to how field error constructs field paths.
Tomorrow when it's "/" separated this will be a bug. Otherwise, it's fine.
There was a problem hiding this comment.
I'm not worried about a switch to XPath 😉
|
just the one thing, otherwise LGTM. thanks for the validation improvements. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: julz, mattmoor The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Part 700ish of #9713.
Adds more validation and defaulting. Now:
This is probably a bit big, but it's mostly test boilerplate. I'd very happily split out some smaller PRs if anyone feels it's too painful to review, though.
/assign @mattmoor @dprotaso