Feat v0.9.2 Starlark converter consolidation + snapshot cleanup (#75)
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m43s
CI/CD / test-sqlite (pull_request) Successful in 2m52s
CI/CD / build-and-deploy (pull_request) Successful in 2m15s
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-runners (pull_request) Has been skipped
CI/CD / e2e-smoke (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Successful in 2m43s
CI/CD / test-sqlite (pull_request) Successful in 2m52s
CI/CD / build-and-deploy (pull_request) Successful in 2m15s
Consolidate duplicate Go↔Starlark converters into sandbox/convert.go and snapshot parsers into models/snapshot.go. Standardize snapshot creation on wrapped format. Net -393 lines across 21 files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"go.starlark.net/starlark"
|
||||
|
||||
"armature/models"
|
||||
"armature/sandbox"
|
||||
)
|
||||
|
||||
// HandleWebhook is the Gin handler for inbound webhook triggers.
|
||||
@@ -152,7 +153,7 @@ func parseWebhookResponse(val starlark.Value) webhookResponse {
|
||||
}
|
||||
|
||||
if bodyVal, found, _ := d.Get(starlark.String("body")); found {
|
||||
resp.body = starlarkToGo(bodyVal)
|
||||
resp.body = sandbox.StarlarkToGo(bodyVal)
|
||||
} else {
|
||||
resp.body = gin.H{"ok": true}
|
||||
}
|
||||
@@ -168,41 +169,6 @@ func parseWebhookResponse(val starlark.Value) webhookResponse {
|
||||
return webhookResponse{status: 200, body: gin.H{"ok": true}}
|
||||
}
|
||||
|
||||
// starlarkToGo converts a Starlark value to a Go value (for JSON serialization).
|
||||
func starlarkToGo(v starlark.Value) any {
|
||||
switch val := v.(type) {
|
||||
case starlark.NoneType:
|
||||
return nil
|
||||
case starlark.Bool:
|
||||
return bool(val)
|
||||
case starlark.Int:
|
||||
if i, ok := val.Int64(); ok {
|
||||
return i
|
||||
}
|
||||
return val.String()
|
||||
case starlark.Float:
|
||||
return float64(val)
|
||||
case starlark.String:
|
||||
return string(val)
|
||||
case *starlark.List:
|
||||
result := make([]any, val.Len())
|
||||
for i := 0; i < val.Len(); i++ {
|
||||
result[i] = starlarkToGo(val.Index(i))
|
||||
}
|
||||
return result
|
||||
case *starlark.Dict:
|
||||
result := make(map[string]any, val.Len())
|
||||
for _, item := range val.Items() {
|
||||
if k, ok := item[0].(starlark.String); ok {
|
||||
result[string(k)] = starlarkToGo(item[1])
|
||||
}
|
||||
}
|
||||
return result
|
||||
default:
|
||||
return v.String()
|
||||
}
|
||||
}
|
||||
|
||||
// verifyHMAC checks the HMAC-SHA256 signature of a webhook payload.
|
||||
func verifyHMAC(body []byte, secret, signature string) bool {
|
||||
if signature == "" {
|
||||
|
||||
Reference in New Issue
Block a user