Table of contents
Part of nurago, a collection of independent Go packages for backend services.
import "github.com/tecnickcom/nurago/pkg/devlake"
Package devlake provides a Go client for the DevLake Webhook API.
It sends deployment and incident lifecycle events from Go services to DevLake with request validation and retries. The package includes typed request models for deployments, deployment commits, incident creation, and incident close operations, with validation tags aligned to expected webhook payload constraints.
The client provides:
- typed request payloads for deployment and incident webhook endpoints
- helpers for SendDeployment, SendIncident, and SendIncidentClose
- request validation before network calls using field/tag-based constraints
- a health check for API reachability
- configurable timeouts, retry attempts, and custom HTTP client injection
- bearer-token authenticated JSON requests with contextual error wrapping
Based on the DevLake Webhook API documentation: https://devlake.apache.org/docs/Plugins/webhook/
When To Use
- You feed DORA metrics into DevLake from a pipeline.
- Payloads should be validated before they are sent.
Example
// A stand-in for a DevLake instance. Real code passes the base address
// of the deployment.
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.Method, r.URL.Path)
w.WriteHeader(http.StatusOK)
}))
defer srv.Close()
client, err := devlake.New(srv.URL, "api-key")
if err != nil {
fmt.Println(err)
return
}
started := time.Date(2026, 9, 7, 10, 0, 0, 0, time.UTC)
finished := time.Date(2026, 9, 7, 10, 4, 0, 0, time.UTC)
// Requests are validated before being sent, so a malformed payload
// fails locally rather than at the API.
err = client.SendDeployment(context.TODO(), &devlake.DeploymentRequest{
ConnectionID: 1,
ID: "deploy-2026-09-07-001",
DisplayTitle: "payments v1.2.3",
Result: "SUCCESS",
Environment: "PRODUCTION",
StartedDate: &started,
FinishedDate: &finished,
})
fmt.Println("err:", err)
// Output:
// POST /api/rest/plugins/webhook/connections/1/deployments
// err: <nil>
Full source is in example_devlake_test.go. More runnable examples are on pkg.go.dev.
Dependencies
Importing this package pulls 9 external modules:
github.com/gabriel-vasile/mimetypegithub.com/go-playground/localesgithub.com/go-playground/universal-translatorgithub.com/go-playground/validator/v10github.com/julienschmidt/httproutergithub.com/leodido/go-urngolang.org/x/cryptogolang.org/x/sysgolang.org/x/text