opavalidation

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package opavalidation validates OPA policies for Insights.

Index

Constants

View Source
const (
	DefaultKubeObjectNamespace = "notset" // The namespace to use if one is unspecified
)

Variables

This section is empty.

Functions

func FindFilesWithExtension

func FindFilesWithExtension(dir, ext string) ([]string, error)

FindFilesWithExtension returns a slice of filenames from the given dir, that have the given extension.

func HumanizeMapOutput

func HumanizeMapOutput(m map[string]error, keyNoun string) string

HumanizeMapOutput returns a Humanized string listing a maps keys with its error values in parenthesis. The supplied keyNoun will be pluralized if there are more than one key in the map.

func HumanizeStringsOutput

func HumanizeStringsOutput(s []string, noun string) string

HumanizeStringsOutput returns a humanized string listing the slice of strings.

func Run

func Run(regoFileName, objectFileName string, insightsInfo fwrego.InsightsInfo, objectNamespaceOverride string) (actionItems, error)

Run is a ValidateRego() wrapper that validates and prints resulting actionItems. This is meant to be called from a cobra.Command{}.

func RunBatch

func RunBatch(batchDir string, insightsInfo fwrego.InsightsInfo, objectNamespaceOverride string) (successfulPolicies, failedPolicies []string, err error)

RunBatch is a Run() wrapper that processes multiple OPA policies. It does not return the actionItems from each call to Run(), as there would not be correlation of actionItems to their OPA policy. This is meant to be called from a cobra.Command{}.

func ValidateRego

func ValidateRego(ctx context.Context, regoAsString string, objectAsBytes []byte, insightsInfo fwrego.InsightsInfo, eventType string, objectNamespaceOverride string) (actionItems, error)

ValidateRego validates rego by executing rego with an input object. Validation includes signatures for Insights-provided rego functions.

Types

This section is empty.

Jump to

Keyboard shortcuts

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