buildcel

package
v0.0.0-...-864d242 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package buildcel provides go/cel support for Build proto.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolEval

func BoolEval(b *pb.Build, predicates []string) (bool, error)

BoolEval is a helper function to generate a Bool cel program then evaluate b with it.

func StringMapEval

func StringMapEval(b *pb.Build, fields map[string]string) (map[string]string, error)

StringMapEval is a helper function to generate a StringMap cel program then evaluate b with it.

Types

type Bool

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

Bool is a CEL program to evaluate a Build message against a list of bool expressions.

Currently it can support checking if: * build has a field, e.g. `has(build.tags)`, * input/output properties has a key, e.g. `has(build.input.properties.pro_key)` * an input/output property with key "key" has "value": `string(build.output.properties.key) == "value"`

  • Note: because input/output properties are Struct, we have to cast the value to string.

* experiments includes an experiment, e.g. `build.input.experiments.exists(e, e=="luci.buildbucket.exp")` * tags includes a tag with key "key", and there are two ways:

  • `build.tags.get_value("key")!=""`
  • `build.tags.exists(t, t.key=="key")`

func NewBool

func NewBool(predicates []string) (*Bool, error)

NewBool generates a CEL program to evaluate a Build message against a list of bool expressions (aka `predicates`). The predicates are concatenated with "&&", meaning that the Build needs to match all predicates to pass `Eval`.

func (*Bool) Eval

func (bbc *Bool) Eval(b *pb.Build) (bool, error)

Eval evaluates the given build. If the build matchs all predicates, Eval returns true; Otherwise false.

type StringMap

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

StringMap is a CEL program to return the requested information of a Build message in a string map.

Currently it can support getting values for: * value of any build string field, e.g. `build.summary_markdown` * value of an input/output property, e.g. `string(build.input.properties.key)`

  • Note: because input/output properties are Struct, we have to cast the value to string.

* value of a tag, e.g. `build.tags.get_value("key")`

func NewStringMap

func NewStringMap(strMap map[string]string) (*StringMap, error)

NewStringMap generates a CEL program to evaluate a Build message against a string map. The values of the map can be either a CEL expression for the build which should output a string, like `build.summary_markdown`, or a string literal like `"random string literal"`.

func (*StringMap) Eval

func (smbc *StringMap) Eval(b *pb.Build) (map[string]string, error)

Eval evaluates the build and returns the evaluation result.

Jump to

Keyboard shortcuts

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