index

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicatePolicy signals that there are duplicate policy definitions.
	ErrDuplicatePolicy = errors.New("duplicate policy definitions")
	// ErrInvalidEntry signals that the index entry is invalid.
	ErrInvalidEntry = errors.New("invalid index entry")
	// ErrPolicyNotFound signals that the policy does not exist.
	ErrPolicyNotFound = errors.New("policy not found")
)

Functions

This section is empty.

Types

type BuildError

type BuildError struct {
	*runtimev1.IndexBuildErrors
	// contains filtered or unexported fields
}

BuildError is an error type that contains details about the failures encountered during the index build.

func (*BuildError) Error

func (ibe *BuildError) Error() string

type BuildOpt

type BuildOpt func(*buildOptions)

func WithBuildFailureLogLevel added in v0.19.0

func WithBuildFailureLogLevel(level zapcore.Level) BuildOpt

func WithRootDir

func WithRootDir(rootDir string) BuildOpt

func WithSourceAttributes added in v0.33.0

func WithSourceAttributes(attrs ...policy.SourceAttribute) BuildOpt

type Entry

type Entry struct {
	File   string
	Policy policy.Wrapper
}

type Index

type Index interface {
	io.Closer
	storage.Instrumented
	GetFirstMatch([]namer.ModuleID) (*policy.CompilationUnit, error)
	GetCompilationUnits(...namer.ModuleID) (map[namer.ModuleID]*policy.CompilationUnit, error)
	GetDependents(...namer.ModuleID) (map[namer.ModuleID][]namer.ModuleID, error)
	AddOrUpdate(Entry) (storage.Event, error)
	Delete(Entry) (storage.Event, error)
	GetFiles() []string
	GetAllCompilationUnits(context.Context) <-chan *policy.CompilationUnit
	Clear() error
	InspectPolicies(context.Context) (map[string]*responsev1.InspectPoliciesResponse_Result, error)
	ListPolicyIDs(context.Context) ([]string, error)
	ListSchemaIDs(context.Context) ([]string, error)
	LoadSchema(context.Context, string) (io.ReadCloser, error)
	LoadPolicy(context.Context, ...string) ([]*policy.Wrapper, error)
	Reload(ctx context.Context) ([]storage.Event, error)
}

func Build

func Build(ctx context.Context, fsys fs.FS, opts ...BuildOpt) (Index, error)

Build builds an index from the policy files stored in a directory.

type ModuleIDSet added in v0.34.0

type ModuleIDSet map[namer.ModuleID]struct{}

type SchemaLoader added in v0.11.0

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

func NewSchemaLoader added in v0.11.0

func NewSchemaLoader(fsys fs.FS, rootDir string) *SchemaLoader

func (*SchemaLoader) ListIDs added in v0.18.0

func (sl *SchemaLoader) ListIDs(_ context.Context) ([]string, error)

func (*SchemaLoader) Load added in v0.11.0

func (sl *SchemaLoader) Load(_ context.Context, id string) (io.ReadCloser, error)

Jump to

Keyboard shortcuts

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