Documentation ¶
Index ¶
- Constants
- Variables
- func ExprToProto(expr build.Expr, f *featurev1beta1.StaticFeature, ...) (proto.Message, error)
- func NewWalker(filename string, starBytes []byte, registry *protoregistry.Types, ...) *walker
- func ProtoToStatic(imports []*featurev1beta1.ImportStatement, msg protoreflect.Message, ...) (*build.CallExpr, error)
- func ReflectValueToExpr(imports []*featurev1beta1.ImportStatement, ...) (build.Expr, error)
- type Walker
Constants ¶
View Source
const ( FeatureConstructor starlark.String = "feature" ExportConstructor starlark.String = "export" ConfigConstructor starlark.String = "Config" ResultVariableName string = "result" DefaultValueAttrName string = "default" DescriptionAttrName string = "description" MetadataAttrName string = "metadata" // TODO: Fully migrate to overrides over rules RulesAttrName string = "rules" OverridesAttrName string = "overrides" 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, nv feature.NamespaceVersion) *walker
func ProtoToStatic ¶ added in v0.2.23
func ProtoToStatic(imports []*featurev1beta1.ImportStatement, msg protoreflect.Message, meta *featurev1beta1.StarMeta) (*build.CallExpr, error)
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.
Click to show internal directories.
Click to hide internal directories.