Skip to content

Commit 83d09fa

Browse files
authored
remove external golang dependencies (#6712)
1 parent 8093459 commit 83d09fa

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ require (
88
github.com/cert-manager/cert-manager v1.16.1
99
github.com/dlclark/regexp2 v1.11.4
1010
github.com/gkampitakis/go-snaps v0.5.7
11-
github.com/go-chi/chi/v5 v5.1.0
1211
github.com/go-kit/log v0.2.1
1312
github.com/golang-jwt/jwt/v4 v4.5.0
1413
github.com/google/go-cmp v0.6.0
1514
github.com/jinzhu/copier v0.4.0
16-
github.com/kr/pretty v0.3.1
1715
github.com/nginxinc/nginx-plus-go-client v1.3.0
1816
github.com/nginxinc/nginx-prometheus-exporter v1.3.0
1917
github.com/nginxinc/nginx-service-mesh v1.7.0
@@ -84,6 +82,7 @@ require (
8482
github.com/josharian/intern v1.0.0 // indirect
8583
github.com/json-iterator/go v1.1.12 // indirect
8684
github.com/klauspost/compress v1.17.9 // indirect
85+
github.com/kr/pretty v0.3.1 // indirect
8786
github.com/kr/text v0.2.0 // indirect
8887
github.com/kylelemons/godebug v1.1.0 // indirect
8988
github.com/mailru/easyjson v0.7.7 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ github.com/gkampitakis/go-snaps v0.5.7/go.mod h1:ZABkO14uCuVxBHAXAfKG+bqNz+aa1bG
7575
github.com/go-asn1-ber/asn1-ber v1.5.5/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
7676
github.com/go-asn1-ber/asn1-ber v1.5.6 h1:CYsqysemXfEaQbyrLJmdsCRuufHoLa3P/gGWGl5TDrM=
7777
github.com/go-asn1-ber/asn1-ber v1.5.6/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
78-
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
79-
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
8078
github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E=
8179
github.com/go-jose/go-jose/v4 v4.0.4/go.mod h1:NKb5HO1EZccyMpiZNbdUw/14tiXNyUJh188dfnMCAfc=
8280
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=

internal/certmanager/test_files/actions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"fmt"
2222
"reflect"
2323

24-
"github.com/kr/pretty"
24+
"github.com/google/go-cmp/cmp"
2525
coretesting "k8s.io/client-go/testing"
2626
)
2727

@@ -94,5 +94,5 @@ func (a *action) Matches(act coretesting.Action) error {
9494
return nil
9595
}
9696

97-
return fmt.Errorf("unexpected difference between actions: %s", pretty.Diff(objExp.GetObject(), objAct.GetObject()))
97+
return fmt.Errorf("unexpected difference between actions: %s", cmp.Diff(objExp.GetObject(), objAct.GetObject()))
9898
}

internal/healthcheck/healthcheck.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
v1 "k8s.io/api/core/v1"
1919

20-
"github.com/go-chi/chi/v5"
2120
"github.com/nginxinc/kubernetes-ingress/internal/configs"
2221
"github.com/nginxinc/nginx-plus-go-client/client"
2322
"k8s.io/utils/strings/slices"
@@ -80,9 +79,9 @@ func NewHealthServer(addr string, nc *client.NginxClient, cnf *configs.Configura
8079

8180
// ListenAndServe starts healthcheck server.
8281
func (hs *HealthServer) ListenAndServe() error {
83-
mux := chi.NewRouter()
84-
mux.Get("/probe/{hostname}", hs.UpstreamStats)
85-
mux.Get("/probe/ts/{name}", hs.StreamStats)
82+
mux := http.NewServeMux()
83+
mux.HandleFunc("GET /probe/{hostname}", hs.UpstreamStats)
84+
mux.HandleFunc("GET /probe/ts/{name}", hs.StreamStats)
8685
hs.Server.Handler = mux
8786
if hs.Server.TLSConfig != nil {
8887
return hs.Server.ListenAndServeTLS("", "")
@@ -97,7 +96,7 @@ func (hs *HealthServer) Shutdown(ctx context.Context) error {
9796

9897
// UpstreamStats calculates health stats for the host identified by the hostname in the request URL.
9998
func (hs *HealthServer) UpstreamStats(w http.ResponseWriter, r *http.Request) {
100-
hostname := chi.URLParam(r, "hostname")
99+
hostname := r.PathValue("hostname")
101100
host := sanitize(hostname)
102101

103102
upstreamNames := hs.UpstreamsForHost(host)
@@ -137,7 +136,7 @@ func (hs *HealthServer) UpstreamStats(w http.ResponseWriter, r *http.Request) {
137136
// StreamStats calculates health stats for the TransportServer(s)
138137
// identified by the service (action) name in the request URL.
139138
func (hs *HealthServer) StreamStats(w http.ResponseWriter, r *http.Request) {
140-
name := chi.URLParam(r, "name")
139+
name := r.PathValue("name")
141140
n := sanitize(name)
142141
streamUpstreamNames := hs.StreamUpstreamsForName(n)
143142
if len(streamUpstreamNames) == 0 {

internal/healthcheck/healthcheck_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ import (
1212
nic_glog "github.com/nginxinc/kubernetes-ingress/internal/logger/glog"
1313
"github.com/nginxinc/kubernetes-ingress/internal/logger/levels"
1414

15-
"github.com/go-chi/chi/v5"
1615
"github.com/google/go-cmp/cmp"
1716
"github.com/nginxinc/kubernetes-ingress/internal/healthcheck"
1817
"github.com/nginxinc/nginx-plus-go-client/client"
1918
)
2019

2120
// testHandler creates http handler for testing HealthServer.
2221
func testHandler(hs *healthcheck.HealthServer) http.Handler {
23-
mux := chi.NewRouter()
24-
mux.Get("/probe/{hostname}", hs.UpstreamStats)
25-
mux.Get("/probe/ts/{name}", hs.StreamStats)
22+
mux := http.NewServeMux()
23+
mux.HandleFunc("GET /probe/{hostname}", hs.UpstreamStats)
24+
mux.HandleFunc("GET /probe/ts/{name}", hs.StreamStats)
2625
return mux
2726
}
2827

internal/metrics/listener.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"strconv"
1212
"time"
1313

14-
"github.com/go-chi/chi/v5"
1514
kitlog "github.com/go-kit/log"
1615
"github.com/go-kit/log/level"
1716
prometheusClient "github.com/nginxinc/nginx-prometheus-exporter/client"
@@ -112,8 +111,8 @@ func (s *Server) Home(w http.ResponseWriter, r *http.Request) { //nolint:revive
112111

113112
// ListenAndServe starts metrics server.
114113
func (s *Server) ListenAndServe() error {
115-
mux := chi.NewRouter()
116-
mux.Get("/", s.Home)
114+
mux := http.NewServeMux()
115+
mux.HandleFunc("GET /{$}", s.Home)
117116
mux.Handle("/metrics", promhttp.HandlerFor(s.Registry, promhttp.HandlerOpts{}))
118117
s.Server.Handler = mux
119118
if s.Server.TLSConfig != nil {

0 commit comments

Comments
 (0)