You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: "Description of what this function does",
28
+
Decl: types.NewFunction(
29
+
types.Args(types.Named("input", types.S).Description("this is the input")),
30
+
types.Named("result", types.S).Description("this is the result"),
31
+
),
32
+
}, myFunctionImpl)
33
+
}
34
+
35
+
funcmyFunctionImpl(bctx topdown.BuiltinContext, operands []*ast.Term, iter func(*ast.Term) error) error {
36
+
// Extract arguments
37
+
input, ok:= operands[0].Value.(ast.String)
38
+
if !ok {
39
+
return fmt.Errorf("input must be a string")
40
+
}
41
+
42
+
// Implement logic
43
+
result:=processInput(string(input))
44
+
45
+
// Return result
46
+
returniter(ast.StringTerm(result))
47
+
}
48
+
49
+
// Autoregisters on package load
50
+
funcinit() {
51
+
iferr:=RegisterMyBuiltins(); err != nil {
52
+
panic(fmt.Sprintf("failed to register built-ins: %v", err))
53
+
}
54
+
}
55
+
```
56
+
57
+
2.**Use in Policies** (`*.rego`):
58
+
```rego
59
+
package example
60
+
import rego.v1
61
+
62
+
result := {
63
+
"violations": violations,
64
+
"skipped": false
65
+
}
66
+
67
+
violations contains msg if {
68
+
output := chainloop.my_function(input.value)
69
+
output != "expected"
70
+
msg := "Function returned unexpected value"
71
+
}
72
+
```
73
+
74
+
**Guidelines**:
75
+
- Use `chainloop.*` namespace for all custom built-ins
76
+
- Functions that call third party services should be marked as non-restrictive by adding the `NonRestrictiveBuiltin` category to the builtin definition
Copy file name to clipboardExpand all lines: CLAUDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -269,4 +269,5 @@ Code reviews are required for all submissions via GitHub pull requests.
269
269
- when creating PR message, keep it high-level, what functionality was added, don't add info about testing, no icons, no info about how the message was generated.
270
270
- app/controlplane/api/gen/frontend/google/protobuf/descriptor.ts is a special case that we don't want to upgrade, so if it upgrades, put it back to main
271
271
- when creating a commit or PR message, NEVER add co-authored by or generated by Claude code
272
-
- any call to authorization Enforce done from the biz or svc layer must be done using biz.AuthzUseCase
272
+
- any call to authorization Enforce done from the biz or svc layer must be done using biz.AuthzUseCase
273
+
- if you modify a schema, remember to run `make migration_sync`
0 commit comments