Skip to content

Commit

Permalink
Rerun ConfigMap Watch after stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Jogeleit committed Feb 22, 2021
1 parent 9eb5337 commit 24d07e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions charts/policy-reporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: policy-reporter
description: K8s PolicyReporter watches for wgpolicyk8s.io/v1alpha1.PolicyReport resources. It creates Prometheus Metrics and can send rule validation events to Loki

type: application
version: 0.5.1
appVersion: 0.4.1
version: 0.5.2
appVersion: 0.4.2
2 changes: 1 addition & 1 deletion charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ metrics:
image:
repository: fjogeleit/policy-reporter
pullPolicy: IfNotPresent
tag: 0.4.1
tag: 0.4.2

imagePullSecrets: []

Expand Down
18 changes: 9 additions & 9 deletions pkg/kubernetes/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ func (c coreClient) GetConfig(ctx context.Context, name string) (*apiv1.ConfigMa
}

func (c coreClient) WatchConfigs(ctx context.Context, cb ConfigMapCallback) error {
watch, err := c.cmClient.Watch(ctx, metav1.ListOptions{})
if err != nil {
return err
}
for {
watch, err := c.cmClient.Watch(ctx, metav1.ListOptions{})
if err != nil {
return err
}

for event := range watch.ResultChan() {
if cm, ok := event.Object.(*apiv1.ConfigMap); ok {
cb(event.Type, cm)
for event := range watch.ResultChan() {
if cm, ok := event.Object.(*apiv1.ConfigMap); ok {
cb(event.Type, cm)
}
}
}

return nil
}

func NewCoreClient(kubeconfig, namespace string) (CoreClient, error) {
Expand Down
4 changes: 0 additions & 4 deletions pkg/kubernetes/report_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ func (c *policyReportClient) WatchClusterPolicyReports(cb report.WatchClusterPol
cb(result.Type, c.mapClusterPolicyReport(item.Object))
}
}

log.Println("[WARNING] WatchClusterPolicyReports Stops")
}
}

Expand All @@ -83,8 +81,6 @@ func (c *policyReportClient) WatchPolicyReports(cb report.WatchPolicyReportCallb
cb(result.Type, c.mapPolicyReport(item.Object))
}
}

log.Println("[WARNING] WatchPolicyReports Stops")
}
}

Expand Down

0 comments on commit 24d07e2

Please sign in to comment.