From 4bedc6cf3f52c267c2df59ebbf7dddb81fd676b6 Mon Sep 17 00:00:00 2001 From: Mikhail Swift Date: Wed, 12 Jun 2024 13:48:59 -0400 Subject: [PATCH] chore: fix lint issues --- main.go | 5 ++++- webhook/github/handler.go | 10 +++++++++- webhook/github/options.go | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 943b8d6..7c728d8 100644 --- a/main.go +++ b/main.go @@ -83,7 +83,10 @@ func main() { log.Println("caught interrupt, waiting for requests to finish...") ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - srv.Shutdown(ctx) + if err := srv.Shutdown(ctx); err != nil { + log.Printf("error shutting down server: %v", err) + } + log.Println("shutting down") } diff --git a/webhook/github/handler.go b/webhook/github/handler.go index 1c8f29a..169aaad 100644 --- a/webhook/github/handler.go +++ b/webhook/github/handler.go @@ -15,6 +15,7 @@ package github import ( + "errors" "fmt" "io" "net/http" @@ -30,8 +31,15 @@ type Handler struct { func New(opts ...Option) (webhook.Handler, error) { h := &Handler{} + errs := make([]error, 0) for _, opt := range opts { - opt(h) + if err := opt(h); err != nil { + errs = append(errs, err) + } + } + + if len(errs) > 0 { + return h, fmt.Errorf("could not create github webhook hanlder: %w", errors.Join(errs...)) } return h, nil diff --git a/webhook/github/options.go b/webhook/github/options.go index dc551eb..ef8b723 100644 --- a/webhook/github/options.go +++ b/webhook/github/options.go @@ -38,8 +38,8 @@ func init() { return h, fmt.Errorf("received webhook handler is not a github handler") } - WithSecretFile(val)(githubHandler) - return githubHandler, nil + err := WithSecretFile(val)(githubHandler) + return githubHandler, err }, ), )