mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
9102753323
* fix: make alternate reports storage transparent Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * bg scan Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * aggregation Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * aggregation Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * rm manager Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * update Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fixes Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
43 lines
2 KiB
Go
43 lines
2 KiB
Go
package report
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
kyvernov1alpha2 "github.com/kyverno/kyverno/api/kyverno/v1alpha2"
|
|
policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2"
|
|
reportsv1 "github.com/kyverno/kyverno/api/reports/v1"
|
|
"github.com/kyverno/kyverno/pkg/client/clientset/versioned"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
func CreateReport(ctx context.Context, report kyvernov1alpha2.ReportInterface, client versioned.Interface) (kyvernov1alpha2.ReportInterface, error) {
|
|
switch v := report.(type) {
|
|
case *kyvernov1alpha2.AdmissionReport:
|
|
report, err := client.KyvernoV1alpha2().AdmissionReports(report.GetNamespace()).Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *kyvernov1alpha2.ClusterAdmissionReport:
|
|
report, err := client.KyvernoV1alpha2().ClusterAdmissionReports().Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *kyvernov1alpha2.BackgroundScanReport:
|
|
report, err := client.KyvernoV1alpha2().BackgroundScanReports(report.GetNamespace()).Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *kyvernov1alpha2.ClusterBackgroundScanReport:
|
|
report, err := client.KyvernoV1alpha2().ClusterBackgroundScanReports().Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *policyreportv1alpha2.PolicyReport:
|
|
report, err := client.Wgpolicyk8sV1alpha2().PolicyReports(report.GetNamespace()).Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *policyreportv1alpha2.ClusterPolicyReport:
|
|
report, err := client.Wgpolicyk8sV1alpha2().ClusterPolicyReports().Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *reportsv1.EphemeralReport:
|
|
report, err := client.ReportsV1().EphemeralReports(report.GetNamespace()).Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
case *reportsv1.ClusterEphemeralReport:
|
|
report, err := client.ReportsV1().ClusterEphemeralReports().Create(ctx, v, metav1.CreateOptions{})
|
|
return report, err
|
|
default:
|
|
return nil, errors.New("unknow type")
|
|
}
|
|
}
|