1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

updated readme

This commit is contained in:
NoSkillGirl 2020-08-31 19:32:00 +05:30
parent ccfd4adad3
commit d9c3a166cc
3 changed files with 11 additions and 2 deletions

View file

@ -61,6 +61,12 @@ Example:
kyverno validate /path/to/policy1.yaml /path/to/policy2.yaml /path/to/folderFullOfPolicies -o yaml kyverno validate /path/to/policy1.yaml /path/to/policy2.yaml /path/to/folderFullOfPolicies -o yaml
``` ```
Policy can also be validated with CRDs. Use -c flag to pass the CRD, can pass multiple CRD files or even an entire folder containin CRDs.
Example:
```
kyverno validate /path/to/policy1.yaml -c /path/to/crd.yaml -c /path/to/folderFullOfCRDs
```
#### Apply #### Apply
Applies policies on resources, and supports applying multiple policies on multiple resources in a single command. Applies policies on resources, and supports applying multiple policies on multiple resources in a single command.

View file

@ -7,13 +7,14 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
yaml_v2 "sigs.k8s.io/yaml"
"strings" "strings"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
yaml_v2 "sigs.k8s.io/yaml"
jsonpatch "github.com/evanphx/json-patch" jsonpatch "github.com/evanphx/json-patch"
"github.com/go-logr/logr" "github.com/go-logr/logr"
v1 "github.com/nirmata/kyverno/pkg/api/kyverno/v1" v1 "github.com/nirmata/kyverno/pkg/api/kyverno/v1"
@ -249,6 +250,7 @@ func GetCRDs(paths []string) (unstructuredCrds []*unstructured.Unstructured, err
getCRDs, err := GetCRD(path) getCRDs, err := GetCRD(path)
if err != nil { if err != nil {
fmt.Printf("failed to extract crds: %s\n", err) fmt.Printf("failed to extract crds: %s\n", err)
os.Exit(2)
} }
unstructuredCrds = append(unstructuredCrds, getCRDs...) unstructuredCrds = append(unstructuredCrds, getCRDs...)
} }

View file

@ -56,6 +56,7 @@ func Command() *cobra.Command {
if err != nil { if err != nil {
log.Error(err, "crd is invalid", "file", crdPaths) log.Error(err, "crd is invalid", "file", crdPaths)
os.Exit(1)
} }
for _, crd := range crds { for _, crd := range crds {
openAPIController.ParseCRD(*crd) openAPIController.ParseCRD(*crd)