-
Notifications
You must be signed in to change notification settings - Fork 630
Default channel for Sequence #1569
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
Merged
knative-prow-robot
merged 41 commits into
knative:master
from
nachocano:default-channel-sequence
Jul 26, 2019
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
1802578
adding messaging.channel resource
nachocano 755ac4a
channel messaging
nachocano b1f91d8
using ChannelTemplateSpec
nachocano 7d34bcf
updating channel controller
nachocano 71187ba
channel validation
nachocano 109e8c6
setting to channelTemplate
nachocano 2b54e41
to json
nachocano eac06fe
channel defaulter
nachocano a7b0c63
working
nachocano b419077
removing logs
nachocano f5d4997
Merge remote-tracking branch 'upstream/master' into default-channel
nachocano 4727ae3
patching subscriptions... infinite loop
nachocano d1723c1
updates
nachocano 970ada4
immutable
nachocano 870a146
problems with cyclic dependencies
nachocano 5e5b8bd
moving channel defaulter to duck to avoid cyclic dependency
nachocano d0ebf80
channel defaulter test
nachocano 5cdb7e1
updating UTs
nachocano 9043e37
channel validation test
nachocano db7127b
updating validation
nachocano eee7e1d
updating lifecycle
nachocano e1925ac
updates to broker
nachocano c0e7af4
fixing sequence
nachocano 4916884
broker types
nachocano ef016c5
updating deprecated message
nachocano dadac47
updating broker validation
nachocano 961b0f1
cosmetic
nachocano d30d7ba
injection magic
nachocano 4761836
update to broker test
nachocano 42de64b
updating UTs
nachocano 2734cb2
more UTs
nachocano b44c8dd
eventingchannel package
nachocano 7c57d38
cosmetic
nachocano 376a5b5
cosmetics
nachocano c018c2d
compilation, my bad...
nachocano 025462e
hopefully the last one
nachocano 678e589
Ville's comments
nachocano 356ca7c
Adam's comments, plus cosmetic tests to try to make coverage pass.
nachocano 0ee8679
sequence defaults
nachocano b77538b
Merge remote-tracking branch 'upstream/master' into default-channel-s…
nachocano 2afd344
compiling tests... hopefully
nachocano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| Copyright 2019 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 ( | ||
| "context" | ||
| "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "testing" | ||
|
|
||
| "github.com/google/go-cmp/cmp" | ||
| eventingduckv1alpha1 "github.com/knative/eventing/pkg/apis/duck/v1alpha1" | ||
| ) | ||
|
|
||
| var ( | ||
| defaultTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ | ||
| TypeMeta: v1.TypeMeta{ | ||
| APIVersion: SchemeGroupVersion.String(), | ||
| Kind: "InMemoryChannel", | ||
| }, | ||
| } | ||
| ) | ||
|
|
||
| func TestSequenceSetDefaults(t *testing.T) { | ||
| testCases := map[string]struct { | ||
| nilChannelDefaulter bool | ||
| channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec | ||
| initial Sequence | ||
| expected Sequence | ||
| }{ | ||
| "nil ChannelDefaulter": { | ||
| nilChannelDefaulter: true, | ||
| expected: Sequence{}, | ||
| }, | ||
| "unset ChannelDefaulter": { | ||
| expected: Sequence{}, | ||
| }, | ||
| "set ChannelDefaulter": { | ||
| channelTemplate: defaultChannelTemplate, | ||
| expected: Sequence{ | ||
| Spec: SequenceSpec{ | ||
| ChannelTemplate: defaultChannelTemplate, | ||
| }, | ||
| }, | ||
| }, | ||
| "template already specified": { | ||
| channelTemplate: defaultChannelTemplate, | ||
| initial: Sequence{ | ||
| Spec: SequenceSpec{ | ||
| ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ | ||
| TypeMeta: v1.TypeMeta{ | ||
| APIVersion: SchemeGroupVersion.String(), | ||
| Kind: "OtherChannel", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| expected: Sequence{ | ||
| Spec: SequenceSpec{ | ||
| ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ | ||
| TypeMeta: v1.TypeMeta{ | ||
| APIVersion: SchemeGroupVersion.String(), | ||
| Kind: "OtherChannel", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| for n, tc := range testCases { | ||
| t.Run(n, func(t *testing.T) { | ||
| if !tc.nilChannelDefaulter { | ||
| eventingduckv1alpha1.ChannelDefaulterSingleton = &sequenceChannelDefaulter{ | ||
| channelTemplate: tc.channelTemplate, | ||
| } | ||
| defer func() { eventingduckv1alpha1.ChannelDefaulterSingleton = nil }() | ||
| } | ||
| tc.initial.SetDefaults(context.TODO()) | ||
| if diff := cmp.Diff(tc.expected, tc.initial); diff != "" { | ||
| t.Fatalf("Unexpected defaults (-want, +got): %s", diff) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| type sequenceChannelDefaulter struct { | ||
| channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec | ||
| } | ||
|
|
||
| func (cd *sequenceChannelDefaulter) GetDefault(_ string) *eventingduckv1alpha1.ChannelTemplateSpec { | ||
| return cd.channelTemplate | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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 happens if channelTemplate is set but empty?
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.
you mean something like:
It will fail because we validate en the next lines wether it has APIVersion and Kind.
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.
Ahh, it was below the fold, so I didn't notice it.