Skip to content

Commit

Permalink
updating chi and chi-prom
Browse files Browse the repository at this point in the history
Signed-off-by: Max Knee <[email protected]>
  • Loading branch information
maxknee committed Jan 10, 2024
1 parent af44f63 commit 8af800c
Show file tree
Hide file tree
Showing 128 changed files with 673 additions and 221 deletions.
9 changes: 4 additions & 5 deletions cmd/drone-server/inject_server.go
Expand Up @@ -17,7 +17,6 @@ package main
import (
"net/http"

chiprometheus "github.com/766b/chi-prometheus"
"github.com/drone/drone/cmd/drone-server/config"
"github.com/drone/drone/core"
"github.com/drone/drone/handler/api"
Expand All @@ -29,9 +28,10 @@ import (
"github.com/drone/drone/operator/manager/rpc2"
"github.com/drone/drone/server"
"github.com/google/wire"
"github.com/yarlson/chiprom"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/unrolled/secure"
)

Expand Down Expand Up @@ -62,8 +62,7 @@ var serverSet = wire.NewSet(
// router that is serves the provided handlers.
func provideRouter(api api.Server, web web.Server, rpcv1 rpcHandlerV1, rpcv2 rpcHandlerV2, healthz healthzHandler, metrics *metric.Server, pprof pprofHandler) *chi.Mux {
r := chi.NewRouter()
m := chiprometheus.NewMiddleware("server")
r.Use(m)
r.Use(chiprom.NewMiddleware("server"))
r.Mount("/healthz", healthz)
r.Mount("/metrics", metrics)
r.Mount("/api", api.Handler())
Expand Down
19 changes: 9 additions & 10 deletions go.mod
Expand Up @@ -3,7 +3,6 @@ module github.com/drone/drone
replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.20200309214505-aa6a9891b09c+incompatible

require (
github.com/766b/chi-prometheus v0.0.0-20211217152057-87afa9aa2ca8
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e
github.com/Azure/azure-storage-blob-go v0.7.0
github.com/Azure/go-autorest/autorest/adal v0.8.3 // indirect
Expand All @@ -24,13 +23,14 @@ require (
github.com/drone/go-scm v1.28.0
github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/go-chi/chi v3.3.3+incompatible
github.com/go-chi/chi v1.5.5
github.com/go-chi/chi/v5 v5.0.11
github.com/go-chi/cors v1.0.0
github.com/go-redis/redis/v8 v8.11.0
github.com/go-redsync/redsync/v4 v4.3.0
github.com/go-sql-driver/mysql v1.4.0
github.com/golang/mock v1.3.1
github.com/google/go-cmp v0.5.6
github.com/golang/mock v1.4.4
github.com/google/go-cmp v0.5.9
github.com/google/go-jsonnet v0.17.0
github.com/google/wire v0.2.1
github.com/gosimple/slug v1.3.0
Expand All @@ -42,21 +42,20 @@ require (
github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0
github.com/joho/godotenv v1.3.0
github.com/kelseyhightower/envconfig v1.3.0
github.com/kr/pretty v0.2.0 // indirect
github.com/lib/pq v1.1.0
github.com/mattn/go-sqlite3 v1.9.0
github.com/oxtoacart/bpool v0.0.0-20150712133111-4e1c5567d7c2
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/client_golang v1.16.0
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967
github.com/segmentio/ksuid v1.0.2
github.com/sirupsen/logrus v1.6.0
github.com/unrolled/secure v0.0.0-20181022170031-4b6b7cf51606
github.com/yarlson/chiprom v0.1.0
go.starlark.net v0.0.0-20221020143700-22309ac47eac
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/yaml.v2 v2.3.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/sync v0.3.0
gopkg.in/yaml.v2 v2.4.0
)

replace github.com/h2non/gock => gopkg.in/h2non/gock.v1 v1.0.14
Expand Down
474 changes: 437 additions & 37 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion handler/api/acl/check.go
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion handler/api/acl/check_test.go
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/google/go-cmp/cmp"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
)

Expand Down
2 changes: 1 addition & 1 deletion handler/api/acl/org.go
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// CheckMembership returns an http.Handler middleware that authorizes only
Expand Down
2 changes: 1 addition & 1 deletion handler/api/acl/org_test.go
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
)

Expand Down
2 changes: 1 addition & 1 deletion handler/api/acl/repo.go
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/sirupsen/logrus"
)

Expand Down
4 changes: 2 additions & 2 deletions handler/api/acl/repo_test.go
Expand Up @@ -12,11 +12,11 @@ import (
"testing"
"time"

"github.com/drone/drone/core"
"github.com/drone/drone/handler/api/request"
"github.com/drone/drone/mock"
"github.com/drone/drone/core"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
)

Expand Down
9 changes: 4 additions & 5 deletions handler/api/api.go
Expand Up @@ -18,7 +18,6 @@ import (
"net/http"
"os"

chiprometheus "github.com/766b/chi-prometheus"
"github.com/drone/drone/core"
"github.com/drone/drone/handler/api/acl"
"github.com/drone/drone/handler/api/auth"
Expand Down Expand Up @@ -47,9 +46,10 @@ import (
"github.com/drone/drone/handler/api/user/remote"
"github.com/drone/drone/handler/api/users"
"github.com/drone/drone/logger"
"github.com/yarlson/chiprom"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
)

Expand Down Expand Up @@ -163,8 +163,7 @@ type Server struct {
// Handler returns an http.Handler
func (s Server) Handler() http.Handler {
r := chi.NewRouter()
m := chiprometheus.NewMiddleware("api")
r.Use(m)
r.Use(chiprom.NewMiddleware("api"))
r.Use(middleware.Recoverer)
r.Use(middleware.NoCache)
r.Use(logger.Middleware)
Expand Down
2 changes: 1 addition & 1 deletion handler/api/badge/status.go
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/drone/drone/core"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// Handler returns an http.HandlerFunc that writes an svg status
Expand Down
3 changes: 2 additions & 1 deletion handler/api/badge/status_test.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package badge
Expand All @@ -15,7 +16,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
)

Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/create.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -16,7 +17,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/handler/api/render"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleCreate returns an http.HandlerFunc that processes http
Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/create_test.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -18,7 +19,7 @@ import (
"github.com/drone/drone/handler/api/errors"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
)
Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/delete.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -14,7 +15,7 @@ import (

"net/http"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleDelete returns an http.HandlerFunc that processes http
Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/delete_test.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -18,7 +19,7 @@ import (
"github.com/drone/drone/handler/api/errors"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
)
Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/find.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -14,7 +15,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/handler/api/render"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleFind returns an http.HandlerFunc that writes a json-encoded
Expand Down
3 changes: 2 additions & 1 deletion handler/api/card/find_test.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package card
Expand All @@ -18,7 +19,7 @@ import (
"github.com/drone/drone/handler/api/errors"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
)
Expand Down
3 changes: 2 additions & 1 deletion handler/api/ccmenu/ccmenu.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package ccmenu
Expand All @@ -13,7 +14,7 @@ import (

"github.com/drone/drone/core"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// Handler returns an http.HandlerFunc that writes an svg status
Expand Down
3 changes: 2 additions & 1 deletion handler/api/ccmenu/ccmenu_test.go
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.

//go:build !oss
// +build !oss

package ccmenu
Expand All @@ -16,7 +17,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
"github.com/google/go-cmp/cmp"
)
Expand Down
2 changes: 1 addition & 1 deletion handler/api/events/build.go
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/drone/drone/logger"
"github.com/sirupsen/logrus"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// interval at which the client is pinged to prevent
Expand Down
2 changes: 1 addition & 1 deletion handler/api/events/logs.go
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/handler/api/render"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleLogStream creates an http.HandlerFunc that streams builds logs
Expand Down
2 changes: 1 addition & 1 deletion handler/api/repos/builds/branches/delete.go
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/drone/drone/handler/api/render"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleDelete returns an http.HandlerFunc that handles an
Expand Down
2 changes: 1 addition & 1 deletion handler/api/repos/builds/branches/list.go
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/drone/drone/handler/api/render"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleList returns an http.HandlerFunc that writes a json-encoded
Expand Down
2 changes: 1 addition & 1 deletion handler/api/repos/builds/cancel.go
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/drone/drone/handler/api/render"
"github.com/drone/drone/logger"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleCancel returns an http.HandlerFunc that processes http
Expand Down
2 changes: 1 addition & 1 deletion handler/api/repos/builds/cancel_test.go
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/drone/mock"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
"github.com/golang/mock/gomock"
)

Expand Down
2 changes: 1 addition & 1 deletion handler/api/repos/builds/create.go
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/drone/drone/handler/api/request"
"github.com/drone/go-scm/scm"

"github.com/go-chi/chi"
"github.com/go-chi/chi/v5"
)

// HandleCreate returns an http.HandlerFunc that processes http
Expand Down

0 comments on commit 8af800c

Please sign in to comment.