AsCELVariable converts the serializable form of the Variable into a CEL environment declaration.
(tp types.Provider)
| 303 | |
| 304 | // AsCELVariable converts the serializable form of the Variable into a CEL environment declaration. |
| 305 | func (v *Variable) AsCELVariable(tp types.Provider) (*decls.VariableDecl, error) { |
| 306 | if err := v.Validate(); err != nil { |
| 307 | return nil, err |
| 308 | } |
| 309 | t, err := v.GetType().AsCELType(tp) |
| 310 | if err != nil { |
| 311 | return nil, fmt.Errorf("invalid variable %q: %w", v.Name, err) |
| 312 | } |
| 313 | return decls.NewVariableWithDoc(v.Name, t, v.Description), nil |
| 314 | } |
| 315 | |
| 316 | // NewContextVariable returns a serializable context variable with a specific type name. |
| 317 | func NewContextVariable(typeName string) *ContextVariable { |