Skip to content

Commit

Permalink
Resolve TriggerBindings with no Kind set in sink
Browse files Browse the repository at this point in the history
When upgrading from 0.2.1 to 0.3, the Sink might have
to process a Binding that has no `Kind` set. This is
because, we only persist the default Kind when the Binding
object is created/updated. The reconciler also sets the defaults
by calling `SetDefaults` but that change is not persisted to etcd.

In the future, we might want to consider updating the object from the
reconciler itself if any default values were set.

Fixes: #459

Signed-off-by: Dibyo Mukherjee <[email protected]>
  • Loading branch information
dibyom authored and tekton-robot committed Feb 28, 2020
1 parent 0b70ea6 commit e43f662
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/template/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ func ResolveTrigger(trigger triggersv1.EventListenerTrigger, getTB getTriggerBin
return ResolvedTrigger{}, fmt.Errorf("error getting ClusterTriggerBinding %s: %w", b.Name, err)
}
ctb = append(ctb, ctb2)
}

if b.Kind == triggersv1.NamespacedTriggerBindingKind {
} else {
tb2, err := getTB(b.Name, metav1.GetOptions{})
if err != nil {
return ResolvedTrigger{}, fmt.Errorf("error getting TriggerBinding %s: %w", b.Name, err)
Expand Down
18 changes: 18 additions & 0 deletions pkg/template/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,24 @@ func Test_ResolveTrigger(t *testing.T) {
TriggerTemplate: &tt,
},
},
{
name: "missing kind implies namespacedTriggerBinding",
trigger: triggersv1.EventListenerTrigger{
Bindings: []*triggersv1.EventListenerBinding{{
Name: "my-triggerbinding",
APIVersion: "v1alpha1",
}},
Template: triggersv1.EventListenerTemplate{
Name: "my-triggertemplate",
APIVersion: "v1alpha1",
},
},
want: ResolvedTrigger{
TriggerBindings: []*triggersv1.TriggerBinding{tb},
ClusterTriggerBindings: []*triggersv1.ClusterTriggerBinding{},
TriggerTemplate: &tt,
},
},
}

for _, tc := range tests {
Expand Down

0 comments on commit e43f662

Please sign in to comment.