diff --git a/pkg/apis/pipeline/constants.go b/pkg/apis/pipeline/constants.go index 9769ef13d7a..3b4cf62425e 100644 --- a/pkg/apis/pipeline/constants.go +++ b/pkg/apis/pipeline/constants.go @@ -17,6 +17,12 @@ limitations under the License. package pipeline const ( + // PipelineRunControllerName holds the name of the PipelineRun controller + // nolint: golint + PipelineRunControllerName = "PipelineRun" + + // TaskRunControllerName holds the name of the PipelineRun controller + TaskRunControllerName = "TaskRun" // PipelineResourceTypeGit indicates that this source is a GitHub repo. ArtifactStorageBucketType = "bucket" diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go index 1e0853c1115..143b1f04282 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go @@ -21,7 +21,7 @@ import ( "time" "github.com/tektoncd/pipeline/pkg/apis/config" - + "github.com/tektoncd/pipeline/pkg/apis/pipeline" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,11 +30,10 @@ import ( ) var ( - pipelineRunControllerName = "PipelineRun" - groupVersionKind = schema.GroupVersionKind{ + groupVersionKind = schema.GroupVersionKind{ Group: SchemeGroupVersion.Group, Version: SchemeGroupVersion.Version, - Kind: pipelineRunControllerName, + Kind: pipeline.PipelineRunControllerName, } ) @@ -238,7 +237,7 @@ func (pr *PipelineRun) IsCancelled() bool { // GetRunKey return the pipelinerun key for timeout handler map func (pr *PipelineRun) GetRunKey() string { // The address of the pointer is a threadsafe unique identifier for the pipelinerun - return fmt.Sprintf("%s/%p", pipelineRunControllerName, pr) + return fmt.Sprintf("%s/%p", pipeline.PipelineRunControllerName, pr) } // IsTimedOut returns true if a pipelinerun has exceeded its spec.Timeout based on its status.Timeout diff --git a/pkg/apis/pipeline/v1alpha1/taskrun_types.go b/pkg/apis/pipeline/v1alpha1/taskrun_types.go index 1a676a7cbaf..99991dcef85 100644 --- a/pkg/apis/pipeline/v1alpha1/taskrun_types.go +++ b/pkg/apis/pipeline/v1alpha1/taskrun_types.go @@ -243,7 +243,7 @@ func (tr *TaskRun) GetPipelineRunPVCName() string { return "" } for _, ref := range tr.GetOwnerReferences() { - if ref.Kind == pipelineRunControllerName { + if ref.Kind == pipeline.PipelineRunControllerName { return fmt.Sprintf("%s-pvc", ref.Name) } } @@ -254,7 +254,7 @@ func (tr *TaskRun) GetPipelineRunPVCName() string { // owner reference of type PipelineRun func (tr *TaskRun) HasPipelineRunOwnerReference() bool { for _, ref := range tr.GetOwnerReferences() { - if ref.Kind == pipelineRunControllerName { + if ref.Kind == pipeline.PipelineRunControllerName { return true } } diff --git a/pkg/reconciler/pipelinerun/controller.go b/pkg/reconciler/pipelinerun/controller.go index 93c5fdcc594..cb6cc49eb20 100644 --- a/pkg/reconciler/pipelinerun/controller.go +++ b/pkg/reconciler/pipelinerun/controller.go @@ -81,7 +81,7 @@ func NewController(images pipeline.Images) func(context.Context, configmap.Watch timeoutHandler: timeoutHandler, metrics: metrics, } - impl := controller.NewImpl(c, c.Logger, pipelineRunControllerName) + impl := controller.NewImpl(c, c.Logger, pipeline.PipelineRunControllerName) timeoutHandler.SetPipelineRunCallbackFunc(impl.Enqueue) timeoutHandler.CheckTimeouts(kubeclientset, pipelineclientset) diff --git a/pkg/reconciler/pipelinerun/pipelinerun.go b/pkg/reconciler/pipelinerun/pipelinerun.go index 3c1ce9b2424..fcc8cafd25c 100644 --- a/pkg/reconciler/pipelinerun/pipelinerun.go +++ b/pkg/reconciler/pipelinerun/pipelinerun.go @@ -74,8 +74,6 @@ const ( ReasonInvalidGraph = "PipelineInvalidGraph" // pipelineRunAgentName defines logging agent name for PipelineRun Controller pipelineRunAgentName = "pipeline-controller" - // pipelineRunControllerName defines name for PipelineRun Controller - pipelineRunControllerName = "PipelineRun" // Event reasons eventReasonFailed = "PipelineRunFailed" diff --git a/pkg/reconciler/taskrun/controller.go b/pkg/reconciler/taskrun/controller.go index b4594732d94..d4e643faef8 100644 --- a/pkg/reconciler/taskrun/controller.go +++ b/pkg/reconciler/taskrun/controller.go @@ -83,7 +83,7 @@ func NewController(images pipeline.Images) func(context.Context, configmap.Watch metrics: metrics, entrypointCache: entrypointCache, } - impl := controller.NewImpl(c, c.Logger, taskRunControllerName) + impl := controller.NewImpl(c, c.Logger, pipeline.TaskRunControllerName) timeoutHandler.SetTaskRunCallbackFunc(impl.Enqueue) timeoutHandler.CheckTimeouts(kubeclientset, pipelineclientset) diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 244cae9a99c..a5a3867bba2 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -48,11 +48,6 @@ import ( const ( // taskRunAgentName defines logging agent name for TaskRun Controller taskRunAgentName = "taskrun-controller" - // taskRunControllerName defines name for TaskRun Controller - taskRunControllerName = "TaskRun" - - // imageDigestExporterContainerName defines the name of the container that will collect the - // built images digest ) // Reconciler implements controller.Reconciler for Configuration resources.