-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multinamespace informer filtering
- Loading branch information
Showing
6 changed files
with
182 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package reconciler | ||
|
||
import ( | ||
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" | ||
"knative.dev/pkg/controller" | ||
) | ||
|
||
// PipelineRunInformerFilterFunc returns a filter function | ||
// for PipelineRuns ensuring PipelineRuns are filtered by list of namespaces membership | ||
func PipelineRunInformerFilterFunc(namespaces []string) func(obj interface{}) bool { | ||
return func(obj interface{}) bool { | ||
// Namespace filter | ||
if len(namespaces) == 0 { | ||
return true | ||
} | ||
if pr, ok := obj.(*v1.PipelineRun); ok { | ||
for _, ns := range namespaces { | ||
if pr.Namespace == ns { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
|
||
// TaskRunInformerFilterFunc returns a filter function | ||
// for TaskRuns ensuring TaskRuns are filtered by list of namespaces membership | ||
func TaskRunInformerFilterFunc(namespaces []string) func(obj interface{}) bool { | ||
return func(obj interface{}) bool { | ||
// Namespace filter | ||
if len(namespaces) == 0 { | ||
return true | ||
} | ||
if tr, ok := obj.(*v1.TaskRun); ok { | ||
for _, ns := range namespaces { | ||
if tr.Namespace == ns { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
|
||
// TaskRunInformerFilterFunc returns a filter function | ||
// for TaskRuns ensuring Ownership by a PipelineRun and filtered by list of namespaces membership and | ||
func TaskRunInformerFilterFuncWithOwnership(namespaces []string) func(obj interface{}) bool { | ||
return func(obj interface{}) bool { | ||
// Ownership filter | ||
if !controller.FilterController(&v1.PipelineRun{})(obj) { | ||
return false | ||
} | ||
// Namespace filter | ||
if len(namespaces) == 0 { | ||
return true | ||
} | ||
if tr, ok := obj.(*v1.TaskRun); ok { | ||
for _, ns := range namespaces { | ||
if tr.Namespace == ns { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters