common

package
v1.6.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsHTTPRegex = regexp.MustCompile("^(http|https)://")

IsHTTPRegex represents regex for starts with http:// or https://

View Source
var RegexVariables = regexp.MustCompile(`\{\{[^{}]*\}\}`)

RegexVariables represents regex for '{{}}'

Functions

func ApplyPolicyOnResource added in v1.3.2

func ApplyPolicyOnResource(policy *v1.ClusterPolicy, resource *unstructured.Unstructured,
	mutateLogPath string, mutateLogPathIsDir bool, variables map[string]string, policyReport bool,
	namespaceSelectorMap map[string]map[string]string, stdin bool, rc *ResultCounts,
	printPatchResource bool) ([]*response.EngineResponse, policyreport.Info, error)

ApplyPolicyOnResource - function to apply policy on resource

func CheckVariableForPolicy added in v1.4.3

func CheckVariableForPolicy(valuesMap map[string]map[string]Resource, globalValMap map[string]string, policyName string, resourceName string, resourceKind string, variables map[string]string, kindOnwhichPolicyIsApplied map[string]struct{}, variable string) (map[string]string, error)

func GetCRD

func GetCRD(path string) (unstructuredCrds []*unstructured.Unstructured, err error)

GetCRD - Extracts crds from a YAML

func GetCRDs

func GetCRDs(paths []string) (unstructuredCrds []*unstructured.Unstructured, err error)

GetCRDs - Extracting the crds from multiple YAML

func GetKindsFromPolicy added in v1.4.3

func GetKindsFromPolicy(policy *v1.ClusterPolicy) map[string]struct{}

func GetPatchedResource added in v1.5.0

func GetPatchedResource(patchResourceBytes []byte) (patchedResource unstructured.Unstructured, err error)

GetPatchedResource converts raw bytes to unstructured object

func GetPatchedResourceFromPath added in v1.5.0

func GetPatchedResourceFromPath(fs billy.Filesystem, path string, isGit bool, policyResourcePath string) (unstructured.Unstructured, error)

GetPatchedResourceFromPath - get patchedResource from given path

func GetPolicies

func GetPolicies(paths []string) (policies []*v1.ClusterPolicy, errors []error)

GetPolicies - Extracting the policies from multiple YAML

func GetPoliciesFromPaths added in v1.3.2

func GetPoliciesFromPaths(fs billy.Filesystem, dirPath []string, isGit bool, policyResourcePath string) (policies []*v1.ClusterPolicy, err error)

GetPoliciesFromPaths - get policies according to the resource path

func GetResource added in v1.3.0

func GetResource(resourceBytes []byte) ([]*unstructured.Unstructured, error)

GetResource converts raw bytes to unstructured object

func GetResourceAccordingToResourcePath added in v1.3.2

func GetResourceAccordingToResourcePath(fs billy.Filesystem, resourcePaths []string,
	cluster bool, policies []*v1.ClusterPolicy, dClient *client.Client, namespace string, policyReport bool, isGit bool, policyResourcePath string) (resources []*unstructured.Unstructured, err error)

GetResourceAccordingToResourcePath - get resources according to the resource path

func GetResources added in v1.3.0

func GetResources(policies []*v1.ClusterPolicy, resourcePaths []string, dClient *client.Client, 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 added in v1.3.2

func GetResourcesWithTest(fs billy.Filesystem, policies []*v1.ClusterPolicy, resourcePaths []string, isGit bool, policyResourcePath string) ([]*unstructured.Unstructured, error)

GetResourcesWithTest with gets matched resources by the given policies

func GetVariable added in v1.3.2

func GetVariable(variablesString, valuesFile string, fs billy.Filesystem, isGit bool, policyResourcePath string) (map[string]string, map[string]string, map[string]map[string]Resource, map[string]map[string]string, error)

func HasVariables added in v1.5.2

func HasVariables(policy *v1.ClusterPolicy) [][]string

HasVariables - check for variables in the policy

func IsInputFromPipe

func IsInputFromPipe() bool

IsInputFromPipe - check if input is passed using pipe

func MutatePolices added in v1.3.2

func MutatePolices(policies []*v1.ClusterPolicy) ([]*v1.ClusterPolicy, error)

MutatePolices - function to apply mutation on policies

func MutatePolicy

func MutatePolicy(policy *v1.ClusterPolicy, logger logr.Logger) (*v1.ClusterPolicy, error)

MutatePolicy - applies mutation to a policy

func PrintMutatedOutput added in v1.3.2

func PrintMutatedOutput(mutateLogPath string, mutateLogPathIsDir bool, yaml string, fileName string) error

PrintMutatedOutput - function to print output in provided file or directory

func PrintMutatedPolicy added in v1.4.3

func PrintMutatedPolicy(mutatedPolicies []*v1.ClusterPolicy) error

func ProcessValidateEngineResponse added in v1.4.3

func ProcessValidateEngineResponse(policy *v1.ClusterPolicy, validateResponse *response.EngineResponse, resPath string, rc *ResultCounts, policyReport bool) policyreport.Info

func RemoveDuplicateAndObjectVariables added in v1.4.2

func RemoveDuplicateAndObjectVariables(matches [][]string) string

RemoveDuplicateAndObjectVariables - remove duplicate variables

func SetInStoreContext added in v1.4.3

func SetInStoreContext(mutatedPolicies []*v1.ClusterPolicy, variables map[string]string) map[string]string

Types

type NamespaceSelector added in v1.3.5

type NamespaceSelector struct {
	Name   string            `json:"name"`
	Labels map[string]string `json:"labels"`
}

type Policy added in v1.3.2

type Policy struct {
	Name      string     `json:"name"`
	Resources []Resource `json:"resources"`
	Rules     []Rule     `json:"rules"`
}

type Resource added in v1.3.2

type Resource struct {
	Name   string            `json:"name"`
	Values map[string]string `json:"values"`
}

type ResultCounts added in v1.4.3

type ResultCounts struct {
	Pass  int
	Fail  int
	Warn  int
	Error int
	Skip  int
}

type Rule added in v1.3.6

type Rule struct {
	Name   string            `json:"name"`
	Values map[string]string `json:"values"`
}

type Values added in v1.3.2

type Values struct {
	Policies           []Policy            `json:"policies"`
	GlobalValues       map[string]string   `json:"globalValues"`
	NamespaceSelectors []NamespaceSelector `json:"namespaceSelector"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL