mirror of
https://github.com/tailscale/tailscale.git
synced 2026-07-19 03:52:08 -04:00
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
|
||||
|
||||
import "maps"
|
||||
|
||||
type SliceContainer struct {
|
||||
Slice []*int
|
||||
}
|
||||
@@ -49,9 +51,7 @@ func (m NamedMap) Clone() NamedMap {
|
||||
return nil
|
||||
}
|
||||
m2 := make(NamedMap, len(m))
|
||||
for k, v := range m {
|
||||
m2[k] = v
|
||||
}
|
||||
maps.Copy(m2, m)
|
||||
return m2
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ type ServiceMonitorSpec struct {
|
||||
JobLabel string `json:"jobLabel"`
|
||||
// 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
|
||||
NamespaceSelector ServiceMonitorNamespaceSelector `json:"namespaceSelector,omitempty"`
|
||||
NamespaceSelector ServiceMonitorNamespaceSelector `json:"namespaceSelector"`
|
||||
// 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
|
||||
Selector metav1.LabelSelector `json:"selector"`
|
||||
|
||||
@@ -41,10 +41,7 @@ func Test_statefulSetNameBase(t *testing.T) {
|
||||
if _, err := b.WriteString("a"); err != nil {
|
||||
t.Fatalf("error writing to string builder: %v", err)
|
||||
}
|
||||
baseLength := b.Len()
|
||||
if baseLength > 43 {
|
||||
baseLength = 43 // currently 43 is the max base length
|
||||
}
|
||||
baseLength := min(b.Len(), 43) // currently 43 is the max base length
|
||||
wantsNameR := regexp.MustCompile(`^ts-a{` + fmt.Sprint(baseLength) + `}-$`) // to match a string like ts-aaaa-
|
||||
gotName := statefulSetNameBase(b.String())
|
||||
if !wantsNameR.MatchString(gotName) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"net/netip"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -537,12 +538,7 @@ func (c *connector) ignoreDestination(dstAddrs []netip.Addr) bool {
|
||||
if c.ignoreDsts == nil {
|
||||
return false
|
||||
}
|
||||
for _, a := range dstAddrs {
|
||||
if c.ignoreDsts.Contains(a) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.ContainsFunc(dstAddrs, c.ignoreDsts.Contains)
|
||||
}
|
||||
|
||||
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) {
|
||||
const burst = 4 << 10
|
||||
plen := len(p)
|
||||
if plen > burst {
|
||||
plen = burst
|
||||
}
|
||||
plen := min(len(p), burst)
|
||||
if r.rl == nil {
|
||||
r.rl = rate.NewLimiter(rate.Limit(1<<10), burst)
|
||||
}
|
||||
|
||||
@@ -504,8 +504,8 @@ func writeOutput(path string, data []byte) error {
|
||||
// isZeroMapResponse reports whether all fields of resp are zero values.
|
||||
func isZeroMapResponse(resp *tailcfg.MapResponse) bool {
|
||||
v := reflect.ValueOf(*resp)
|
||||
for i := range v.NumField() {
|
||||
if !v.Field(i).IsZero() {
|
||||
for _, field := range v.Fields() {
|
||||
if !field.IsZero() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/netip"
|
||||
|
||||
"golang.org/x/exp/constraints"
|
||||
@@ -252,9 +253,7 @@ func (m NamedMap) Clone() NamedMap {
|
||||
return nil
|
||||
}
|
||||
m2 := make(NamedMap, len(m))
|
||||
for k, v := range m {
|
||||
m2[k] = v
|
||||
}
|
||||
maps.Copy(m2, m)
|
||||
return m2
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user