index

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 20 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 {
	Disabled       []string        `json:"disabled"`
	DuplicateDefs  []DuplicateDef  `json:"duplicateDefs"`
	LoadFailures   []LoadFailure   `json:"loadFailures"`
	MissingImports []MissingImport `json:"missingImports"`
	MissingScopes  []MissingScope  `json:"missingScopes"`
}

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 WithRootDir

func WithRootDir(rootDir string) BuildOpt

type DuplicateDef

type DuplicateDef struct {
	File      string `json:"file"`
	OtherFile string `json:"otherFile"`
}

DuplicateDef describes a policy file that has a duplicate.

type Entry

type Entry struct {
	File   string
	Policy policy.Wrapper
}

type Index

type Index interface {
	storage.Instrumented
	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
	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 LoadFailure

type LoadFailure struct {
	Err  error
	File string
}

LoadFailure describes a failure to load a policy.

func (LoadFailure) MarshalJSON

func (lf LoadFailure) MarshalJSON() ([]byte, error)

type MissingImport

type MissingImport struct {
	ImportingFile string `json:"importingFile"`
	Desc          string `json:"desc"`
}

MissingImport describes an import that wasn't found.

type MissingScope added in v0.13.0

type MissingScope string

MissingScope describes a scope that is missing from the policies.

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) 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