-
Notifications
You must be signed in to change notification settings - Fork 630
Subscription Controller basics. #437
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
e340872
bc1bfc3
48774f4
9ab7921
b0eda0e
2900300
7fb9c0d
66c4ca3
c68633b
d53db39
a219571
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Copyright 2018 The Knative Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| apiVersion: apiextensions.k8s.io/v1beta1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: subscriptions.eventing.knative.dev | ||
| spec: | ||
| group: eventing.knative.dev | ||
| version: v1alpha1 | ||
| names: | ||
| kind: Subscription | ||
| plural: subscriptions | ||
| singular: subscription | ||
| categories: | ||
| - all | ||
| - knative | ||
| - eventing | ||
| shortNames: | ||
| - sub | ||
| scope: Namespaced |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| Copyright 2018 The Knative Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package v1alpha1 | ||
|
|
||
| import "testing" | ||
|
|
||
| // No-op test because method does nothing. | ||
| func TestSubscriptionDefaults(t *testing.T) { | ||
| s := Subscription{} | ||
| s.SetDefaults() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,9 @@ var _ duckv1alpha1.ConditionsAccessor = (*SubscriptionStatus)(nil) | |
| // Check that Subscription implements the Conditions duck type. | ||
| var _ = duck.VerifyType(&Subscription{}, &duckv1alpha1.Conditions{}) | ||
|
|
||
| // And it's Subscribable | ||
| var _ = duck.VerifyType(&Subscription{}, &duckv1alpha1.Subscribable{}) | ||
|
|
||
| // SubscriptionSpec specifies the Channel for incoming events, a Call target for | ||
| // processing those events and where to put the result of the processing. Only | ||
| // From (where the events are coming from) is always required. You can optionally | ||
|
|
@@ -175,8 +178,25 @@ type SubscriptionStatus struct { | |
| // +patchMergeKey=type | ||
| // +patchStrategy=merge | ||
| Conditions duckv1alpha1.Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
|
|
||
| // Subscription might be Subscribable. This depends if there's a Result channel | ||
| // In that case, this points to that resource. | ||
| Subscribable duckv1alpha1.Subscribable `json:"subscribable,omitempty"` | ||
|
Contributor
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. IIUC, if a Subscription has a from:
ref:
kind: Subscription
name: some-sub
call:
// ...
result:
// ...Is this the intent?
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. YES! :) That's exactly right.
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. YES! That's exactly right, and only if a Subscription has a Result. Just need to fill the status up for that and Result.Status would then point to the resolved ResultChannel |
||
| } | ||
|
|
||
| const ( | ||
|
Contributor
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. You need to update line 173 with: |
||
| // SubscriptionConditionReady has status True when all subconditions below have been set to True. | ||
| SubscriptionConditionReady = duckv1alpha1.ConditionReady | ||
|
|
||
| // SubscriptionReferencesResolved has status True when all the specified references have been successfully | ||
| // resolved. | ||
| SubscriptionConditionReferencesResolved duckv1alpha1.ConditionType = "Resolved" | ||
|
|
||
| // SubscriptionConditionFromReady has status True when controller has successfully added a subscription to From | ||
| // resource. | ||
| SubscriptionConditionFromReady duckv1alpha1.ConditionType = "FromReady" | ||
|
Contributor
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. After you add these, it is helpful to expose an https://github.com/knative/eventing/pull/457/files#diff-67a9c730f0d592911dfa317323fea9e5R131 Also a https://github.com/knative/eventing/pull/457/files#diff-67a9c730f0d592911dfa317323fea9e5R137 And then |
||
| ) | ||
|
|
||
| // GetSpecJSON returns spec as json | ||
| func (s *Subscription) GetSpecJSON() ([]byte, error) { | ||
|
Contributor
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. you can delete GetSpecJSON now that the |
||
| return json.Marshal(s.Spec) | ||
|
|
||
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.
cc @n3wscott I think there's a helper for 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.
I couldn't find. I thought I found it but the name was a bit misleading (IMHO). I created one but didn't want to block this on it and instead would prefer to clean it up later.
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 about this:
Uh oh!
There was an error while loading. Please reload this page.
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.
There is no helper for adding details to a Err* type method, there is a helper for setting the index.
it should be: