-
Notifications
You must be signed in to change notification settings - Fork 630
Create subscriber.uri and deprecate subscriber.dnsName #994
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,10 @@ func (s *Subscription) Validate(ctx context.Context) *apis.FieldError { | |
| return s.Spec.Validate(ctx).ViaField("spec") | ||
| } | ||
|
|
||
| // We require always Channel | ||
| // Also at least one of 'subscriber' and 'reply' must be defined (non-nill and non-empty) | ||
| func (ss *SubscriptionSpec) Validate(ctx context.Context) *apis.FieldError { | ||
| // We require always Channel. | ||
| // Also at least one of 'subscriber' and 'reply' must be defined (non-nil and non-empty). | ||
|
|
||
| var errs *apis.FieldError | ||
| if isChannelEmpty(ss.Channel) { | ||
| fe := apis.ErrMissingField("channel") | ||
|
|
@@ -66,15 +67,34 @@ func (ss *SubscriptionSpec) Validate(ctx context.Context) *apis.FieldError { | |
| } | ||
|
|
||
| func isSubscriberSpecNilOrEmpty(s *SubscriberSpec) bool { | ||
| return s == nil || equality.Semantic.DeepEqual(s, &SubscriberSpec{}) || | ||
| (equality.Semantic.DeepEqual(s.Ref, &corev1.ObjectReference{}) && s.DNSName == nil) | ||
|
|
||
| if s == nil || equality.Semantic.DeepEqual(s, &SubscriberSpec{}) { | ||
| return true | ||
| } | ||
| if equality.Semantic.DeepEqual(s.Ref, &corev1.ObjectReference{}) && | ||
| s.DeprecatedDNSName == nil && | ||
| s.URI == nil { | ||
| return true | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| func isValidSubscriberSpec(s SubscriberSpec) *apis.FieldError { | ||
| var errs *apis.FieldError | ||
| if s.DNSName != nil && *s.DNSName != "" && s.Ref != nil && !equality.Semantic.DeepEqual(s.Ref, &corev1.ObjectReference{}) { | ||
| errs = errs.Also(apis.ErrMultipleOneOf("ref", "dnsName")) | ||
|
|
||
| fieldsSet := make([]string, 0, 0) | ||
| if s.Ref != nil && !equality.Semantic.DeepEqual(s.Ref, &corev1.ObjectReference{}) { | ||
| fieldsSet = append(fieldsSet, "ref") | ||
| } | ||
| if s.DeprecatedDNSName != nil && *s.DeprecatedDNSName != "" { | ||
| fieldsSet = append(fieldsSet, "dnsName") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should it populate the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My hesitation for doing that is code like our Trigger controller, which will compare the What do you think? Is it worth the potential trouble to move things for the user?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, fair point w/ the Trigger controller. So, no need to "adjust" it |
||
| } | ||
| if s.URI != nil && *s.URI != "" { | ||
| fieldsSet = append(fieldsSet, "uri") | ||
| } | ||
| if len(fieldsSet) == 0 { | ||
| errs = errs.Also(apis.ErrMissingOneOf("ref", "dnsName", "uri")) | ||
| } else if len(fieldsSet) > 1 { | ||
| errs = errs.Also(apis.ErrMultipleOneOf(fieldsSet...)) | ||
| } | ||
|
|
||
| // If Ref given, check the fields. | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
when will it be removed? the
DeprecatedDNSName?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.
#993 tracks removing it. The plan is to leave it deprecated for one release. Then remove it in the next. So if this PR merges into 0.5.0, we would remove it in 0.6.0.