Feat v0.9.2 converter consolidation (#75)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #75.
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