Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongxuanzhang committed Dec 1, 2022
1 parent d6a4947 commit 599fec7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/reconciler/customrun/customrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/reconciler/events/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 599fec7

Please sign in to comment.