Very minor clean-ups (import re-ordering by automated tooling) (#28)
This commit is contained in:
committed by
GitHub
parent
ca55bde751
commit
1f5ac0b49d
@@ -4,6 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
kitlogrus "github.com/go-kit/kit/log/logrus"
|
kitlogrus "github.com/go-kit/kit/log/logrus"
|
||||||
discardMetrics "github.com/go-kit/kit/metrics/discard"
|
discardMetrics "github.com/go-kit/kit/metrics/discard"
|
||||||
expvarMetrics "github.com/go-kit/kit/metrics/expvar"
|
expvarMetrics "github.com/go-kit/kit/metrics/expvar"
|
||||||
@@ -11,8 +14,6 @@ import (
|
|||||||
influx "github.com/influxdata/influxdb1-client/v2"
|
influx "github.com/influxdata/influxdb1-client/v2"
|
||||||
"github.com/itzg/mc-router/server"
|
"github.com/itzg/mc-router/server"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetricsBuilder interface {
|
type MetricsBuilder interface {
|
||||||
|
|||||||
+5
-4
@@ -4,14 +4,15 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/text/encoding/unicode"
|
|
||||||
"golang.org/x/text/transform"
|
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"golang.org/x/text/encoding/unicode"
|
||||||
|
"golang.org/x/text/transform"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ReadPacket(reader io.Reader, addr net.Addr, state State) (*Packet, error) {
|
func ReadPacket(reader io.Reader, addr net.Addr, state State) (*Packet, error) {
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package mcproto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadVarInt(t *testing.T) {
|
func TestReadVarInt(t *testing.T) {
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"expvar"
|
"expvar"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var apiRoutes = mux.NewRouter()
|
var apiRoutes = mux.NewRouter()
|
||||||
|
|||||||
+5
-5
@@ -3,15 +3,16 @@ package server
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-kit/kit/metrics"
|
"github.com/go-kit/kit/metrics"
|
||||||
"github.com/itzg/mc-router/mcproto"
|
"github.com/itzg/mc-router/mcproto"
|
||||||
"github.com/juju/ratelimit"
|
"github.com/juju/ratelimit"
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -243,7 +244,6 @@ func (c *connectorImpl) findAndConnectBackend(ctx context.Context, frontendConn
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.pumpConnections(ctx, frontendConn, backendConn)
|
c.pumpConnections(ctx, frontendConn, backendConn)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *connectorImpl) pumpConnections(ctx context.Context, frontendConn, backendConn net.Conn) {
|
func (c *connectorImpl) pumpConnections(ctx context.Context, frontendConn, backendConn net.Conn) {
|
||||||
|
|||||||
+5
-4
@@ -1,17 +1,18 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"net"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
+2
-1
@@ -2,10 +2,11 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestK8sWatcherImpl_handleAddThenUpdate(t *testing.T) {
|
func TestK8sWatcherImpl_handleAddThenUpdate(t *testing.T) {
|
||||||
|
|||||||
+5
-8
@@ -2,11 +2,12 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -134,16 +135,12 @@ func (r *routesImpl) FindBackendForServerAddress(serverAddress string) (string,
|
|||||||
|
|
||||||
address := strings.ToLower(addressParts[0])
|
address := strings.ToLower(addressParts[0])
|
||||||
|
|
||||||
if r.mappings == nil {
|
if r.mappings != nil {
|
||||||
return r.defaultRoute, address
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if route, exists := r.mappings[address]; exists {
|
if route, exists := r.mappings[address]; exists {
|
||||||
return route, address
|
return route, address
|
||||||
} else {
|
|
||||||
return r.defaultRoute, address
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return r.defaultRoute, address
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *routesImpl) GetMappings() map[string]string {
|
func (r *routesImpl) GetMappings() map[string]string {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_routesImpl_FindBackendForServerAddress(t *testing.T) {
|
func Test_routesImpl_FindBackendForServerAddress(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user