engine

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPolicyNotExecutable = errors.New("policy not executable")

Functions

This section is empty.

Types

type CheckOpt added in v0.9.0

type CheckOpt func(*checkOptions)

CheckOpt defines options for engine Check calls.

func WithNowFunc added in v0.20.0

func WithNowFunc(nowFunc func() time.Time) CheckOpt

WithNowFunc sets the function for determining `now` during condition evaluation.

func WithTraceSink added in v0.15.0

func WithTraceSink(tracerSink tracer.Sink) CheckOpt

func WithZapTraceSink added in v0.9.0

func WithZapTraceSink(log *zap.Logger) CheckOpt

WithZapTraceSink sets an engine tracer with Zap set as the sink.

type Components added in v0.11.0

type Components struct {
	AuditLog     audit.Log
	PolicyLoader PolicyLoader
	SchemaMgr    schema.Manager
}

type Conf

type Conf struct {
	// DefaultPolicyVersion defines what version to assume if the request does not specify one.
	DefaultPolicyVersion string `yaml:"defaultPolicyVersion" conf:",example=\"default\""`
	NumWorkers           uint   `yaml:"numWorkers" conf:",ignore"`
}

Conf is optional configuration for engine.

func GetConf added in v0.15.0

func GetConf() (*Conf, error)

func (*Conf) Key

func (c *Conf) Key() string

func (*Conf) SetDefaults

func (c *Conf) SetDefaults()

func (*Conf) Validate

func (c *Conf) Validate() error

type EffectInfo added in v0.13.0

type EffectInfo struct {
	Policy string
	Scope  string
	Effect effectv1.Effect
}

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, components Components) (*Engine, error)

func NewEphemeral

func NewEphemeral(policyLoader PolicyLoader, schemaMgr schema.Manager) (*Engine, error)

func NewFromConf added in v0.15.0

func NewFromConf(ctx context.Context, conf *Conf, components Components) *Engine

func (*Engine) Check

func (engine *Engine) Check(ctx context.Context, inputs []*enginev1.CheckInput, opts ...CheckOpt) ([]*enginev1.CheckOutput, error)

func (*Engine) PlanResources added in v0.16.0

func (engine *Engine) PlanResources(ctx context.Context, input *enginev1.PlanResourcesInput) (*enginev1.PlanResourcesOutput, error)

type Evaluator added in v0.9.0

type Evaluator interface {
	Evaluate(context.Context, tracer.Context, *enginev1.CheckInput) (*PolicyEvalResult, error)
}

func NewEvaluator added in v0.9.0

func NewEvaluator(rps *runtimev1.RunnablePolicySet, schemaMgr schema.Manager, eparams evalParams) Evaluator

type PolicyEvalResult added in v0.12.0

type PolicyEvalResult struct {
	Effects               map[string]EffectInfo
	EffectiveDerivedRoles map[string]struct{}

	ValidationErrors []*schemav1.ValidationError
	// contains filtered or unexported fields
}

type PolicyLoader added in v0.20.0

type PolicyLoader interface {
	GetPolicySet(context.Context, namer.ModuleID) (*runtimev1.RunnablePolicySet, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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