1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

policy report yaml added

This commit is contained in:
evalsocket 2020-09-15 08:07:01 -07:00
parent 68855c2ca9
commit 573496f318
6 changed files with 1911 additions and 444 deletions

View file

@ -32,6 +32,7 @@ const (
validatingWebhookConfigKind string = "ValidatingWebhookConfiguration"
)
func main() {
klog.InitFlags(nil)
log.SetLogger(klogr.New())

File diff suppressed because it is too large Load diff

565
go.sum

File diff suppressed because it is too large Load diff

View file

@ -207,7 +207,7 @@ func (j *Job) syncHandler(info JobInfo) error {
if info.JobType == "POLICYSYNC" {
wg.Add(1)
go j.syncKyverno(&wg, "All", "SYNC", info.JobData)
} else if info.JobType == "CONFIGMAP" {
}else if info.JobType == "CONFIGMAP" {
if info.JobData != "" {
str := strings.Split(info.JobData, ",")
wg.Add(len(str))

View file

@ -15,7 +15,7 @@ import (
func AllReportsCommand() *cobra.Command {
kubernetesConfig := genericclioptions.NewConfigFlags(true)
var namespace, policy string
var mode,namespace, policy string
cmd := &cobra.Command{
Use: "all",
Short: "generate report",
@ -34,29 +34,32 @@ func AllReportsCommand() *cobra.Command {
log.Log.Error(err, "Failed to create kubernetes client")
os.Exit(1)
}
var stopCh <-chan struct{}
var wg sync.WaitGroup
if namespace != "" {
wg.Add(1)
go backgroundScan(namespace, All, policy, &wg, restConfig, logger)
wg.Wait()
} else {
ns, err := kubeClient.CoreV1().Namespaces().List(metav1.ListOptions{})
if err != nil {
os.Exit(1)
}
wg.Add(len(ns.Items))
for _, n := range ns.Items {
go backgroundScan(n.GetName(), All, policy, &wg, restConfig, logger)
if mode == "cli" {
var wg sync.WaitGroup
if namespace != "" {
wg.Add(1)
go backgroundScan(namespace, All, policy, &wg, restConfig, logger)
} else {
ns, err := kubeClient.CoreV1().Namespaces().List(metav1.ListOptions{})
if err != nil {
os.Exit(1)
}
wg.Add(len(ns.Items))
for _, n := range ns.Items {
go backgroundScan(n.GetName(), All, policy, &wg, restConfig, logger)
}
}
wg.Wait()
os.Exit(0)
}else{
log.Log.Error(nil, "mode is not supported","mode",mode)
os.Exit(1)
}
os.Exit(0)
<-stopCh
return nil
},
}
cmd.Flags().StringVarP(&namespace, "namespace", "n", "", "define specific namespace")
cmd.Flags().StringVarP(&policy, "policy", "p", "", "define specific policy")
cmd.Flags().StringVarP(&mode, "mode", "m", "cli", "mode")
return cmd
}

View file

@ -38,7 +38,7 @@ import (
)
const (
Helm string = "Helm"
Helm string = "App"
Namespace string = "Namespace"
Cluster string = "Cluster"
All string = "All"