util

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendComment

func AppendComment(comment1 string, comment2 string) string

concat two comments

func EvalPolicy

func EvalPolicy(rawFile *[]byte, regoNamespace string, policyPath string) rego.ResultSet

given raw bytes of a YAML file apply Rego query on it return rego result set

func ExecuteMandatoryRule

func ExecuteMandatoryRule(rawFile *[]byte, queryResult rego.ResultSet) *[]byte

given raw byte data of a YAML, decision results returned by OPA append YAML template under specified key and add comments to YAML nodes return raw byte data of a updated YAML

func ExecuteOptionalRule

func ExecuteOptionalRule(rawFile *[]byte, queryResult rego.ResultSet) *[]byte

given raw byte data of a YAML, decision results returned by OPA append comments to YAML nodes return raw byte data of a updated YAML

func ExecuteProhibitedRule

func ExecuteProhibitedRule(rawFile *[]byte, queryResult rego.ResultSet) *[]byte

given raw byte data of a YAML, decision results returned by OPA remove prohibited YAML nodes and append comments to YAML nodes return raw byte data of a updated YAML

func ExecuteRule

func ExecuteRule(rawFile *[]byte, hints []interface{}, handleFunc func(*yaml.Node, map[string]interface{})) *[]byte

given raw byte data of a YAML, rule result set as hints and function to apply rules apply rules to a YAML file return raw byte data of a updated YAML

func ExtractRuleResult

func ExtractRuleResult(queryResult rego.ResultSet, ruleName string) []interface{}

given OPA query result set, extracts the result set from rule execution return extracted result set

func FindElements

func FindElements(yamlNode *yaml.Node, path string) []*yaml.Node

find corresponding YAML Nodes based on a JSONPath query return found Nodes in a YAML Node tree

func NewRegoObject

func NewRegoObject(regoNamespace string, policyPath string) (*rego.PreparedEvalQuery, context.Context)

given rego pacakge name and folder path where policies are located return a Rego query object which is ready for execution

func ParseConfiguration

func ParseConfiguration(rawFile *[]byte) map[string]interface{}

parse raw byte data of a file to Golang variables return sturctured data

func ReadFile

func ReadFile(path string) *[]byte

read a file return raw byte data

func WriteFile

func WriteFile(filename string, data *[]byte)

given filename and raw byte data of a file create a new file

Types

This section is empty.

Jump to

Keyboard shortcuts

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