diff --git a/pkg/broadcaster/broadcaster.go b/pkg/broadcaster/broadcaster.go index 622af9740..1ae2e7142 100644 --- a/pkg/broadcaster/broadcaster.go +++ b/pkg/broadcaster/broadcaster.go @@ -56,9 +56,15 @@ const ( ServiceAccountCreated MessageType = "ServiceAccountCreated" ServiceAccountDeleted MessageType = "ServiceAccountDeleted" ServiceAccountUpdated MessageType = "ServiceAccountUpdated" + TriggerCreated MessageType = "TriggerCreated" + TriggerDeleted MessageType = "TriggerDeleted" + TriggerUpdated MessageType = "TriggerUpdated" TriggerBindingCreated MessageType = "TriggerBindingCreated" TriggerBindingDeleted MessageType = "TriggerBindingDeleted" TriggerBindingUpdated MessageType = "TriggerBindingUpdated" + ClusterInterceptorCreated MessageType = "ClusterInterceptorCreated" + ClusterInterceptorDeleted MessageType = "ClusterInterceptorDeleted" + ClusterInterceptorUpdated MessageType = "ClusterInterceptorUpdated" ClusterTriggerBindingCreated MessageType = "ClusterTriggerBindingCreated" ClusterTriggerBindingDeleted MessageType = "ClusterTriggerBindingDeleted" ClusterTriggerBindingUpdated MessageType = "ClusterTriggerBindingUpdated" diff --git a/pkg/controllers/controller.go b/pkg/controllers/controller.go index 6c6924608..50f6dd122 100644 --- a/pkg/controllers/controller.go +++ b/pkg/controllers/controller.go @@ -73,7 +73,9 @@ func StartTriggersControllers(clientset dynamic.Interface, resyncDur time.Durati clusterInformerFactory := dynamicinformer.NewDynamicSharedInformerFactory(clientset, resyncDur) tenantInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(clientset, resyncDur, tenantNamespace, nil) + triggerscontroller.NewClusterInterceptorController(clusterInformerFactory) triggerscontroller.NewClusterTriggerBindingController(clusterInformerFactory) + triggerscontroller.NewTriggerController(tenantInformerFactory) triggerscontroller.NewTriggerBindingController(tenantInformerFactory) triggerscontroller.NewTriggerTemplateController(tenantInformerFactory) triggerscontroller.NewEventListenerController(tenantInformerFactory) diff --git a/pkg/controllers/triggers/clusterInterceptor.go b/pkg/controllers/triggers/clusterInterceptor.go new file mode 100644 index 000000000..4558c2bb5 --- /dev/null +++ b/pkg/controllers/triggers/clusterInterceptor.go @@ -0,0 +1,41 @@ +/* +Copyright 2021 The Tekton Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package triggers + +import ( + "github.com/tektoncd/dashboard/pkg/broadcaster" + "github.com/tektoncd/dashboard/pkg/controllers/utils" + logging "github.com/tektoncd/dashboard/pkg/logging" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic/dynamicinformer" +) + +func NewClusterInterceptorController(sharedInformerFactory dynamicinformer.DynamicSharedInformerFactory) { + logging.Log.Debug("In NewClusterInterceptorController") + + gvr := schema.GroupVersionResource{ + Group: "triggers.tekton.dev", + Version: "v1alpha1", + Resource: "clusterinterceptors", + } + + utils.NewController( + "ClusterInterceptor", + sharedInformerFactory.ForResource(gvr).Informer(), + broadcaster.ClusterInterceptorCreated, + broadcaster.ClusterInterceptorUpdated, + broadcaster.ClusterInterceptorDeleted, + nil, + ) +} diff --git a/pkg/controllers/triggers/trigger.go b/pkg/controllers/triggers/trigger.go new file mode 100644 index 000000000..62dfb613b --- /dev/null +++ b/pkg/controllers/triggers/trigger.go @@ -0,0 +1,41 @@ +/* +Copyright 2021 The Tekton Authors +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package triggers + +import ( + "github.com/tektoncd/dashboard/pkg/broadcaster" + "github.com/tektoncd/dashboard/pkg/controllers/utils" + logging "github.com/tektoncd/dashboard/pkg/logging" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic/dynamicinformer" +) + +func NewTriggerController(sharedInformerFactory dynamicinformer.DynamicSharedInformerFactory) { + logging.Log.Debug("In NewTriggerController") + + gvr := schema.GroupVersionResource{ + Group: "triggers.tekton.dev", + Version: "v1alpha1", + Resource: "triggers", + } + + utils.NewController( + "Trigger", + sharedInformerFactory.ForResource(gvr).Informer(), + broadcaster.TriggerCreated, + broadcaster.TriggerUpdated, + broadcaster.TriggerDeleted, + nil, + ) +}