mirror of
https://github.com/kyverno/policy-reporter.git
synced 2024-12-14 11:57:32 +00:00
release 1.12.2
Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
This commit is contained in:
parent
d844db66fb
commit
fc3358ef7a
5 changed files with 47 additions and 36 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
# 1.12.1
|
# 1.12.2
|
||||||
* Remove CRD registration limitation
|
* Fix CRD registration for PolicyReport and ClusterPolicyReport
|
||||||
|
|
||||||
# 1.12.0
|
# 1.12.0
|
||||||
* Add Yandex as new Target for Policy Reporter
|
* Add Yandex as new Target for Policy Reporter
|
||||||
|
|
6
Makefile
6
Makefile
|
@ -1,7 +1,7 @@
|
||||||
GO ?= go
|
GO ?= go
|
||||||
BUILD ?= build
|
BUILD ?= build
|
||||||
REPO ?= ghcr.io/kyverno/policy-reporter
|
REPO ?= fjogeleit/policy-reporter
|
||||||
IMAGE_TAG ?= 1.10.0
|
IMAGE_TAG ?= 1.10.1
|
||||||
LD_FLAGS="-s -w"
|
LD_FLAGS="-s -w"
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
@ -37,4 +37,4 @@ docker-push:
|
||||||
|
|
||||||
.PHONY: docker-push-dev
|
.PHONY: docker-push-dev
|
||||||
docker-push-dev:
|
docker-push-dev:
|
||||||
@docker buildx build --progress plane --platform linux/arm64,linux/amd64 --tag $(REPO):dev . --build-arg LD_FLAGS=$(LD_FLAGS) --push
|
@docker buildx build --progress plane --platform linux/amd64 --tag $(REPO):dev . --build-arg LD_FLAGS=$(LD_FLAGS) --push
|
||||||
|
|
|
@ -5,8 +5,8 @@ description: |
|
||||||
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
|
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
|
||||||
|
|
||||||
type: application
|
type: application
|
||||||
version: 1.12.1
|
version: 1.12.2
|
||||||
appVersion: 1.10.0
|
appVersion: 1.10.1
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: monitoring
|
- name: monitoring
|
||||||
|
|
|
@ -2,7 +2,7 @@ image:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
repository: kyverno/policy-reporter
|
repository: kyverno/policy-reporter
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
tag: 1.10.0
|
tag: 1.10.1
|
||||||
|
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/kyverno/policy-reporter/pkg/report"
|
"github.com/kyverno/policy-reporter/pkg/report"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -64,44 +63,56 @@ func (k *k8sPolicyReportAdapter) GetFoundResources() map[string]string {
|
||||||
func (k *k8sPolicyReportAdapter) WatchPolicyReports(ctx context.Context) (chan WatchEvent, error) {
|
func (k *k8sPolicyReportAdapter) WatchPolicyReports(ctx context.Context) (chan WatchEvent, error) {
|
||||||
events := make(chan WatchEvent)
|
events := make(chan WatchEvent)
|
||||||
|
|
||||||
resources := []schema.GroupVersionResource{
|
pr := []schema.GroupVersionResource{
|
||||||
policyReportAlphaV1,
|
|
||||||
policyReportAlphaV2,
|
policyReportAlphaV2,
|
||||||
clusterPolicyReportAlphaV1,
|
policyReportAlphaV1,
|
||||||
clusterPolicyReportAlphaV2,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, resource := range resources {
|
cpor := []schema.GroupVersionResource{
|
||||||
go func(r schema.GroupVersionResource) {
|
clusterPolicyReportAlphaV2,
|
||||||
|
clusterPolicyReportAlphaV1,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, versions := range [][]schema.GroupVersionResource{pr, cpor} {
|
||||||
|
go func(vs []schema.GroupVersionResource) {
|
||||||
for {
|
for {
|
||||||
w, err := k.client.Resource(r).Watch(ctx, metav1.ListOptions{})
|
for _, resource := range vs {
|
||||||
if err != nil {
|
k.WatchCRD(ctx, resource, events)
|
||||||
k.mx.Lock()
|
|
||||||
delete(k.found, r.String())
|
|
||||||
k.mx.Unlock()
|
|
||||||
|
|
||||||
time.Sleep(time.Second * 10)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("[INFO] Resource registered: %s\n", r.String())
|
|
||||||
|
|
||||||
k.mx.Lock()
|
|
||||||
k.found[r.String()] = r.String()
|
|
||||||
k.mx.Unlock()
|
|
||||||
|
|
||||||
for result := range w.ResultChan() {
|
|
||||||
if item, ok := result.Object.(*unstructured.Unstructured); ok {
|
|
||||||
preport := k.mapper.MapPolicyReport(item.Object)
|
|
||||||
events <- WatchEvent{preport, result.Type}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(resource)
|
|
||||||
|
}(versions)
|
||||||
}
|
}
|
||||||
|
|
||||||
return events, nil
|
return events, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (k *k8sPolicyReportAdapter) WatchCRD(ctx context.Context, r schema.GroupVersionResource, events chan WatchEvent) {
|
||||||
|
for {
|
||||||
|
w, err := k.client.Resource(r).Watch(ctx, metav1.ListOptions{})
|
||||||
|
if err != nil {
|
||||||
|
k.mx.Lock()
|
||||||
|
delete(k.found, r.String())
|
||||||
|
k.mx.Unlock()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("[INFO] Resource registered: %s\n", r.String())
|
||||||
|
|
||||||
|
k.mx.Lock()
|
||||||
|
k.found[r.String()] = r.String()
|
||||||
|
k.mx.Unlock()
|
||||||
|
|
||||||
|
for result := range w.ResultChan() {
|
||||||
|
if item, ok := result.Object.(*unstructured.Unstructured); ok {
|
||||||
|
preport := k.mapper.MapPolicyReport(item.Object)
|
||||||
|
events <- WatchEvent{preport, result.Type}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewPolicyReportAdapter new Adapter for Policy Report Kubernetes API
|
// NewPolicyReportAdapter new Adapter for Policy Report Kubernetes API
|
||||||
func NewPolicyReportAdapter(dynamic dynamic.Interface, mapper Mapper) PolicyReportAdapter {
|
func NewPolicyReportAdapter(dynamic dynamic.Interface, mapper Mapper) PolicyReportAdapter {
|
||||||
return &k8sPolicyReportAdapter{
|
return &k8sPolicyReportAdapter{
|
||||||
|
|
Loading…
Reference in a new issue