static

package
v0.2.28 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FeatureConstructor   starlark.String = "feature"
	FeatureVariableName  string          = "result"
	DefaultValueAttrName string          = "default"
	DescriptionAttrName  string          = "description"
	RulesAttrName        string          = "rules"
	InputTypeAuto        string          = "auto"
)

Variables

View Source
var (
	ErrUnsupportedStaticParsing = errors.New("unsupported static parsing")
)

Functions

func ExprToProto added in v0.2.23

func ExprToProto(expr build.Expr, f *featurev1beta1.StaticFeature, registry *protoregistry.Types) (proto.Message, error)

Returns (nil, err) if the message is not protobuf.

func NewWalker

func NewWalker(filename string, starBytes []byte, registry *protoregistry.Types) *walker

func ProtoToStatic added in v0.2.23

Given a proto message and the import statement that the type of the message is provided by, constructs a starlark expression defining the proto message.

func ReflectValueToExpr added in v0.2.23

func ReflectValueToExpr(imports []*featurev1beta1.ImportStatement, fieldDesc protoreflect.FieldDescriptor, val *protoreflect.Value, meta *featurev1beta1.StarMeta) (build.Expr, error)

Types

type Walker

type Walker interface {
	Build() (*featurev1beta1.StaticFeature, error)
	// Note: this method will perform mutations based on the V3 ruleslang
	// AST if it exists. If not, it will fall back to the ruleString
	// provided in the feature.
	// Note: static mutation is supported for all lekko types with the following
	// caveat: Any feature that has advanced starlark such as helper functions,
	// list comprehension, etc will fail to be statically parsed at the moment.
	Mutate(f *featurev1beta1.StaticFeature) ([]byte, error)
	// Returns the formatted bytes.
	Format() ([]byte, error)
}

Walker provides methods to statically read and manipulate .star files that hold lekko features.

Jump to

Keyboard shortcuts

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