shared

package
v0.0.0-...-476792b Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AllOf = "allof"
View Source
const AnyOf = "anyof"
View Source
const Audit = "audit"
View Source
const Count = "count"
View Source
const Deny = "deny"
View Source
const DeployIfNotExists = "deployifnotexists"
View Source
const Disabled = "disabled"
View Source
const Field = "field"
View Source
const IfCondition = "if"
View Source
const KindOfResource = "kind"
View Source
const Modify = "modify"
View Source
const Not = "not"
View Source
const RegexExp = "regex.match"
View Source
const RegoTestTemplate = `package main

import rego.v1

default allow := false
allow if { 
  %s
}`
View Source
const ResourcePathPrefix = "r.values"
View Source
const TypeOfResource = "type"
View Source
const UtilsRego = `` /* 3036-byte string literal not displayed */
View Source
const Value = "value"
View Source
const VarInCountWhere = "[VAR_IN_COUNT_WHERE]"
View Source
const Warn = "warn"
View Source
const Where = "where"

Variables

This section is empty.

Functions

func AssertRego

func AssertRego(t *testing.T, query, cfg string, input map[string]any, expected bool, ctx *Context)

func AssertRegoAllow

func AssertRegoAllow(t *testing.T, cfg string, input map[string]any, allowed bool, ctx *Context)

func ConvertAzurePathToObjectPath

func ConvertAzurePathToObjectPath(prop string, ctx *Context) string

func EvaluateFunctionCall

func EvaluateFunctionCall(call *FunctionCall, c *Context) (any, error)

EvaluateFunctionCall handles different function evaluations based on function name

func EvaluateRego

func EvaluateRego(t *testing.T, query, cfg string, input map[string]any, ctx *Context) any

func FieldNameParser

func FieldNameParser(fieldNameRaw string, ctx *Context) string

func FieldNameProcessor

func FieldNameProcessor(fieldName string, ctx *Context) (string, error)

func HumanFriendlyEnglishString

func HumanFriendlyEnglishString(length int) string

func HumanFriendlyString

func HumanFriendlyString(length int) string

func ResolveParameterValue

func ResolveParameterValue[T any](input any, c *Context) (T, error)

func ResolveParameterValueAsString

func ResolveParameterValueAsString(input any, c *Context) (string, error)

func SliceConstructor

func SliceConstructor(input any) string

func WithUtilFunctions

func WithUtilFunctions(exp string) string

Types

type Context

type Context struct {
	context.Context

	GetParameterFunc func(string) (any, bool, error)
	// contains filtered or unexported fields
}

func NewContext

func NewContext() *Context

func NewContextWithOptions

func NewContextWithOptions(option Options) *Context

func (*Context) CurrentCountFieldName

func (c *Context) CurrentCountFieldName() string

func (*Context) EnqueueHelperFunction

func (c *Context) EnqueueHelperFunction(funcDec string)

func (*Context) EnterCountRego

func (c *Context) EnterCountRego(name string)

func (*Context) ExitCountRego

func (c *Context) ExitCountRego()

func (*Context) Fork

func (c *Context) Fork() *Context

func (*Context) GenerateRuleName

func (c *Context) GenerateRuleName() bool

func (*Context) HelperFunctionsRego

func (c *Context) HelperFunctionsRego() string

func (*Context) InHelperFunction

func (c *Context) InHelperFunction(parameterName string, action func() error) error

func (*Context) IsInCountRego

func (c *Context) IsInCountRego() bool

func (*Context) PackageName

func (c *Context) PackageName() string

func (*Context) PopVarNameForField

func (c *Context) PopVarNameForField()

func (*Context) PushResourceType

func (c *Context) PushResourceType(rt string)

func (*Context) PushVarNameForField

func (c *Context) PushVarNameForField(name string)

func (*Context) UtilLibraryPackageName

func (c *Context) UtilLibraryPackageName() string

func (*Context) UtilRegoFileName

func (c *Context) UtilRegoFileName() string

func (*Context) VarNameForField

func (c *Context) VarNameForField() (string, bool)

type FunctionCall

type FunctionCall struct {
	Name       string
	Parameters []any
	// contains filtered or unexported fields
}

func ParseFunctionCall

func ParseFunctionCall(str string) (*FunctionCall, bool)

ParseFunctionCall extracts function name and parameters from a string if it's a function call

type Options

type Options struct {
	PackageName            string
	UtilLibraryPackageName string
	UtilRegoFileName       string
	GenerateRuleName       bool
}

type Rego

type Rego interface {
	Rego(ctx *Context) (string, error)
}

type StringRego

type StringRego string

func (StringRego) Rego

func (s StringRego) Rego(ctx *Context) (string, error)

Jump to

Keyboard shortcuts

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