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