diff --git a/pkg/reconciler/customrun/customrun.go b/pkg/reconciler/customrun/customrun.go index ea40825bf19..fb36f305171 100644 --- a/pkg/reconciler/customrun/customrun.go +++ b/pkg/reconciler/customrun/customrun.go @@ -23,6 +23,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" customrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/customrun" + "github.com/tektoncd/pipeline/pkg/reconciler/events" "github.com/tektoncd/pipeline/pkg/reconciler/events/cache" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" _ "github.com/tektoncd/pipeline/pkg/taskrunmetrics/fake" // Make sure the taskrunmetrics are setup @@ -64,7 +65,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, customRun *v1beta1.Custo condition := customRunEvents.Status.GetCondition(apis.ConditionSucceeded) logger.Debugf("Emitting cloudevent for %s, condition: %s", customRunEvents.Name, condition) - cloudevent.EmitCloudEvents(ctx, &customRunEvents) + events.EmitCloudEvents(ctx, &customRunEvents) } return nil diff --git a/pkg/reconciler/events/event.go b/pkg/reconciler/events/event.go index e61a24e7994..c4af716f7c9 100644 --- a/pkg/reconciler/events/event.go +++ b/pkg/reconciler/events/event.go @@ -34,3 +34,9 @@ func Emit(ctx context.Context, beforeCondition *apis.Condition, afterCondition * k8sevent.EmitK8sEvents(ctx, beforeCondition, afterCondition, object) cloudevent.EmitCloudEventsWhenConditionChange(ctx, beforeCondition, afterCondition, object) } + +// EmitCloudEvents is refactored to cloudevent, this is to avoid breaking change +var EmitCloudEvents = cloudevent.EmitCloudEvents + +// EmitError is refactored to k8sevent, this is to avoid breaking change +var EmitError = k8sevent.EmitError diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index dd6dc24652a..7a6e7357a09 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -46,7 +46,6 @@ import ( tknreconciler "github.com/tektoncd/pipeline/pkg/reconciler" "github.com/tektoncd/pipeline/pkg/reconciler/events" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" - "github.com/tektoncd/pipeline/pkg/reconciler/events/k8sevent" "github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag" rprp "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/pipelinespec" "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources" @@ -292,7 +291,7 @@ func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, pr *v1 _, err := c.updateLabelsAndAnnotations(ctx, pr) if err != nil { logger.Warn("Failed to update PipelineRun labels/annotations", zap.Error(err)) - k8sevent.EmitError(controller.GetEventRecorder(ctx), err, pr) + events.EmitError(controller.GetEventRecorder(ctx), err, pr) } merr := multierror.Append(previousError, err).ErrorOrNil() diff --git a/pkg/reconciler/run/run.go b/pkg/reconciler/run/run.go index e29ca80c85b..9a4f0f0cf16 100644 --- a/pkg/reconciler/run/run.go +++ b/pkg/reconciler/run/run.go @@ -23,6 +23,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/config" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" runreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1alpha1/run" + "github.com/tektoncd/pipeline/pkg/reconciler/events" "github.com/tektoncd/pipeline/pkg/reconciler/events/cache" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" _ "github.com/tektoncd/pipeline/pkg/taskrunmetrics/fake" // Make sure the taskrunmetrics are setup @@ -65,7 +66,7 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, run *v1alpha1.Run) pkgre condition := runEvents.Status.GetCondition(apis.ConditionSucceeded) logger.Debugf("Emitting cloudevent for %s, condition: %s", runEvents.Name, condition) - cloudevent.EmitCloudEvents(ctx, &runEvents) + events.EmitCloudEvents(ctx, &runEvents) } return nil diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index c882126ba51..4ddd3d360b1 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -42,7 +42,6 @@ import ( tknreconciler "github.com/tektoncd/pipeline/pkg/reconciler" "github.com/tektoncd/pipeline/pkg/reconciler/events" "github.com/tektoncd/pipeline/pkg/reconciler/events/cloudevent" - "github.com/tektoncd/pipeline/pkg/reconciler/events/k8sevent" "github.com/tektoncd/pipeline/pkg/reconciler/taskrun/resources" "github.com/tektoncd/pipeline/pkg/reconciler/volumeclaim" "github.com/tektoncd/pipeline/pkg/remote" @@ -301,7 +300,7 @@ func (c *Reconciler) finishReconcileUpdateEmitEvents(ctx context.Context, tr *v1 _, err := c.updateLabelsAndAnnotations(ctx, tr) if err != nil { logger.Warn("Failed to update TaskRun labels/annotations", zap.Error(err)) - k8sevent.EmitError(controller.GetEventRecorder(ctx), err, tr) + events.EmitError(controller.GetEventRecorder(ctx), err, tr) } merr := multierror.Append(previousError, err).ErrorOrNil()