cmd: apply go fix
Updates #cleanup Signed-off-by: Adriano Sela Aviles <adriano@tailscale.com>
This commit is contained in:
committed by
Adriano Sela Aviles
parent
2b62cb54a7
commit
66a51c426f
@@ -6,6 +6,8 @@
|
|||||||
// Package clonerex is an example package for the cloner tool.
|
// Package clonerex is an example package for the cloner tool.
|
||||||
package clonerex
|
package clonerex
|
||||||
|
|
||||||
|
import "maps"
|
||||||
|
|
||||||
type SliceContainer struct {
|
type SliceContainer struct {
|
||||||
Slice []*int
|
Slice []*int
|
||||||
}
|
}
|
||||||
@@ -49,9 +51,7 @@ func (m NamedMap) Clone() NamedMap {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
m2 := make(NamedMap, len(m))
|
m2 := make(NamedMap, len(m))
|
||||||
for k, v := range m {
|
maps.Copy(m2, m)
|
||||||
m2[k] = v
|
|
||||||
}
|
|
||||||
return m2
|
return m2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ type ServiceMonitorSpec struct {
|
|||||||
JobLabel string `json:"jobLabel"`
|
JobLabel string `json:"jobLabel"`
|
||||||
// NamespaceSelector selects the namespace of Service(s) that this ServiceMonitor allows to scrape.
|
// NamespaceSelector selects the namespace of Service(s) that this ServiceMonitor allows to scrape.
|
||||||
// https://github.com/prometheus-operator/prometheus-operator/blob/bb4514e0d5d69f20270e29cfd4ad39b87865ccdf/pkg/apis/monitoring/v1/servicemonitor_types.go#L88
|
// https://github.com/prometheus-operator/prometheus-operator/blob/bb4514e0d5d69f20270e29cfd4ad39b87865ccdf/pkg/apis/monitoring/v1/servicemonitor_types.go#L88
|
||||||
NamespaceSelector ServiceMonitorNamespaceSelector `json:"namespaceSelector,omitempty"`
|
NamespaceSelector ServiceMonitorNamespaceSelector `json:"namespaceSelector"`
|
||||||
// Selector is the label selector for Service(s) that this ServiceMonitor allows to scrape.
|
// Selector is the label selector for Service(s) that this ServiceMonitor allows to scrape.
|
||||||
// https://github.com/prometheus-operator/prometheus-operator/blob/bb4514e0d5d69f20270e29cfd4ad39b87865ccdf/pkg/apis/monitoring/v1/servicemonitor_types.go#L85
|
// https://github.com/prometheus-operator/prometheus-operator/blob/bb4514e0d5d69f20270e29cfd4ad39b87865ccdf/pkg/apis/monitoring/v1/servicemonitor_types.go#L85
|
||||||
Selector metav1.LabelSelector `json:"selector"`
|
Selector metav1.LabelSelector `json:"selector"`
|
||||||
|
|||||||
@@ -41,10 +41,7 @@ func Test_statefulSetNameBase(t *testing.T) {
|
|||||||
if _, err := b.WriteString("a"); err != nil {
|
if _, err := b.WriteString("a"); err != nil {
|
||||||
t.Fatalf("error writing to string builder: %v", err)
|
t.Fatalf("error writing to string builder: %v", err)
|
||||||
}
|
}
|
||||||
baseLength := b.Len()
|
baseLength := min(b.Len(), 43) // currently 43 is the max base length
|
||||||
if baseLength > 43 {
|
|
||||||
baseLength = 43 // currently 43 is the max base length
|
|
||||||
}
|
|
||||||
wantsNameR := regexp.MustCompile(`^ts-a{` + fmt.Sprint(baseLength) + `}-$`) // to match a string like ts-aaaa-
|
wantsNameR := regexp.MustCompile(`^ts-a{` + fmt.Sprint(baseLength) + `}-$`) // to match a string like ts-aaaa-
|
||||||
gotName := statefulSetNameBase(b.String())
|
gotName := statefulSetNameBase(b.String())
|
||||||
if !wantsNameR.MatchString(gotName) {
|
if !wantsNameR.MatchString(gotName) {
|
||||||
|
|||||||
+2
-6
@@ -20,6 +20,7 @@ import (
|
|||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -537,12 +538,7 @@ func (c *connector) ignoreDestination(dstAddrs []netip.Addr) bool {
|
|||||||
if c.ignoreDsts == nil {
|
if c.ignoreDsts == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, a := range dstAddrs {
|
return slices.ContainsFunc(dstAddrs, c.ignoreDsts.Contains)
|
||||||
if c.ignoreDsts.Contains(a) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func proxyTCPConn(c net.Conn, dest string, ctor *connector) {
|
func proxyTCPConn(c net.Conn, dest string, ctor *connector) {
|
||||||
|
|||||||
@@ -548,10 +548,7 @@ type slowReader struct {
|
|||||||
|
|
||||||
func (r *slowReader) Read(p []byte) (n int, err error) {
|
func (r *slowReader) Read(p []byte) (n int, err error) {
|
||||||
const burst = 4 << 10
|
const burst = 4 << 10
|
||||||
plen := len(p)
|
plen := min(len(p), burst)
|
||||||
if plen > burst {
|
|
||||||
plen = burst
|
|
||||||
}
|
|
||||||
if r.rl == nil {
|
if r.rl == nil {
|
||||||
r.rl = rate.NewLimiter(rate.Limit(1<<10), burst)
|
r.rl = rate.NewLimiter(rate.Limit(1<<10), burst)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -504,8 +504,8 @@ func writeOutput(path string, data []byte) error {
|
|||||||
// isZeroMapResponse reports whether all fields of resp are zero values.
|
// isZeroMapResponse reports whether all fields of resp are zero values.
|
||||||
func isZeroMapResponse(resp *tailcfg.MapResponse) bool {
|
func isZeroMapResponse(resp *tailcfg.MapResponse) bool {
|
||||||
v := reflect.ValueOf(*resp)
|
v := reflect.ValueOf(*resp)
|
||||||
for i := range v.NumField() {
|
for _, field := range v.Fields() {
|
||||||
if !v.Field(i).IsZero() {
|
if !field.IsZero() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package tests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
"golang.org/x/exp/constraints"
|
"golang.org/x/exp/constraints"
|
||||||
@@ -252,9 +253,7 @@ func (m NamedMap) Clone() NamedMap {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
m2 := make(NamedMap, len(m))
|
m2 := make(NamedMap, len(m))
|
||||||
for k, v := range m {
|
maps.Copy(m2, m)
|
||||||
m2[k] = v
|
|
||||||
}
|
|
||||||
return m2
|
return m2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user