From 1d4c6c9500d57459a4badbb636b4c9a06202669b Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Wed, 4 Mar 2020 12:11:35 +0100 Subject: [PATCH] fixing that triggers can actually have no filters... --- pkg/apis/eventing/v1alpha1/trigger_conversion.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/apis/eventing/v1alpha1/trigger_conversion.go b/pkg/apis/eventing/v1alpha1/trigger_conversion.go index fb9c0631809..eac948d8ec8 100644 --- a/pkg/apis/eventing/v1alpha1/trigger_conversion.go +++ b/pkg/apis/eventing/v1alpha1/trigger_conversion.go @@ -34,14 +34,19 @@ func (source *Trigger) ConvertTo(ctx context.Context, obj apis.Convertible) erro sink.Spec.Subscriber = source.Spec.Subscriber if source.Spec.Filter != nil { sink.Spec.Filter = &v1beta1.TriggerFilter{ - Attributes: make(v1beta1.TriggerFilterAttributes, 0), } if source.Spec.Filter.Attributes != nil { + sink.Spec.Filter = &v1beta1.TriggerFilter{ + Attributes: make(v1beta1.TriggerFilterAttributes, 0), + } for k, v := range *source.Spec.Filter.Attributes { sink.Spec.Filter.Attributes[k] = v } } if source.Spec.Filter.DeprecatedSourceAndType != nil { + sink.Spec.Filter = &v1beta1.TriggerFilter{ + Attributes: make(v1beta1.TriggerFilterAttributes, 0), + } sink.Spec.Filter.Attributes["source"] = source.Spec.Filter.DeprecatedSourceAndType.Source sink.Spec.Filter.Attributes["type"] = source.Spec.Filter.DeprecatedSourceAndType.Type } @@ -63,7 +68,7 @@ func (sink *Trigger) ConvertFrom(ctx context.Context, obj apis.Convertible) erro sink.ObjectMeta = source.ObjectMeta sink.Spec.Broker = source.Spec.Broker sink.Spec.Subscriber = source.Spec.Subscriber - if source.Spec.Filter != nil { + if source.Spec.Filter != nil && source.Spec.Filter.Attributes != nil { attributes := TriggerFilterAttributes{} for k, v := range source.Spec.Filter.Attributes { attributes[k] = v