Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Namespace support to work without cluster scope, fixes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaakin committed Jun 22, 2020
1 parent fee8951 commit 077bb66
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
logLevel: debug
logFormat: json
# namespace: my-namespace-only # Omitting it defaults to all namespaces.
route:
# Main route
routes:
Expand Down
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
logLevel: error
logFormat: json
# namespace: tekton-pipelines
route:
routes:
- match:
- receiver: "dump"
receivers:
- name: "dump"
file:
path: "/tmp/deneme1"
path: "/dev/stdout"
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
}

engine := exporter.NewEngine(&cfg, &exporter.ChannelBasedReceiverRegistry{})
w := kube.NewEventWatcher(kubeconfig, engine.OnEvent)
w := kube.NewEventWatcher(kubeconfig, cfg.Namespace, engine.OnEvent)

ctx, cancel := context.WithCancel(context.Background())
leaderLost := make(chan bool)
Expand Down
1 change: 1 addition & 0 deletions pkg/exporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
// TODO: I am not sure what to do here.
LogLevel string `yaml:"logLevel"`
LogFormat string `yaml:"logFormat"`
Namespace string `yaml:"namespace"`
LeaderElection kube.LeaderElectionConfig `yaml:"leaderElection"`
Route Route `yaml:"route"`
Receivers []sinks.ReceiverConfig `yaml:"receivers"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/kube/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type EventWatcher struct {
fn EventHandler
}

func NewEventWatcher(config *rest.Config, fn EventHandler) *EventWatcher {
func NewEventWatcher(config *rest.Config, namespace string, fn EventHandler) *EventWatcher {
clientset := kubernetes.NewForConfigOrDie(config)
factory := informers.NewSharedInformerFactory(clientset, 0)
factory := informers.NewSharedInformerFactoryWithOptions(clientset, 0, informers.WithNamespace(namespace))
informer := factory.Core().V1().Events().Informer()

watcher := &EventWatcher{
Expand Down

0 comments on commit 077bb66

Please sign in to comment.