diff --git a/go.mod b/go.mod index 6cedc49769..bb2e20e364 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,10 @@ require ( github.com/cert-manager/cert-manager v1.16.1 github.com/dlclark/regexp2 v1.11.4 github.com/gkampitakis/go-snaps v0.5.7 - github.com/go-chi/chi/v5 v5.1.0 github.com/go-kit/log v0.2.1 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/go-cmp v0.6.0 github.com/jinzhu/copier v0.4.0 - github.com/kr/pretty v0.3.1 github.com/nginxinc/nginx-plus-go-client v1.3.0 github.com/nginxinc/nginx-prometheus-exporter v1.3.0 github.com/nginxinc/nginx-service-mesh v1.7.0 @@ -84,6 +82,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.9 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/go.sum b/go.sum index e60e11de81..8a46594645 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,6 @@ github.com/gkampitakis/go-snaps v0.5.7/go.mod h1:ZABkO14uCuVxBHAXAfKG+bqNz+aa1bG github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-asn1-ber/asn1-ber v1.5.6 h1:CYsqysemXfEaQbyrLJmdsCRuufHoLa3P/gGWGl5TDrM= github.com/go-asn1-ber/asn1-ber v1.5.6/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= -github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= -github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E= github.com/go-jose/go-jose/v4 v4.0.4/go.mod h1:NKb5HO1EZccyMpiZNbdUw/14tiXNyUJh188dfnMCAfc= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= diff --git a/internal/certmanager/test_files/actions.go b/internal/certmanager/test_files/actions.go index 66469ed7da..9284e3a363 100644 --- a/internal/certmanager/test_files/actions.go +++ b/internal/certmanager/test_files/actions.go @@ -21,7 +21,7 @@ import ( "fmt" "reflect" - "github.com/kr/pretty" + "github.com/google/go-cmp/cmp" coretesting "k8s.io/client-go/testing" ) @@ -94,5 +94,5 @@ func (a *action) Matches(act coretesting.Action) error { return nil } - return fmt.Errorf("unexpected difference between actions: %s", pretty.Diff(objExp.GetObject(), objAct.GetObject())) + return fmt.Errorf("unexpected difference between actions: %s", cmp.Diff(objExp.GetObject(), objAct.GetObject())) } diff --git a/internal/healthcheck/healthcheck.go b/internal/healthcheck/healthcheck.go index cb473af31d..0785349b8c 100644 --- a/internal/healthcheck/healthcheck.go +++ b/internal/healthcheck/healthcheck.go @@ -17,7 +17,6 @@ import ( v1 "k8s.io/api/core/v1" - "github.com/go-chi/chi/v5" "github.com/nginxinc/kubernetes-ingress/internal/configs" "github.com/nginxinc/nginx-plus-go-client/client" "k8s.io/utils/strings/slices" @@ -80,9 +79,9 @@ func NewHealthServer(addr string, nc *client.NginxClient, cnf *configs.Configura // ListenAndServe starts healthcheck server. func (hs *HealthServer) ListenAndServe() error { - mux := chi.NewRouter() - mux.Get("/probe/{hostname}", hs.UpstreamStats) - mux.Get("/probe/ts/{name}", hs.StreamStats) + mux := http.NewServeMux() + mux.HandleFunc("GET /probe/{hostname}", hs.UpstreamStats) + mux.HandleFunc("GET /probe/ts/{name}", hs.StreamStats) hs.Server.Handler = mux if hs.Server.TLSConfig != nil { return hs.Server.ListenAndServeTLS("", "") @@ -97,7 +96,7 @@ func (hs *HealthServer) Shutdown(ctx context.Context) error { // UpstreamStats calculates health stats for the host identified by the hostname in the request URL. func (hs *HealthServer) UpstreamStats(w http.ResponseWriter, r *http.Request) { - hostname := chi.URLParam(r, "hostname") + hostname := r.PathValue("hostname") host := sanitize(hostname) upstreamNames := hs.UpstreamsForHost(host) @@ -137,7 +136,7 @@ func (hs *HealthServer) UpstreamStats(w http.ResponseWriter, r *http.Request) { // StreamStats calculates health stats for the TransportServer(s) // identified by the service (action) name in the request URL. func (hs *HealthServer) StreamStats(w http.ResponseWriter, r *http.Request) { - name := chi.URLParam(r, "name") + name := r.PathValue("name") n := sanitize(name) streamUpstreamNames := hs.StreamUpstreamsForName(n) if len(streamUpstreamNames) == 0 { diff --git a/internal/healthcheck/healthcheck_test.go b/internal/healthcheck/healthcheck_test.go index 6ee6500853..fa385189ba 100644 --- a/internal/healthcheck/healthcheck_test.go +++ b/internal/healthcheck/healthcheck_test.go @@ -12,7 +12,6 @@ import ( nic_glog "github.com/nginxinc/kubernetes-ingress/internal/logger/glog" "github.com/nginxinc/kubernetes-ingress/internal/logger/levels" - "github.com/go-chi/chi/v5" "github.com/google/go-cmp/cmp" "github.com/nginxinc/kubernetes-ingress/internal/healthcheck" "github.com/nginxinc/nginx-plus-go-client/client" @@ -20,9 +19,9 @@ import ( // testHandler creates http handler for testing HealthServer. func testHandler(hs *healthcheck.HealthServer) http.Handler { - mux := chi.NewRouter() - mux.Get("/probe/{hostname}", hs.UpstreamStats) - mux.Get("/probe/ts/{name}", hs.StreamStats) + mux := http.NewServeMux() + mux.HandleFunc("GET /probe/{hostname}", hs.UpstreamStats) + mux.HandleFunc("GET /probe/ts/{name}", hs.StreamStats) return mux } diff --git a/internal/metrics/listener.go b/internal/metrics/listener.go index 8f16cf52df..20650b5798 100644 --- a/internal/metrics/listener.go +++ b/internal/metrics/listener.go @@ -11,7 +11,6 @@ import ( "strconv" "time" - "github.com/go-chi/chi/v5" kitlog "github.com/go-kit/log" "github.com/go-kit/log/level" prometheusClient "github.com/nginxinc/nginx-prometheus-exporter/client" @@ -112,8 +111,8 @@ func (s *Server) Home(w http.ResponseWriter, r *http.Request) { //nolint:revive // ListenAndServe starts metrics server. func (s *Server) ListenAndServe() error { - mux := chi.NewRouter() - mux.Get("/", s.Home) + mux := http.NewServeMux() + mux.HandleFunc("GET /{$}", s.Home) mux.Handle("/metrics", promhttp.HandlerFor(s.Registry, promhttp.HandlerOpts{})) s.Server.Handler = mux if s.Server.TLSConfig != nil {