Skip to content

Commit caaae67

Browse files
fraenkeltekton-robot
authored andcommitted
Allow controller to watch a specified namespace
Add a command line option to optionally watch a specific namespace. The default is to watch all namespaces.
1 parent 6ff5e84 commit caaae67

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/controller/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import (
2222
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
2323
"github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun"
2424
"github.com/tektoncd/pipeline/pkg/reconciler/taskrun"
25+
corev1 "k8s.io/api/core/v1"
26+
"knative.dev/pkg/injection"
2527
"knative.dev/pkg/injection/sharedmain"
28+
"knative.dev/pkg/signals"
2629
)
2730

2831
const (
@@ -49,6 +52,7 @@ var (
4952
"The container image containing our PR binary.")
5053
imageDigestExporterImage = flag.String("imagedigest-exporter-image", "override-with-imagedigest-exporter-image:latest",
5154
"The container image containing our image digest exporter binary.")
55+
namespace = flag.String("namespace", corev1.NamespaceAll, "Namespace to restrict informer to. Optional, defaults to all namespaces.")
5256
)
5357

5458
func main() {
@@ -65,7 +69,7 @@ func main() {
6569
PRImage: *prImage,
6670
ImageDigestExporterImage: *imageDigestExporterImage,
6771
}
68-
sharedmain.Main(ControllerLogKey,
72+
sharedmain.MainWithContext(injection.WithNamespaceScope(signals.NewContext(), *namespace), ControllerLogKey,
6973
taskrun.NewController(images),
7074
pipelinerun.NewController(images),
7175
)

0 commit comments

Comments
 (0)