Documentation
¶
Index ¶
- Variables
- func CheckVariableForPolicy(valuesMap map[string]map[string]Resource, globalValMap map[string]string, ...) (map[string]interface{}, error)
- func GetGitBranchOrPolicyPaths(gitBranch, repoURL string, policyPaths []string) (string, string)
- func GetKindsFromPolicy(policy kyvernov1.PolicyInterface, subresources []Subresource, ...) map[string]struct{}
- func GetKindsFromRule(rule kyvernov1.Rule, client dclient.Interface) (map[schema.GroupVersionKind]bool, map[schema.GroupVersionKind]Subresource)
- func GetPatchedAndGeneratedResource(resourceBytes []byte) (unstructured.Unstructured, error)
- func GetPolicies(paths []string) (policies []kyvernov1.PolicyInterface, errors []error)
- func GetPoliciesFromPaths(fs billy.Filesystem, dirPath []string, isGit bool, policyResourcePath string) (policies []kyvernov1.PolicyInterface, err error)
- func GetResource(resourceBytes []byte) ([]*unstructured.Unstructured, error)
- func GetResourceAccordingToResourcePath(fs billy.Filesystem, resourcePaths []string, cluster bool, ...) (resources []*unstructured.Unstructured, err error)
- func GetResourceFromPath(fs billy.Filesystem, path string, isGit bool, policyResourcePath string, ...) (unstructured.Unstructured, error)
- func GetResources(policies []kyvernov1.PolicyInterface, resourcePaths []string, ...) ([]*unstructured.Unstructured, error)
- func GetResourcesWithTest(fs billy.Filesystem, policies []kyvernov1.PolicyInterface, ...) ([]*unstructured.Unstructured, error)
- func GetUserInfoFromPath(fs billy.Filesystem, path string, isGit bool, policyResourcePath string) (kyvernov1beta1.RequestInfo, store.Subject, error)
- func HasVariables(policy kyvernov1.PolicyInterface) [][]string
- func IsGitSourcePath(policyPaths []string) bool
- func IsInputFromPipe() bool
- func PrintMutatedOutput(mutateLogPath string, mutateLogPathIsDir bool, yaml string, fileName string) error
- func PrintMutatedPolicy(mutatedPolicies []kyvernov1.PolicyInterface) error
- func RemoveDuplicateAndObjectVariables(matches [][]string) string
- func SetInStoreContext(mutatedPolicies []kyvernov1.PolicyInterface, variables map[string]string) map[string]string
- type ApplyPolicyConfig
- type EngineResponseResult
- type Info
- type NamespaceSelector
- type Policy
- type Resource
- type ResultCounts
- type Rule
- type Subresource
- type Values
Constants ¶
This section is empty.
Variables ¶
var IsHTTPRegex = regexp.MustCompile("^(http|https)://")
IsHTTPRegex represents regex for starts with http:// or https://
var RegexVariables = regexp.MustCompile(`\{\{[^{}]*\}\}`)
RegexVariables represents regex for '{{}}'
Functions ¶
func CheckVariableForPolicy ¶
func GetGitBranchOrPolicyPaths ¶ added in v1.9.0
func GetKindsFromPolicy ¶
func GetKindsFromPolicy(policy kyvernov1.PolicyInterface, subresources []Subresource, dClient dclient.Interface) map[string]struct{}
func GetKindsFromRule ¶
func GetKindsFromRule(rule kyvernov1.Rule, client dclient.Interface) (map[schema.GroupVersionKind]bool, map[schema.GroupVersionKind]Subresource)
GetKindsFromRule will return the kinds from policy match block
func GetPatchedAndGeneratedResource ¶ added in v1.8.0
func GetPatchedAndGeneratedResource(resourceBytes []byte) (unstructured.Unstructured, error)
GetPatchedAndGeneratedResource converts raw bytes to unstructured object
func GetPolicies ¶
func GetPolicies(paths []string) (policies []kyvernov1.PolicyInterface, errors []error)
GetPolicies - Extracting the policies from multiple YAML
func GetPoliciesFromPaths ¶
func GetPoliciesFromPaths(fs billy.Filesystem, dirPath []string, isGit bool, policyResourcePath string) (policies []kyvernov1.PolicyInterface, err error)
GetPoliciesFromPaths - get policies according to the resource path
func GetResource ¶
func GetResource(resourceBytes []byte) ([]*unstructured.Unstructured, error)
GetResource converts raw bytes to unstructured object
func GetResourceAccordingToResourcePath ¶
func GetResourceAccordingToResourcePath(fs billy.Filesystem, resourcePaths []string, cluster bool, policies []kyvernov1.PolicyInterface, dClient dclient.Interface, namespace string, policyReport bool, isGit bool, policyResourcePath string, ) (resources []*unstructured.Unstructured, err error)
GetResourceAccordingToResourcePath - get resources according to the resource path
func GetResourceFromPath ¶ added in v1.8.0
func GetResourceFromPath(fs billy.Filesystem, path string, isGit bool, policyResourcePath string, resourceType string) (unstructured.Unstructured, error)
GetResourceFromPath - get patchedResource and generatedResource from given path
func GetResources ¶
func GetResources( policies []kyvernov1.PolicyInterface, resourcePaths []string, dClient dclient.Interface, cluster bool, namespace string, policyReport bool, ) ([]*unstructured.Unstructured, error)
GetResources gets matched resources by the given policies the resources are fetched from - local paths to resources, if given - the k8s cluster, if given
func GetResourcesWithTest ¶
func GetResourcesWithTest(fs billy.Filesystem, policies []kyvernov1.PolicyInterface, resourcePaths []string, isGit bool, policyResourcePath string) ([]*unstructured.Unstructured, error)
GetResourcesWithTest with gets matched resources by the given policies
func GetUserInfoFromPath ¶
func GetUserInfoFromPath(fs billy.Filesystem, path string, isGit bool, policyResourcePath string) (kyvernov1beta1.RequestInfo, store.Subject, error)
GetUserInfoFromPath - get the request info as user info from a given path
func HasVariables ¶
func HasVariables(policy kyvernov1.PolicyInterface) [][]string
HasVariables - check for variables in the policy
func IsGitSourcePath ¶ added in v1.9.0
func IsInputFromPipe ¶
func IsInputFromPipe() bool
IsInputFromPipe - check if input is passed using pipe
func PrintMutatedOutput ¶
func PrintMutatedOutput(mutateLogPath string, mutateLogPathIsDir bool, yaml string, fileName string) error
PrintMutatedOutput - function to print output in provided file or directory
func PrintMutatedPolicy ¶
func PrintMutatedPolicy(mutatedPolicies []kyvernov1.PolicyInterface) error
func RemoveDuplicateAndObjectVariables ¶
RemoveDuplicateAndObjectVariables - remove duplicate variables
func SetInStoreContext ¶
Types ¶
type ApplyPolicyConfig ¶ added in v1.9.0
type ApplyPolicyConfig struct { Policy kyvernov1.PolicyInterface Resource *unstructured.Unstructured MutateLogPath string MutateLogPathIsDir bool Variables map[string]interface{} UserInfo kyvernov1beta1.RequestInfo PolicyReport bool NamespaceSelectorMap map[string]map[string]string Stdin bool Rc *ResultCounts PrintPatchResource bool RuleToCloneSourceResource map[string]string Client dclient.Interface AuditWarn bool Subresources []Subresource }
type EngineResponseResult ¶ added in v1.9.0
type EngineResponseResult struct { Resource response.ResourceSpec Rules []kyvernov1.ViolatedRule }
type Info ¶ added in v1.9.0
type Info struct { PolicyName string Namespace string Results []EngineResponseResult }
Info stores the policy application results for all matched resources Namespace is set to empty "" if resource is cluster wide resource
func ApplyPolicyOnResource ¶
func ApplyPolicyOnResource(c ApplyPolicyConfig) ([]*response.EngineResponse, Info, error)
ApplyPolicyOnResource - function to apply policy on resource
func ProcessValidateEngineResponse ¶
func ProcessValidateEngineResponse(policy kyvernov1.PolicyInterface, validateResponse *response.EngineResponse, resPath string, rc *ResultCounts, policyReport bool, auditWarn bool) Info
type NamespaceSelector ¶
type Subresource ¶ added in v1.9.0
type Subresource struct { APIResource metav1.APIResource `json:"subresource"` ParentResource metav1.APIResource `json:"parentResource"` }
type Values ¶
type Values struct { Policies []Policy `json:"policies"` GlobalValues map[string]string `json:"globalValues"` NamespaceSelectors []NamespaceSelector `json:"namespaceSelector"` Subresources []Subresource `json:"subresources"` }