Skip to content

Commit

Permalink
remove external golang dependencies (#6712)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdabelf5 authored Oct 29, 2024
1 parent 8093459 commit 83d09fa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions internal/certmanager/test_files/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"reflect"

"github.com/kr/pretty"
"github.com/google/go-cmp/cmp"
coretesting "k8s.io/client-go/testing"
)

Expand Down Expand Up @@ -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()))
}
11 changes: 5 additions & 6 deletions internal/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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("", "")
Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions internal/healthcheck/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ 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"
)

// 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
}

Expand Down
5 changes: 2 additions & 3 deletions internal/metrics/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 83d09fa

Please sign in to comment.