mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
6e1def1004
* feat: remove v1alpha2 group Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * codegen Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix tests Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package report
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
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 reportsv1.ReportInterface, client versioned.Interface) (reportsv1.ReportInterface, error) {
|
|
switch v := report.(type) {
|
|
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")
|
|
}
|
|
}
|