library

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Overview

Package library defined CEL compile and program options in an object that can be used as a library in a CEL environment.

Index

Constants

View Source
const (
	Name = "cel.protobom.api"
)

Variables

View Source
var DefaultOptions = Options{
	EnableIO:        false,
	ProtobomVarName: "protobom",
	DocsVarName:     "sboms",
}

Functions

This section is empty.

Types

type OptFunc

type OptFunc func(*Options)

func WithDocsVarName

func WithDocsVarName(name string) OptFunc

func WithEnableIO

func WithEnableIO(w bool) OptFunc

func WithProtobomVarName

func WithProtobomVarName(name string) OptFunc

type Options

type Options struct {
	// EnableIO enables the functions that call to the network or the
	// local filesystem. If false, these functions will not be available
	// in the CEL runtime.
	EnableIO bool

	// ProtobomVarName is the name of the global variable of the protobom
	// object that hosts all the protobom.* functions
	ProtobomVarName string

	// DocsVarName is the name of the variable that holds the loaded SBOMs.
	DocsVarName string
}

Options groups the knobs that can be flicked to control how the library behaves when embedding it into a CEL environment

type Protobom

type Protobom struct {
	Options Options
}

func NewProtobom

func NewProtobom(funcs ...OptFunc) *Protobom

func (*Protobom) CompileOptions

func (p *Protobom) CompileOptions() []cel.EnvOption

CompileOptions creates the CEL execution environment that the runner will use to compile and evaluate programs on the SBOM

func (*Protobom) EnvOption

func (p *Protobom) EnvOption() cel.EnvOption

EnvOption compiles the library and supporting functions into a CEL library that can be added to a CEL environment.

func (*Protobom) Functions

func (p *Protobom) Functions() []cel.EnvOption

Functions returns the compile-time options that define the functions that the protobom library exposes to the cel environment.

func (*Protobom) LibraryName

func (*Protobom) LibraryName() string

LibraryName returns the library name as defined in the Name constant

func (*Protobom) ProgramOptions

func (*Protobom) ProgramOptions() []cel.ProgramOption

ProgramOptions is here to implement the cel library interface, currently none are supported.

func (*Protobom) TypeAdapters

func (*Protobom) TypeAdapters() []cel.EnvOption

TypeAdapters wraps the protobom custom type adapter into an option that can be injected into the CEL environment

func (*Protobom) Types

func (*Protobom) Types() []cel.EnvOption

Types returns the types that the library defines in the CEL environment

func (*Protobom) Variables

func (p *Protobom) Variables() []cel.EnvOption

Variables defines the global variables that are created in the CEL environment when the library is included

Jump to

Keyboard shortcuts

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