mirror of
https://github.com/coredns/coredns.git
synced 2026-10-08 19:45:21 -04:00
core: upgrade Go requirement to 1.26.0 (#8466)
* core: upgrade Go requirement to 1.26.0 As golang 1.27 has been released, this PR - Bump Go version requirement to 1.26.0 - Update Go build version to 1.27.0 This is also for solving the issue encountered in 8092 of k8s update Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Bump golang ci Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Fix Signed-off-by: Yong Tang <yong.tang.github@outlook.com> * Migrate faillint to forbidigo, as failint has not bee updated for more than a year Signed-off-by: Yong Tang <yong.tang.github@outlook.com> --------- Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
1
.github/workflows/go.test.yml
vendored
1
.github/workflows/go.test.yml
vendored
@@ -102,7 +102,6 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
go install github.com/fatih/faillint@c56e3ec6dbfc933bbeb884fd31f2bcd41f712657 # v1.15.0
|
||||
( cd test; go test -race ./... )
|
||||
|
||||
test-makefile-release:
|
||||
|
||||
2
.github/workflows/golangci-lint.yml
vendored
2
.github/workflows/golangci-lint.yml
vendored
@@ -20,4 +20,4 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
|
||||
with:
|
||||
version: v2.11.4
|
||||
version: v2.13.2
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.26.7
|
||||
1.27.0
|
||||
|
||||
@@ -10,6 +10,7 @@ linters:
|
||||
- canonicalheader
|
||||
- copyloopvar
|
||||
- durationcheck
|
||||
- forbidigo
|
||||
- godoclint
|
||||
- gosec
|
||||
- govet
|
||||
@@ -43,6 +44,13 @@ linters:
|
||||
- perfsprint
|
||||
- gosec
|
||||
settings:
|
||||
forbidigo:
|
||||
analyze-types: true
|
||||
forbid:
|
||||
- pattern: "^prometheus\\.(NewCounter|NewCounterVec|NewGauge|NewGaugeVec|NewGaugeFunc|NewHistogram|NewHistogramVec|NewSummary|NewSummaryVec)$"
|
||||
pkg: "^github\\.com/prometheus/client_golang/prometheus$"
|
||||
msg: use github.com/prometheus/client_golang/prometheus/promauto
|
||||
|
||||
govet:
|
||||
enable:
|
||||
- nilness
|
||||
|
||||
@@ -57,7 +57,7 @@ out-of-tree plugins.
|
||||
To compile CoreDNS, we assume you have a working Go setup. See various tutorials if you don’t have
|
||||
that already configured.
|
||||
|
||||
First, make sure your golang version is 1.25.0 or higher as `go mod` support and other api is needed.
|
||||
First, make sure your golang version is 1.26.0 or higher as `go mod` support and other api is needed.
|
||||
See [here](https://github.com/golang/go/wiki/Modules) for `go mod` details.
|
||||
Then, check out the project and run `make` to compile the binary:
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"maps"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -128,8 +129,8 @@ func NewServer(addr string, group []*Config) (*Server, error) {
|
||||
|
||||
// compile custom plugin for everything
|
||||
var stack plugin.Handler
|
||||
for i := len(site.Plugin) - 1; i >= 0; i-- {
|
||||
stack = site.Plugin[i](stack)
|
||||
for _, v := range slices.Backward(site.Plugin) {
|
||||
stack = v(stack)
|
||||
|
||||
// register the *handler* also
|
||||
site.registerHandler(stack)
|
||||
|
||||
@@ -414,8 +414,7 @@ func TestServeHTTP3DoesNotLeakBodyReadError(t *testing.T) {
|
||||
func requireHTTPS3ConnectionRejected(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
|
||||
var appErr *quic.ApplicationError
|
||||
if errors.As(err, &appErr) {
|
||||
if appErr, ok := errors.AsType[*quic.ApplicationError](err); ok {
|
||||
if !appErr.Remote {
|
||||
t.Fatalf("connection closed with local application error: %v", err)
|
||||
}
|
||||
@@ -428,8 +427,7 @@ func requireHTTPS3ConnectionRejected(t *testing.T, err error) {
|
||||
// An application close sent before 1-RTT keys are available is encoded as
|
||||
// the generic transport-level APPLICATION_ERROR. In that case, the peer
|
||||
// cannot observe the HTTP/3 application code or reason phrase.
|
||||
var transportErr *quic.TransportError
|
||||
if errors.As(err, &transportErr) {
|
||||
if transportErr, ok := errors.AsType[*quic.TransportError](err); ok {
|
||||
if !transportErr.Remote {
|
||||
t.Fatalf("connection closed with local transport error: %v", err)
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -2,7 +2,7 @@ module github.com/coredns/coredns
|
||||
|
||||
// Note this minimum version requirement. CoreDNS supports the last two
|
||||
// Go versions. This follows the upstream Go project support.
|
||||
go 1.25.0
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible
|
||||
|
||||
@@ -507,7 +507,7 @@ func TestDNS64(t *testing.T) {
|
||||
}
|
||||
actual := rec.Msg
|
||||
if actual.Rcode != rc {
|
||||
t.Fatalf("ServeDNS should return real result code %q != %q", actual.Rcode, rc)
|
||||
t.Fatalf("ServeDNS should return real result code %d != %d", actual.Rcode, rc)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, tc.resp) {
|
||||
|
||||
@@ -92,7 +92,7 @@ func TestShouldTransfer(t *testing.T) {
|
||||
t.Fatalf("Unable to run shouldTransfer: %v", err)
|
||||
}
|
||||
if !should {
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %q", soa.serial-1)
|
||||
t.Fatalf("ShouldTransfer should return true for serial: %d", soa.serial-1)
|
||||
}
|
||||
// Serial equal
|
||||
z.SOA = test.SOA(fmt.Sprintf("%s IN SOA bla. bla. %d 0 0 0 0 ", testZone, soa.serial))
|
||||
|
||||
@@ -32,14 +32,14 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
max_connections 200
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxConnections: new(200),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
@@ -47,8 +47,8 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(50),
|
||||
expectedMaxConnections: intPtr(100),
|
||||
expectedMaxStreams: new(50),
|
||||
expectedMaxConnections: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -56,14 +56,14 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
{
|
||||
input: `grpc_server {
|
||||
max_connections 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(0),
|
||||
expectedMaxConnections: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -139,9 +139,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -48,14 +48,14 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 200
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxConnections: new(200),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
@@ -63,8 +63,8 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(200),
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxConnections: new(200),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ func TestSetup(t *testing.T) {
|
||||
max_connections 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxConnections: intPtr(0),
|
||||
expectedMaxConnections: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -123,7 +123,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
{
|
||||
input: `https {
|
||||
@@ -199,9 +199,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
// Zero values (unbounded)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ func TestSetup(t *testing.T) {
|
||||
max_streams 0
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: intPtr(0),
|
||||
expectedMaxStreams: new(0),
|
||||
},
|
||||
// Error cases
|
||||
{
|
||||
@@ -114,9 +114,7 @@ func TestSetup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(v int) *int {
|
||||
return &v
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
func assertIntPtrValue(t *testing.T, testIndex int, testInput, fieldName string, actual, expected *int) {
|
||||
t.Helper()
|
||||
|
||||
@@ -132,7 +132,7 @@ type dnsControlOpts struct {
|
||||
}
|
||||
|
||||
// newdnsController creates a controller for CoreDNS.
|
||||
func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsClient mcsClientset.MulticlusterV1alpha1Interface, opts dnsControlOpts) *dnsControl {
|
||||
func newdnsController(_ context.Context, kubeClient kubernetes.Interface, mcsClient mcsClientset.MulticlusterV1alpha1Interface, opts dnsControlOpts) *dnsControl {
|
||||
dns := dnsControl{
|
||||
client: kubeClient,
|
||||
mcsClient: mcsClient,
|
||||
@@ -147,8 +147,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.svcLister, dns.svcController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: serviceListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: serviceWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: serviceListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: serviceWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -161,8 +161,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
podLister, podController := object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: podListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: podWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: podListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: podWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -183,8 +183,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
epLister, epController := object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: endpointSliceListFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFunc: endpointSliceWatchFunc(ctx, dns.client, api.NamespaceAll, dns.selector),
|
||||
ListWithContextFunc: endpointSliceListFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
WatchFuncWithContext: endpointSliceWatchFunc(dns.client, api.NamespaceAll, dns.selector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -201,8 +201,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.nsLister, dns.nsController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: namespaceListFunc(ctx, dns.client, dns.namespaceSelector),
|
||||
WatchFunc: namespaceWatchFunc(ctx, dns.client, dns.namespaceSelector),
|
||||
ListWithContextFunc: namespaceListFunc(dns.client, dns.namespaceSelector),
|
||||
WatchFuncWithContext: namespaceWatchFunc(dns.client, dns.namespaceSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -222,8 +222,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.mcEpLister, dns.mcEpController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: endpointSliceListFunc(ctx, dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
WatchFunc: endpointSliceWatchFunc(ctx, dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
ListWithContextFunc: endpointSliceListFunc(dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
WatchFuncWithContext: endpointSliceWatchFunc(dns.client, api.NamespaceAll, mcsEpSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -235,8 +235,8 @@ func newdnsController(ctx context.Context, kubeClient kubernetes.Interface, mcsC
|
||||
dns.svcImportLister, dns.svcImportController = object.NewIndexerInformer(
|
||||
cache.ToListWatcherWithWatchListSemantics(
|
||||
&cache.ListWatch{
|
||||
ListFunc: serviceImportListFunc(ctx, dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
WatchFunc: serviceImportWatchFunc(ctx, dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
ListWithContextFunc: serviceImportListFunc(dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
WatchFuncWithContext: serviceImportWatchFunc(dns.mcsClient, api.NamespaceAll, dns.namespaceSelector),
|
||||
},
|
||||
kubeClient,
|
||||
),
|
||||
@@ -334,8 +334,8 @@ func mcEpNameNamespaceIndexFunc(obj any) ([]string, error) {
|
||||
return []string{mcEp.Index}, nil
|
||||
}
|
||||
|
||||
func serviceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func serviceListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -343,8 +343,8 @@ func serviceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s l
|
||||
}
|
||||
}
|
||||
|
||||
func podListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func podListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -356,8 +356,8 @@ func podListFunc(ctx context.Context, c kubernetes.Interface, ns string, s label
|
||||
}
|
||||
}
|
||||
|
||||
func endpointSliceListFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func endpointSliceListFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -365,8 +365,8 @@ func endpointSliceListFunc(ctx context.Context, c kubernetes.Interface, ns strin
|
||||
}
|
||||
}
|
||||
|
||||
func namespaceListFunc(ctx context.Context, c kubernetes.Interface, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func namespaceListFunc(c kubernetes.Interface, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -374,8 +374,8 @@ func namespaceListFunc(ctx context.Context, c kubernetes.Interface, s labels.Sel
|
||||
}
|
||||
}
|
||||
|
||||
func serviceImportListFunc(ctx context.Context, c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(meta.ListOptions) (runtime.Object, error) {
|
||||
return func(opts meta.ListOptions) (runtime.Object, error) {
|
||||
func serviceImportListFunc(c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (runtime.Object, error) {
|
||||
return func(ctx context.Context, opts meta.ListOptions) (runtime.Object, error) {
|
||||
if s != nil {
|
||||
opts.LabelSelector = s.String()
|
||||
}
|
||||
@@ -383,8 +383,8 @@ func serviceImportListFunc(ctx context.Context, c mcsClientset.MulticlusterV1alp
|
||||
}
|
||||
}
|
||||
|
||||
func serviceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func serviceWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -392,8 +392,8 @@ func serviceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s
|
||||
}
|
||||
}
|
||||
|
||||
func podWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func podWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -405,8 +405,8 @@ func podWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labe
|
||||
}
|
||||
}
|
||||
|
||||
func endpointSliceWatchFunc(ctx context.Context, c kubernetes.Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func endpointSliceWatchFunc(c kubernetes.Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -414,8 +414,8 @@ func endpointSliceWatchFunc(ctx context.Context, c kubernetes.Interface, ns stri
|
||||
}
|
||||
}
|
||||
|
||||
func namespaceWatchFunc(ctx context.Context, c kubernetes.Interface, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func namespaceWatchFunc(c kubernetes.Interface, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
@@ -423,8 +423,8 @@ func namespaceWatchFunc(ctx context.Context, c kubernetes.Interface, s labels.Se
|
||||
}
|
||||
}
|
||||
|
||||
func serviceImportWatchFunc(ctx context.Context, c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(options meta.ListOptions) (watch.Interface, error) {
|
||||
return func(options meta.ListOptions) (watch.Interface, error) {
|
||||
func serviceImportWatchFunc(c mcsClientset.MulticlusterV1alpha1Interface, ns string, s labels.Selector) func(context.Context, meta.ListOptions) (watch.Interface, error) {
|
||||
return func(ctx context.Context, options meta.ListOptions) (watch.Interface, error) {
|
||||
if s != nil {
|
||||
options.LabelSelector = s.String()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
mcs "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
|
||||
)
|
||||
|
||||
func ptrTo[T any](v T) *T { return &v }
|
||||
//go:fix inline
|
||||
|
||||
// dump renders an object for a failure message. %+v prints an aliased pointer field as
|
||||
// an address, which hides the value that actually differs, so render as JSON instead.
|
||||
@@ -76,7 +76,7 @@ func deepCopyCases() []struct {
|
||||
Ports: []api.ServicePort{{
|
||||
Name: "http", Protocol: api.ProtocolTCP, Port: 80,
|
||||
// A pointer field, so a slice copy alone leaves it shared.
|
||||
AppProtocol: ptrTo("kubernetes.io/h2c"),
|
||||
AppProtocol: new("kubernetes.io/h2c"),
|
||||
}},
|
||||
ExternalIPs: []string{"1.2.3.4"},
|
||||
}},
|
||||
@@ -89,7 +89,7 @@ func deepCopyCases() []struct {
|
||||
Type: mcs.ClusterSetIP,
|
||||
Ports: []mcs.ServicePort{{
|
||||
Name: "http", Protocol: api.ProtocolTCP, Port: 80,
|
||||
AppProtocol: ptrTo("kubernetes.io/h2c"),
|
||||
AppProtocol: new("kubernetes.io/h2c"),
|
||||
}},
|
||||
}},
|
||||
{"Namespace", &Namespace{Version: "1", Name: "testns"}},
|
||||
|
||||
@@ -176,12 +176,12 @@ func makeDoQTestTLSConfigs(t *testing.T) (*tls.Config, *tls.Config) {
|
||||
}
|
||||
roots.AddCert(parsed)
|
||||
return &tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
NextProtos: []string{doqALPN},
|
||||
}, &tls.Config{
|
||||
RootCAs: roots,
|
||||
ServerName: "doq.test",
|
||||
}
|
||||
Certificates: []tls.Certificate{cert},
|
||||
NextProtos: []string{doqALPN},
|
||||
}, &tls.Config{
|
||||
RootCAs: roots,
|
||||
ServerName: "doq.test",
|
||||
}
|
||||
}
|
||||
|
||||
func writeDoQTestResponse(stream *quic.Stream, response *dns.Msg) error {
|
||||
@@ -291,8 +291,7 @@ func TestProxyDoQVerifiesServerName(t *testing.T) {
|
||||
if err == nil {
|
||||
t.Fatal("Connect() succeeded with the wrong TLS server name")
|
||||
}
|
||||
var hostnameError x509.HostnameError
|
||||
if !errors.As(err, &hostnameError) {
|
||||
if _, ok := errors.AsType[x509.HostnameError](err); !ok {
|
||||
t.Fatalf("Connect() error = %T %v, want x509.HostnameError", err, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,10 +141,10 @@ func loadRoots(caPath string) (*x509.CertPool, error) {
|
||||
func NewHTTPSTransport(cc *tls.Config) *http.Transport {
|
||||
tr := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Dial: (&net.Dialer{
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).Dial,
|
||||
}).DialContext,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
TLSClientConfig: cc,
|
||||
MaxIdleConnsPerHost: 25,
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
max_streams 100
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedMaxStreams: new(100),
|
||||
expectedWorkerPoolSize: nil,
|
||||
},
|
||||
{
|
||||
@@ -45,7 +45,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: nil,
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -53,8 +53,8 @@ func TestQuicSetup(t *testing.T) {
|
||||
worker_pool_size 1000
|
||||
}`,
|
||||
shouldErr: false,
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedMaxStreams: new(100),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -133,7 +133,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: true,
|
||||
expectedErrContent: "already defined",
|
||||
expectedMaxStreams: pint(100),
|
||||
expectedMaxStreams: new(100),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -142,7 +142,7 @@ func TestQuicSetup(t *testing.T) {
|
||||
}`,
|
||||
shouldErr: true,
|
||||
expectedErrContent: "already defined",
|
||||
expectedWorkerPoolSize: pint(1000),
|
||||
expectedWorkerPoolSize: new(1000),
|
||||
},
|
||||
{
|
||||
input: `quic {
|
||||
@@ -239,6 +239,4 @@ func formatNilableInt(v *int) string {
|
||||
return fmt.Sprintf("%d", *v)
|
||||
}
|
||||
|
||||
func pint(i int) *int {
|
||||
return &i
|
||||
}
|
||||
//go:fix inline
|
||||
|
||||
@@ -2,6 +2,7 @@ package rewrite
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
@@ -161,8 +162,8 @@ func copyRRs(rrs []dns.RR) []dns.RR {
|
||||
|
||||
func (r *ResponseReverter) rewriteResourceRecord(res *dns.Msg, rr dns.RR) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
r.ResponseRules[i].RewriteResponse(res, rr)
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
v.RewriteResponse(res, rr)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,18 +172,18 @@ func (r *ResponseReverter) rewriteResourceRecord(res *dns.Msg, rr dns.RR) {
|
||||
// loops in WriteMsg would otherwise never apply them.
|
||||
func (r *ResponseReverter) rewriteMsg(res *dns.Msg) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
if _, ok := r.ResponseRules[i].(msgResponseRule); !ok {
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
if _, ok := v.(msgResponseRule); !ok {
|
||||
continue
|
||||
}
|
||||
r.ResponseRules[i].RewriteResponse(res, nil)
|
||||
v.RewriteResponse(res, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ResponseReverter) rewriteRequestExtra(req *dns.Msg, rr dns.RR) {
|
||||
// The reverting rules need to be done in reversed order.
|
||||
for i := len(r.ResponseRules) - 1; i >= 0; i-- {
|
||||
rule, ok := r.ResponseRules[i].(requestExtraRevertRule)
|
||||
for _, v := range slices.Backward(r.ResponseRules) {
|
||||
rule, ok := v.(requestExtraRevertRule)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ func TestSIIT(t *testing.T) {
|
||||
}
|
||||
actual := rec.Msg
|
||||
if actual.Rcode != rc {
|
||||
t.Fatalf("ServeDNS should return real result code %q != %q", actual.Rcode, rc)
|
||||
t.Fatalf("ServeDNS should return real result code %d != %d", actual.Rcode, rc)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, tc.resp) {
|
||||
|
||||
@@ -247,7 +247,7 @@ func Section(tc Case, sec sect, rr []dns.RR) error {
|
||||
return fmt.Errorf("MX Mx should be %q, but is %q", tt.Mx, x.Mx)
|
||||
}
|
||||
if x.Preference != tt.Preference {
|
||||
return fmt.Errorf("MX Preference should be %q, but is %q", tt.Preference, x.Preference)
|
||||
return fmt.Errorf("MX Preference should be %d, but is %d", tt.Preference, x.Preference)
|
||||
}
|
||||
case *dns.NS:
|
||||
tt := section[i].(*dns.NS)
|
||||
|
||||
@@ -97,7 +97,7 @@ func getBucketCount(mf *test.MetricFamily, bucketLabel string) (int, error) {
|
||||
return 0, fmt.Errorf("metric point for %s has no 'Buckets' field", mf.Name)
|
||||
}
|
||||
|
||||
bucketsMap, ok := bucketsField.Interface().(map[string]string)
|
||||
bucketsMap, ok := reflect.TypeAssert[map[string]string](bucketsField)
|
||||
if !ok {
|
||||
return 0, fmt.Errorf("'Buckets' field for %s is not a map[string]string", mf.Name)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -313,21 +312,3 @@ func importtype(s string) string {
|
||||
}
|
||||
return "std"
|
||||
}
|
||||
|
||||
// TestPrometheusImports tests the imports path used for metrics. It depends on faillint to be installed: go install github.com/fatih/faillint
|
||||
func TestPrometheusImports(t *testing.T) {
|
||||
if _, err := exec.LookPath("faillint"); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Not executing TestPrometheusImports: faillint not found\n")
|
||||
return
|
||||
}
|
||||
|
||||
// make this multiline?
|
||||
p := `github.com/prometheus/client_golang/prometheus.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}=github.com/prometheus/client_golang/prometheus/promauto.{NewCounter,NewCounterVec,NewCounterVec,NewGauge,NewGaugeVec,NewGaugeFunc,NewHistorgram,NewHistogramVec,NewSummary,NewSummaryVec}`
|
||||
|
||||
cmd := exec.Command("faillint", "-paths", p, "./...")
|
||||
cmd.Dir = ".."
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed: %s\n%s", err, out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user