From 3d5e0796dffd30a659843f90cc1be3bf21951a67 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 22:27:05 -0500 Subject: [PATCH 1/5] fix whitespace --- .golangci.yaml | 212 ++++++++++++++++-- pkg/apis/config/store_test.go | 1 - .../v1alpha1/ingress_defaults_test.go | 1 - test/conformance/ingress/class.go | 1 - test/conformance/ingress/headers.go | 2 - test/conformance/ingress/visibility.go | 1 - test/test_images/httpproxy/httpproxy.go | 1 - 7 files changed, 198 insertions(+), 21 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 1e75e309e..5fbed11c9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,29 +1,213 @@ run: - timeout: 5m - + timeout: 10m + allow-parallel-runners: true + exclude-dirs: + - pkg/client build-tags: - - e2e + - e2e + +output: + sort-results: true + sort-order: + - linter + - file + show-stats: true + + +issues: + uniq-by-line: true + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-rules: + - path: test # Excludes /test, *_test.go etc. + linters: + - gosec + - unparam + - noctx + - protogetter + - linters: ["gocritic"] + # Fixes are non-trivial do in a follow up + text: "ifElseChain" - skip-dirs: - - pkg/client +linters-settings: + intrange: + severity: warning + gomodguard: + blocked: + modules: + - github.com/ghodss/yaml: + recommendations: + - sigs.k8s.io/yaml + - go.uber.org/atomic: + recommendations: + - sync/atomic + - io/ioutil: + recommendations: + - os + - io + - github.com/hashicorp/go-multierror: + reason: "use errors.Join" + recommendations: + - errors + - go.uber.org/multierr: + reason: "use errors.Join" + recommendations: + - errors + revive: + rules: + # use unparam linter instead - defaults are better + - name: unused-parameter + disabled: true linters: + disable: + - errcheck enable: + # Check for pass []any as any in variadic func(...any). + - asasalint + + # Only use ASCII chars in indentifiers - asciicheck + + # Dangerous unicode characters + - bidichk + + # Checks whether HTTP response body is closed successfully. + - bodyclose + + # Canonicalheader checks whether net/http.Header uses canonical header. + - canonicalheader + + # TODO - do a follow up PR + # # Containedctx is a linter that detects struct contained context.Context + # # field. + # - containedctx + + # TODO - do a follow up PR + # # Check whether the function uses a non-inherited context. + # - contextcheck + + # Copyloopvar is a linter detects places where loop variables are copied. + - copyloopvar + + # Check declaration order of types, consts, vars and funcs. + - decorder + + # Check for two durations multiplied together. + - durationcheck + + # Checks that sentinel errors are prefixed with the Err- and error types + # are suffixed with the -Error. + - errname + + # Errorlint is a linter for that can be used to find code that will cause + # problems with the error wrapping scheme introduced in Go 1.13. - errorlint + + # Detects nested contexts in loops. + - fatcontext + + # Checks that go compiler directive comments (//go:) are valid. + - gocheckcompilerdirectives + + # Provides diagnostics that check for bugs, performance and style issues. + # Extensible without recompilation through dynamic rules. + # Dynamic rules are written declaratively with AST patterns, filters, + # report message and optional suggestion. + - gocritic + + # Gofmt checks whether code was gofmt-ed. By default this tool runs + # with -s option to check for code simplification. + - gofmt + + # Gofumpt checks whether code was gofumpt-ed. + - gofumpt + + # Check import statements are formatted according to the 'goimport' + # command. Reformat imports in autofix mode. + - goimports + + # See config below + - gomodguard + + # Inspects source code for security problems. - gosec + + # Linter that specializes in simplifying code. + - gosimple + - govet + + # Intrange is a linter to find places where for loops could make use of + # an integer range. + - intrange + + # Checks key value pairs for common logger libraries (kitlog,klog,logr,zap). + - loggercheck + + # Finds slice declarations with non-zero initial length. + - makezero + + # Reports wrong mirror patterns of bytes/strings usage + - mirror + + # Finds commonly misspelled English words. + - misspell + + # Finds the code that returns nil even if it checks that the error is not nil. + - nilerr + + # Finds sending HTTP request without context.Context. + - noctx + + # Reports ill-formed or insufficient nolint directives. + - nolintlint + + # Checks for misuse of Sprintf to construct a host with port in a URL. + - nosprintfhostport + + # Checks that fmt.Sprintf can be replaced with a faster alternative. + - perfsprint + + # Finds slice declarations that could potentially be pre-allocated. - prealloc + + # Reports direct reads from proto message fields when getters should be used. + - protogetter + + # Checks that package variables are not reassigned. + - reassign + + # Fast, configurable, extensible, flexible, and beautiful linter for + # Go. Drop-in replacement of golint. - revive + + # Checks for mistakes with OpenTelemetry/Census spans. + - spancheck + + # Stylecheck is a replacement for golint. - stylecheck - - tparallel + + # Tenv is analyzer that detects using os.Setenv instead of t.Setenv + # since Go1.17. + - tenv + + # Linter checks if examples are testable (have an expected output). + - testableexamples + + # Remove unnecessary type conversions. - unconvert + + # Reports unused function parameters and results in your code. - unparam - disable: - - errcheck -issues: - exclude-rules: - - path: test # Excludes /test, *_test.go etc. - linters: - - gosec - - unparam + # A linter that detect the possibility to use variables/constants from the + # Go standard library. + - usestdlibvars + + # Finds wasted assignment statements. + - wastedassign + + # Whitespace is a linter that checks for unnecessary newlines at the start + # and end of functions, if, for, etc. + - whitespace + diff --git a/pkg/apis/config/store_test.go b/pkg/apis/config/store_test.go index ebe774d25..4f08de14a 100644 --- a/pkg/apis/config/store_test.go +++ b/pkg/apis/config/store_test.go @@ -47,7 +47,6 @@ func TestStoreLoadWithContext(t *testing.T) { t.Error("Unexpected defaults config (-want, +got):", diff) } }) - } func TestStoreLoadWithContextOrDefaults(t *testing.T) { diff --git a/pkg/apis/networking/v1alpha1/ingress_defaults_test.go b/pkg/apis/networking/v1alpha1/ingress_defaults_test.go index 0f8e4e8ad..4227b8145 100644 --- a/pkg/apis/networking/v1alpha1/ingress_defaults_test.go +++ b/pkg/apis/networking/v1alpha1/ingress_defaults_test.go @@ -147,5 +147,4 @@ func TestIngressDefaulting(t *testing.T) { } }) } - } diff --git a/test/conformance/ingress/class.go b/test/conformance/ingress/class.go index 2a2142500..d233c2308 100644 --- a/test/conformance/ingress/class.go +++ b/test/conformance/ingress/class.go @@ -67,7 +67,6 @@ func TestIngressClass(t *testing.T) { verifyIngressWithAnnotations(ctx, t, clients, test.annotations, ingressBackend) }) } - } func verifyIngressWithAnnotations(ctx context.Context, t *testing.T, clients *test.Clients, diff --git a/test/conformance/ingress/headers.go b/test/conformance/ingress/headers.go index 83c2c6522..4488b4463 100644 --- a/test/conformance/ingress/headers.go +++ b/test/conformance/ingress/headers.go @@ -106,7 +106,6 @@ func TestProbeHeaders(t *testing.T) { } }) } - } // TestTagHeaders verifies that an Ingress properly dispatches to backends based on the tag header @@ -210,7 +209,6 @@ func TestTagHeaders(t *testing.T) { } }) } - } // TestPreSplitSetHeaders verifies that an Ingress that specified AppendHeaders pre-split has the appropriate header(s) set. diff --git a/test/conformance/ingress/visibility.go b/test/conformance/ingress/visibility.go index e68712f70..b673a22ee 100644 --- a/test/conformance/ingress/visibility.go +++ b/test/conformance/ingress/visibility.go @@ -79,7 +79,6 @@ func TestVisibility(t *testing.T) { } func testProxyToHelloworld(ctx context.Context, t *testing.T, ingress *v1alpha1.Ingress, clients *test.Clients, privateHostName string) { - loadbalancerAddress := ingress.Status.PrivateLoadBalancer.Ingress[0].DomainInternal proxyName, proxyPort, _ := CreateProxyService(ctx, t, clients, privateHostName, loadbalancerAddress) diff --git a/test/test_images/httpproxy/httpproxy.go b/test/test_images/httpproxy/httpproxy.go index 563fa0eb6..385dbd3a4 100644 --- a/test/test_images/httpproxy/httpproxy.go +++ b/test/test_images/httpproxy/httpproxy.go @@ -103,7 +103,6 @@ func main() { log.Print("Listening on address: ", address) test.ListenAndServeGracefully(address, handler) } - } // newDNSCachingTransport caches DNS lookups locally to avoid issues like From 2e34d077d0e3ecb6ce833d2c53ccb79d4730e7ea Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 22:29:45 -0500 Subject: [PATCH 2/5] use stdlib constants --- test/conformance/ingress/headers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/conformance/ingress/headers.go b/test/conformance/ingress/headers.go index 4488b4463..8e9712159 100644 --- a/test/conformance/ingress/headers.go +++ b/test/conformance/ingress/headers.go @@ -83,7 +83,7 @@ func TestProbeHeaders(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - req, err := http.NewRequest("GET", fmt.Sprintf("http://%s.%s", name, test.NetworkingFlags.ServiceDomain), nil) + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("http://%s.%s", name, test.NetworkingFlags.ServiceDomain), nil) if err != nil { t.Fatal("Error creating request:", err) } From 4629d8f999bafd02cbcf5fed2fa7617983148f1a Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 22:39:52 -0500 Subject: [PATCH 3/5] run golangci-lint run --fix --- pkg/apis/networking/metadata_validation.go | 24 +++++------ pkg/apis/networking/ports.go | 6 +-- .../v1alpha1/certificate_validation_test.go | 1 + .../networking/v1alpha1/domainclaim_types.go | 6 +-- .../v1alpha1/ingress_helpers_test.go | 4 +- pkg/certificates/constants.go | 4 +- pkg/config/config_test.go | 18 +++++--- pkg/http/probe/handler_test.go | 4 +- pkg/ingress/ingress.go | 3 +- pkg/status/status.go | 16 ++++---- pkg/status/status_test.go | 41 +++++++++---------- pkg/testing/status/fake_test.go | 4 +- test/conformance/ingress/class.go | 4 +- test/conformance/ingress/grpc.go | 6 +-- test/conformance/ingress/headers.go | 9 ++-- test/conformance/ingress/path.go | 2 +- test/conformance/ingress/percentage.go | 2 +- test/conformance/ingress/update.go | 4 +- test/conformance/ingress/util.go | 39 +++++++++++------- test/conformance/ingress/visibility.go | 7 +--- test/conformance/ingress/websocket.go | 8 ++-- test/test_images/httpproxy/httpproxy.go | 7 ++-- test/test_images/runtime/handlers/cgroup.go | 5 ++- test/test_images/runtime/handlers/file.go | 3 +- test/test_images/runtime/handlers/mount.go | 3 +- test/test_images/runtime/handlers/runtime.go | 3 +- test/test_images/runtime/main.go | 4 +- 27 files changed, 125 insertions(+), 112 deletions(-) diff --git a/pkg/apis/networking/metadata_validation.go b/pkg/apis/networking/metadata_validation.go index ff081dcd0..3c57c4fa9 100644 --- a/pkg/apis/networking/metadata_validation.go +++ b/pkg/apis/networking/metadata_validation.go @@ -24,19 +24,17 @@ import ( "knative.dev/pkg/apis" ) -var ( - allowedAnnotations = sets.New[string]( - IngressClassAnnotationKey, - CertificateClassAnnotationKey, - DisableAutoTLSAnnotationKey, - DisableExternalDomainTLSAnnotationKey, - HTTPOptionAnnotationKey, - - IngressClassAnnotationAltKey, - CertificateClassAnnotationAltKey, - DisableAutoTLSAnnotationAltKey, - HTTPProtocolAnnotationKey, - ) +var allowedAnnotations = sets.New[string]( + IngressClassAnnotationKey, + CertificateClassAnnotationKey, + DisableAutoTLSAnnotationKey, + DisableExternalDomainTLSAnnotationKey, + HTTPOptionAnnotationKey, + + IngressClassAnnotationAltKey, + CertificateClassAnnotationAltKey, + DisableAutoTLSAnnotationAltKey, + HTTPProtocolAnnotationKey, ) // ValidateAnnotations validates that `annotations` in `metadata` stanza of the diff --git a/pkg/apis/networking/ports.go b/pkg/apis/networking/ports.go index 6bd1a65f2..14c033121 100644 --- a/pkg/apis/networking/ports.go +++ b/pkg/apis/networking/ports.go @@ -40,10 +40,8 @@ const ( ServicePortNameHTTPS = "https" ) -var ( - // AppProtocolH2C is the name of the external port of the service for HTTP/2, from https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/3726-standard-application-protocols#new-standard-protocols - AppProtocolH2C = "kubernetes.io/h2c" -) +// AppProtocolH2C is the name of the external port of the service for HTTP/2, from https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/3726-standard-application-protocols#new-standard-protocols +var AppProtocolH2C = "kubernetes.io/h2c" // ServicePortName returns the port for the app level protocol. func ServicePortName(proto ProtocolType) string { diff --git a/pkg/apis/networking/v1alpha1/certificate_validation_test.go b/pkg/apis/networking/v1alpha1/certificate_validation_test.go index 0c64bcd44..5ac96cc31 100644 --- a/pkg/apis/networking/v1alpha1/certificate_validation_test.go +++ b/pkg/apis/networking/v1alpha1/certificate_validation_test.go @@ -95,6 +95,7 @@ func TestCertificateSpecValidation(t *testing.T) { }) } } + func TestCertificateValidation(t *testing.T) { tests := []struct { name string diff --git a/pkg/apis/networking/v1alpha1/domainclaim_types.go b/pkg/apis/networking/v1alpha1/domainclaim_types.go index df19f31d7..352f9658d 100644 --- a/pkg/apis/networking/v1alpha1/domainclaim_types.go +++ b/pkg/apis/networking/v1alpha1/domainclaim_types.go @@ -39,10 +39,8 @@ type ClusterDomainClaim struct { Spec ClusterDomainClaimSpec `json:"spec,omitempty"` } -var ( - // Check that we can create OwnerReferences to a ClusterDomainClaim. - _ kmeta.OwnerRefable = (*ClusterDomainClaim)(nil) -) +// Check that we can create OwnerReferences to a ClusterDomainClaim. +var _ kmeta.OwnerRefable = (*ClusterDomainClaim)(nil) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/networking/v1alpha1/ingress_helpers_test.go b/pkg/apis/networking/v1alpha1/ingress_helpers_test.go index 4b9004a3a..0be4cc289 100644 --- a/pkg/apis/networking/v1alpha1/ingress_helpers_test.go +++ b/pkg/apis/networking/v1alpha1/ingress_helpers_test.go @@ -22,9 +22,7 @@ import ( "github.com/google/go-cmp/cmp" ) -var ( - hosts = []string{"foo", "bar", "foo.bar"} -) +var hosts = []string{"foo", "bar", "foo.bar"} func TestGetIngressTLSForVisibility(t *testing.T) { tests := []struct { diff --git a/pkg/certificates/constants.go b/pkg/certificates/constants.go index 53f9c048d..cdb8c2941 100644 --- a/pkg/certificates/constants.go +++ b/pkg/certificates/constants.go @@ -21,10 +21,10 @@ import "strings" const ( Organization = "knative.dev" - // nolint:all + //nolint:all LegacyFakeDnsName = "data-plane." + Organization - // nolint:all + //nolint:all // Deprecated: FakeDnsName is deprecated. // Please use the DataPlaneRoutingSAN for calls to the Activator // and the DataPlaneUserSAN function for calls to a Knative-Service via Queue-Proxy. diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 88f1ce64e..0408f61f5 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -548,8 +548,10 @@ func TestAnnotationsInDomainTemplate(t *testing.T) { Name: "foo", Namespace: "bar", Annotations: map[string]string{ - "sub": "sub1"}, - Domain: "baz.com"}, + "sub": "sub1", + }, + Domain: "baz.com", + }, }, { name: "network configuration without annotations in template", wantErr: false, @@ -561,7 +563,8 @@ func TestAnnotationsInDomainTemplate(t *testing.T) { data: DomainTemplateValues{ Name: "foo", Namespace: "bar", - Domain: "baz.com"}, + Domain: "baz.com", + }, }} for _, tt := range networkConfigTests { @@ -602,8 +605,10 @@ func TestLabelsInDomainTemplate(t *testing.T) { Name: "foo", Namespace: "bar", Labels: map[string]string{ - "sub": "sub1"}, - Domain: "baz.com"}, + "sub": "sub1", + }, + Domain: "baz.com", + }, }, { name: "network configuration without labels in template", wantErr: false, @@ -615,7 +620,8 @@ func TestLabelsInDomainTemplate(t *testing.T) { templateValue: DomainTemplateValues{ Name: "foo", Namespace: "bar", - Domain: "baz.com"}, + Domain: "baz.com", + }, }} for _, tt := range networkConfigTests { diff --git a/pkg/http/probe/handler_test.go b/pkg/http/probe/handler_test.go index c9afb5c52..2e9a59fca 100644 --- a/pkg/http/probe/handler_test.go +++ b/pkg/http/probe/handler_test.go @@ -109,7 +109,7 @@ func BenchmarkProbeHandlerNoProbeHeader(b *testing.B) { req := httptest.NewRequest(http.MethodGet, "http://example.com", nil) b.Run("sequential-no-header", func(b *testing.B) { - for j := 0; j < b.N; j++ { + for range b.N { h.ServeHTTP(resp, req) } }) @@ -131,7 +131,7 @@ func BenchmarkProbeHandlerWithProbeHeader(b *testing.B) { h = NewHandler(h) b.Run("sequential-probe-header", func(b *testing.B) { resp := httptest.NewRecorder() - for j := 0; j < b.N; j++ { + for range b.N { h.ServeHTTP(resp, req) } }) diff --git a/pkg/ingress/ingress.go b/pkg/ingress/ingress.go index f1ffb88c4..ec4825c70 100644 --- a/pkg/ingress/ingress.go +++ b/pkg/ingress/ingress.go @@ -18,6 +18,7 @@ package ingress import ( "crypto/sha256" + "encoding/hex" "encoding/json" "fmt" "strings" @@ -46,7 +47,7 @@ func InsertProbe(ing *v1alpha1.Ingress) (string, error) { if err != nil { return "", fmt.Errorf("failed to compute the hash of the Ingress: %w", err) } - hash := fmt.Sprintf("%x", bytes) + hash := hex.EncodeToString(bytes[:]) for _, rule := range ing.Spec.Rules { if rule.HTTP == nil { diff --git a/pkg/status/status.go b/pkg/status/status.go index d48e57a36..ca0315632 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -19,6 +19,7 @@ package status import ( "context" "crypto/tls" + "encoding/hex" "fmt" "net" "net/http" @@ -58,10 +59,8 @@ const ( initialDelay = 200 * time.Millisecond ) -var ( - // probeMaxRetryDelay defines the maximum delay between retries in the backoff of probing - probeMaxRetryDelay = 30 * time.Second -) +// probeMaxRetryDelay defines the maximum delay between retries in the backoff of probing +var probeMaxRetryDelay = 30 * time.Second func init() { if val, ok := os.LookupEnv("PROBE_MAX_RETRY_DELAY_SECONDS"); ok { @@ -151,7 +150,8 @@ type Prober struct { func NewProber( logger *zap.SugaredLogger, targetLister ProbeTargetLister, - readyCallback func(*v1alpha1.Ingress)) *Prober { + readyCallback func(*v1alpha1.Ingress), +) *Prober { return &Prober{ logger: logger, ingressStates: make(map[types.NamespacedName]*ingressState), @@ -183,7 +183,7 @@ func (m *Prober) IsReady(ctx context.Context, ing *v1alpha1.Ingress) (bool, erro if err != nil { return false, fmt.Errorf("failed to compute the hash of the Ingress: %w", err) } - hash := fmt.Sprintf("%x", bytes) + hash := hex.EncodeToString(bytes[:]) if ready, ok := func() (bool, bool) { m.mu.Lock() @@ -297,11 +297,11 @@ func (m *Prober) Start(done <-chan struct{}) chan struct{} { var wg sync.WaitGroup // Start the worker goroutines - for i := 0; i < m.probeConcurrency; i++ { + for range m.probeConcurrency { wg.Add(1) go func() { defer wg.Done() - //nolint:all + for m.processWorkItem() { } }() diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index 2b6456368..9051446fa 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -39,23 +39,21 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -var ( - ingTemplate = &v1alpha1.Ingress{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: "default", - Name: "whatever", - }, - Spec: v1alpha1.IngressSpec{ - Rules: []v1alpha1.IngressRule{{ - Hosts: []string{ - "foo.bar.com", - }, - Visibility: v1alpha1.IngressVisibilityExternalIP, - HTTP: &v1alpha1.HTTPIngressRuleValue{}, - }}, - }, - } -) +var ingTemplate = &v1alpha1.Ingress{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "default", + Name: "whatever", + }, + Spec: v1alpha1.IngressSpec{ + Rules: []v1alpha1.IngressRule{{ + Hosts: []string{ + "foo.bar.com", + }, + Visibility: v1alpha1.IngressVisibilityExternalIP, + HTTP: &v1alpha1.HTTPIngressRuleValue{}, + }}, + }, +} func TestProbeAllHosts(t *testing.T) { const hostA = "foo.bar.com" @@ -73,7 +71,7 @@ func TestProbeAllHosts(t *testing.T) { failedRequests := make(chan *http.Request) failHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { failedRequests <- r - w.WriteHeader(500) + w.WriteHeader(http.StatusInternalServerError) }) // Actual probe handler used in Activator and Queue-Proxy @@ -163,7 +161,6 @@ func TestProbeAllHosts(t *testing.T) { // Just drain the requests in the channel to not block the handler go func() { - //nolint:all for range probeRequests { } }() @@ -197,7 +194,7 @@ func TestProbeLifecycle(t *testing.T) { failedRequests := make(chan *http.Request) failHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { failedRequests <- r - w.WriteHeader(500) + w.WriteHeader(http.StatusInternalServerError) }) // Actual probe handler used in Activator and Queue-Proxy @@ -260,7 +257,7 @@ func TestProbeLifecycle(t *testing.T) { const expHostHeader = "foo.bar.com" // Wait for the first (failing) and second (success) requests to be executed and validate Host header - for i := 0; i < 2; i++ { + for range 2 { req := <-probeRequests if req.Host != expHostHeader { t.Fatalf("Host header = %q, want %q", req.Host, expHostHeader) @@ -275,7 +272,7 @@ func TestProbeLifecycle(t *testing.T) { } // The subsequent calls to IsReady must succeed and return true - for i := 0; i < 5; i++ { + for range 5 { if ok, err = prober.IsReady(context.Background(), ing); err != nil { t.Fatal("IsReady failed:", err) } diff --git a/pkg/testing/status/fake_test.go b/pkg/testing/status/fake_test.go index 8deb1d58b..2bf7fcebf 100644 --- a/pkg/testing/status/fake_test.go +++ b/pkg/testing/status/fake_test.go @@ -34,11 +34,11 @@ func TestIsReadyCallCount(t *testing.T) { ingress2 := v1alpha1.Ingress{ObjectMeta: metav1.ObjectMeta{Namespace: "ns2", Name: "name2"}} ingress3 := v1alpha1.Ingress{ObjectMeta: metav1.ObjectMeta{Namespace: "ns3", Name: "name3"}} - for i := 0; i < 10; i++ { + for range 10 { statusManager.IsReady(context.Background(), &ingress1) } - for i := 0; i < 5; i++ { + for range 5 { statusManager.IsReady(context.Background(), &ingress2) } diff --git a/test/conformance/ingress/class.go b/test/conformance/ingress/class.go index d233c2308..c90999d6b 100644 --- a/test/conformance/ingress/class.go +++ b/test/conformance/ingress/class.go @@ -60,7 +60,6 @@ func TestIngressClass(t *testing.T) { }} for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() @@ -70,7 +69,8 @@ func TestIngressClass(t *testing.T) { } func verifyIngressWithAnnotations(ctx context.Context, t *testing.T, clients *test.Clients, - annotations map[string]string, backend *v1alpha1.IngressBackend) { + annotations map[string]string, backend *v1alpha1.IngressBackend, +) { t.Helper() // createIngress internally sets hooks to delete the ingress, diff --git a/test/conformance/ingress/grpc.go b/test/conformance/ingress/grpc.go index 27cbcfd22..f95333953 100644 --- a/test/conformance/ingress/grpc.go +++ b/test/conformance/ingress/grpc.go @@ -85,7 +85,7 @@ func TestGRPC(t *testing.T) { t.Fatal("PingStream() =", err) } - for i := 0; i < 100; i++ { + for range 100 { checkGRPCRoundTrip(t, stream, suffix) } } @@ -151,7 +151,7 @@ func TestGRPCSplit(t *testing.T) { const maxRequests = 100 got := sets.New[string]() - for i := 0; i < maxRequests; i++ { + for range maxRequests { stream, err := pc.PingStream(ctx) if err != nil { t.Error("PingStream() =", err) @@ -164,7 +164,7 @@ func TestGRPCSplit(t *testing.T) { } got.Insert(suffix) - for j := 0; j < 10; j++ { + for range 10 { checkGRPCRoundTrip(t, stream, suffix) } diff --git a/test/conformance/ingress/headers.go b/test/conformance/ingress/headers.go index 8e9712159..e1a90d323 100644 --- a/test/conformance/ingress/headers.go +++ b/test/conformance/ingress/headers.go @@ -18,6 +18,7 @@ package ingress import ( "context" + "encoding/hex" "fmt" "net/http" "testing" @@ -71,7 +72,7 @@ func TestProbeHeaders(t *testing.T) { }{{ name: "kingress generates hash", req: header.HashValueOverride, - want: fmt.Sprintf("%x", bytes), + want: hex.EncodeToString(bytes[:]), }, { name: "request overrides hash", req: "2701a1b241db6af811992c57a5e11171847148ac3d2e1a8cc992a62f9e4fa111", // random hash to override. @@ -286,7 +287,7 @@ func TestPostSplitSetHeaders(t *testing.T) { backends := make([]v1alpha1.IngressBackendSplit, 0, splits) names := make(sets.Set[string], splits) - for i := 0; i < splits; i++ { + for range splits { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) backends = append(backends, v1alpha1.IngressBackendSplit{ IngressBackend: v1alpha1.IngressBackend{ @@ -325,7 +326,7 @@ func TestPostSplitSetHeaders(t *testing.T) { // but don't check the distribution of requests, as that isn't the point of this // particular test. seen := make(sets.Set[string], len(names)) - for i := 0; i < maxRequests; i++ { + for range maxRequests { ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain) if ri == nil { return @@ -348,7 +349,7 @@ func TestPostSplitSetHeaders(t *testing.T) { // but don't check the distribution of requests, as that isn't the point of this // particular test. seen := make(sets.Set[string], len(names)) - for i := 0; i < maxRequests; i++ { + for range maxRequests { ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain, func(req *http.Request) { // Specify a value for the header to verify that implementations // use set vs. append semantics. diff --git a/test/conformance/ingress/path.go b/test/conformance/ingress/path.go index 101aeeb34..32a6dc7d1 100644 --- a/test/conformance/ingress/path.go +++ b/test/conformance/ingress/path.go @@ -215,7 +215,7 @@ func TestPathAndPercentageSplit(t *testing.T) { var g errgroup.Group g.SetLimit(8) - for i := 0; i < total; i++ { + for range total { g.Go(func() error { ri := RuntimeRequest(ctx, t, client, "http://"+name+"."+test.NetworkingFlags.ServiceDomain+"/foo") if ri == nil { diff --git a/test/conformance/ingress/percentage.go b/test/conformance/ingress/percentage.go index 228a0fe55..8eea6e710 100644 --- a/test/conformance/ingress/percentage.go +++ b/test/conformance/ingress/percentage.go @@ -44,7 +44,7 @@ func TestPercentage(t *testing.T) { // Double the percentage of the split each iteration until it would overflow, and then // give the last route the remainder. percent, total := 1, 0 - for i := 0; i < 10; i++ { + for range 10 { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) backends = append(backends, v1alpha1.IngressBackendSplit{ IngressBackend: v1alpha1.IngressBackend{ diff --git a/test/conformance/ingress/update.go b/test/conformance/ingress/update.go index 9fb2ac28f..1422d2332 100644 --- a/test/conformance/ingress/update.go +++ b/test/conformance/ingress/update.go @@ -80,7 +80,7 @@ func TestUpdate(t *testing.T) { time.Sleep(1 * time.Second) // First test with only sentinel changes. - for i := 0; i < 10; i++ { + for range 10 { sentinel := test.ObjectNameForTest(t) t.Logf("Rolling out %q w/ %q", firstName, sentinel) @@ -122,7 +122,7 @@ func TestUpdate(t *testing.T) { t.Logf("Tearing down %q", firstName) firstCancel() } - for i := 0; i < 10; i++ { + for range 10 { sentinel := test.ObjectNameForTest(t) nextName, nextPort, nextCancel := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) diff --git a/test/conformance/ingress/util.go b/test/conformance/ingress/util.go index b8226f22d..a9411ec00 100644 --- a/test/conformance/ingress/util.go +++ b/test/conformance/ingress/util.go @@ -146,7 +146,8 @@ func CreateRuntimeService(ctx context.Context, t *testing.T, clients *test.Clien Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -270,19 +271,23 @@ func CreateProxyService(ctx context.Context, t *testing.T, clients *test.Clients Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } if caSecretName := os.Getenv("UPSTREAM_CA_CERT"); caSecretName != "" { pod = PodWithOption(pod, - WithEnv([]corev1.EnvVar{{Name: "CA_CERT", Value: caCertPath}, - {Name: "SERVER_NAME", Value: os.Getenv("SERVER_NAME")}}...), + WithEnv([]corev1.EnvVar{ + {Name: "CA_CERT", Value: caCertPath}, + {Name: "SERVER_NAME", Value: os.Getenv("SERVER_NAME")}, + }...), WithVolume("ca-certs", caCertDirectory, corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ SecretName: caSecretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -372,7 +377,8 @@ func CreateTimeoutService(ctx context.Context, t *testing.T, clients *test.Clien Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -459,7 +465,8 @@ func CreateWebsocketService(ctx context.Context, t *testing.T, clients *test.Cli Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -544,7 +551,8 @@ func CreateGRPCService(ctx context.Context, t *testing.T, clients *test.Clients, Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -626,7 +634,8 @@ func CreateRetryService(ctx context.Context, t *testing.T, clients *test.Clients Secret: &corev1.SecretVolumeSource{ SecretName: secretName, Optional: ptr.Bool(false), - }}), + }, + }), ) } @@ -1075,7 +1084,7 @@ func CreateDialContext(ctx context.Context, t *testing.T, ing *v1alpha1.Ingress, return nil, err } for _, sp := range svc.Spec.Ports { - if fmt.Sprint(sp.Port) == port { + if strconv.Itoa(int(sp.Port)) == port { return dial(ctx, "tcp", fmt.Sprintf("%s:%d", pkgTest.Flags.IngressEndpoint, sp.NodePort)) } } @@ -1116,8 +1125,10 @@ func CreateDialContext(ctx context.Context, t *testing.T, ing *v1alpha1.Ingress, return nil // Unreachable } -type RequestOption func(*http.Request) -type ResponseExpectation func(response *http.Response) error +type ( + RequestOption func(*http.Request) + ResponseExpectation func(response *http.Response) error +) func RuntimeRequest(ctx context.Context, t *testing.T, client *http.Client, url string, opts ...RequestOption) *types.RuntimeInfo { return RuntimeRequestWithExpectations(ctx, t, client, url, @@ -1132,7 +1143,8 @@ func RuntimeRequest(ctx context.Context, t *testing.T, client *http.Client, url func RuntimeRequestWithExpectations(ctx context.Context, t *testing.T, client *http.Client, url string, responseExpectations []ResponseExpectation, allowDialError bool, - opts ...RequestOption) *types.RuntimeInfo { + opts ...RequestOption, +) *types.RuntimeInfo { t.Helper() req, err := http.NewRequest(http.MethodGet, url, nil) @@ -1146,7 +1158,6 @@ func RuntimeRequestWithExpectations(ctx context.Context, t *testing.T, client *h } resp, err := client.Do(req) - if err != nil { if !allowDialError || !IsDialError(err) { t.Error("Error making GET request:", err) diff --git a/test/conformance/ingress/visibility.go b/test/conformance/ingress/visibility.go index b673a22ee..42063b468 100644 --- a/test/conformance/ingress/visibility.go +++ b/test/conformance/ingress/visibility.go @@ -40,7 +40,7 @@ func TestVisibility(t *testing.T) { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) // Generate a different hostname for each of these tests, so that they do not fail when run concurrently. - var privateHostNames = map[string]string{ + privateHostNames := map[string]string{ "fqdn": test.ObjectNameForTest(t) + "." + test.ServingNamespace + ".svc." + test.NetworkingFlags.ClusterSuffix, "short": test.ObjectNameForTest(t) + "." + test.ServingNamespace + ".svc", "shortest": test.ObjectNameForTest(t) + "." + test.ServingNamespace, @@ -121,7 +121,7 @@ func TestVisibilitySplit(t *testing.T) { // Double the percentage of the split each iteration until it would overflow, and then // give the last route the remainder. percent, total := 1, 0 - for i := 0; i < 10; i++ { + for range 10 { name, port, _ := CreateRuntimeService(ctx, t, clients, networking.ServicePortNameHTTP1) backends = append(backends, v1alpha1.IngressBackendSplit{ IngressBackend: v1alpha1.IngressBackend{ @@ -364,16 +364,13 @@ func TestVisibilityPath(t *testing.T) { t.Run(path, func(t *testing.T) { t.Parallel() - //nolint:all ri := RuntimeRequest(ctx, t, client, "http://"+publicHostName+path) if ri == nil { return } - //nolint:all got := ri.Request.Headers.Get(headerName) - //nolint:all if got != want { t.Errorf("Header[%q] = %q, wanted %q", headerName, got, want) } diff --git a/test/conformance/ingress/websocket.go b/test/conformance/ingress/websocket.go index dbf0c2338..7fd757af6 100644 --- a/test/conformance/ingress/websocket.go +++ b/test/conformance/ingress/websocket.go @@ -70,13 +70,14 @@ func TestWebsocket(t *testing.T) { } u := url.URL{Scheme: "ws", Host: domain, Path: "/"} + //nolint:bodyclose conn, _, err := dialer.Dial(u.String(), http.Header{"Host": {domain}}) if err != nil { t.Fatal("Dial() =", err) } defer conn.Close() - for i := 0; i < 100; i++ { + for range 100 { checkWebsocketRoundTrip(t, conn, suffix) } } @@ -133,7 +134,8 @@ func TestWebsocketSplit(t *testing.T) { const maxRequests = 100 got := sets.New[string]() - for i := 0; i < maxRequests; i++ { + for range maxRequests { + //nolint:bodyclose conn, _, err := dialer.Dial(u.String(), http.Header{"Host": {domain}}) if err != nil { t.Fatal("Dial() =", err) @@ -146,7 +148,7 @@ func TestWebsocketSplit(t *testing.T) { } got.Insert(suffix) - for j := 0; j < 10; j++ { + for range 10 { checkWebsocketRoundTrip(t, conn, suffix) } diff --git a/test/test_images/httpproxy/httpproxy.go b/test/test_images/httpproxy/httpproxy.go index 385dbd3a4..d4be3a5c9 100644 --- a/test/test_images/httpproxy/httpproxy.go +++ b/test/test_images/httpproxy/httpproxy.go @@ -18,17 +18,16 @@ package main import ( "context" + "crypto/tls" + "crypto/x509" "errors" "flag" "log" "net" - "os" - - "crypto/tls" - "crypto/x509" "net/http" "net/http/httputil" "net/url" + "os" "github.com/rs/dnscache" "knative.dev/networking/pkg/http/probe" diff --git a/test/test_images/runtime/handlers/cgroup.go b/test/test_images/runtime/handlers/cgroup.go index 2eb57776e..c0b99f048 100644 --- a/test/test_images/runtime/handlers/cgroup.go +++ b/test/test_images/runtime/handlers/cgroup.go @@ -30,7 +30,8 @@ var cgroupPaths = []string{ "/sys/fs/cgroup/memory/memory.limit_in_bytes", "/sys/fs/cgroup/cpu/cpu.cfs_period_us", "/sys/fs/cgroup/cpu/cpu.cfs_quota_us", - "/sys/fs/cgroup/cpu/cpu.shares"} + "/sys/fs/cgroup/cpu/cpu.shares", +} var ( yes = true @@ -60,7 +61,7 @@ func cgroups(paths ...string) []*types.Cgroup { // Try to write to the Cgroup. We expect this to fail as a cheap // method for read-only validation newValue := []byte{'9'} - err = os.WriteFile(path, newValue, 0644) + err = os.WriteFile(path, newValue, 0o644) if err != nil { cgroups = append(cgroups, &types.Cgroup{Name: path, Value: &ic, ReadOnly: &yes}) } else { diff --git a/test/test_images/runtime/handlers/file.go b/test/test_images/runtime/handlers/file.go index ff42241c8..b5275c555 100644 --- a/test/test_images/runtime/handlers/file.go +++ b/test/test_images/runtime/handlers/file.go @@ -44,7 +44,8 @@ func fileInfo(paths ...string) map[string]types.FileInfo { Perm: perm, ModTime: file.ModTime(), SourceFile: source, - IsDir: &dir} + IsDir: &dir, + } } return files } diff --git a/test/test_images/runtime/handlers/mount.go b/test/test_images/runtime/handlers/mount.go index 03be30b48..55a83e44e 100644 --- a/test/test_images/runtime/handlers/mount.go +++ b/test/test_images/runtime/handlers/mount.go @@ -46,7 +46,8 @@ func mounts() []*types.Mount { Device: ms[0], Path: ms[1], Type: ms[2], - Options: strings.Split(ms[3], ",")}) + Options: strings.Split(ms[3], ","), + }) } if err := sc.Err(); err != nil { diff --git a/test/test_images/runtime/handlers/runtime.go b/test/test_images/runtime/handlers/runtime.go index 94820311e..85f98a791 100644 --- a/test/test_images/runtime/handlers/runtime.go +++ b/test/test_images/runtime/handlers/runtime.go @@ -45,7 +45,8 @@ func runtimeHandler(w http.ResponseWriter, r *http.Request) { k := &types.RuntimeInfo{ Request: requestInfo(r), - Host: &types.HostInfo{EnvVars: env(), + Host: &types.HostInfo{ + EnvVars: env(), Files: fileInfo(filePaths...), FileAccess: fileAccessAttempt(excludeFilePaths(filePaths, fileAccessExclusions)...), Cgroups: cgroups(cgroupPaths...), diff --git a/test/test_images/runtime/main.go b/test/test_images/runtime/main.go index 309a5d9f4..2bf522e18 100644 --- a/test/test_images/runtime/main.go +++ b/test/test_images/runtime/main.go @@ -40,8 +40,10 @@ func main() { args := flag.Args() if len(args) > 0 && args[0] == "probe" { url := "http://localhost:" + port - if _, err := http.Get(url); err != nil { + if resp, err := http.Get(url); err != nil { log.Fatal("Failed to probe ", err) + } else { + resp.Body.Close() } return } From da5fcf6216ad814861888226e172fb30cc9ac862 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 23:10:51 -0500 Subject: [PATCH 4/5] address remaining linter changes --- .golangci.yaml | 2 -- .../networking/v1alpha1/ingress_helpers.go | 4 +-- pkg/deprecated_header.go | 2 +- pkg/http/header/header.go | 2 +- pkg/status/status.go | 31 ++++++++++--------- pkg/status/status_test.go | 2 +- test/conformance/ingress/grpc.go | 4 +-- test/conformance/ingress/headers.go | 2 -- test/conformance/ingress/path.go | 1 - test/conformance/ingress/timeout.go | 1 - test/prober.go | 8 ++--- 11 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 5fbed11c9..9c69b83ac 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -30,8 +30,6 @@ issues: text: "ifElseChain" linters-settings: - intrange: - severity: warning gomodguard: blocked: modules: diff --git a/pkg/apis/networking/v1alpha1/ingress_helpers.go b/pkg/apis/networking/v1alpha1/ingress_helpers.go index f3e015b05..fa77c3c6e 100644 --- a/pkg/apis/networking/v1alpha1/ingress_helpers.go +++ b/pkg/apis/networking/v1alpha1/ingress_helpers.go @@ -27,13 +27,13 @@ import ( func (i *Ingress) GetIngressTLSForVisibility(visibility IngressVisibility) []IngressTLS { ingressTLS := make([]IngressTLS, 0, len(i.Spec.TLS)) - if i.Spec.TLS == nil || len(i.Spec.TLS) == 0 { + if len(i.Spec.TLS) == 0 { return ingressTLS } for _, rule := range i.Spec.Rules { if rule.Visibility == visibility { - if rule.Hosts == nil || len(rule.Hosts) == 0 { + if len(rule.Hosts) == 0 { return ingressTLS } diff --git a/pkg/deprecated_header.go b/pkg/deprecated_header.go index c2e98c2c3..ce7d3059d 100644 --- a/pkg/deprecated_header.go +++ b/pkg/deprecated_header.go @@ -67,7 +67,7 @@ const ( // different user-agent. So we augment the probes with this header. // // Deprecated: use knative.dev/networking/pkg/http/header.KubeletProbeKey - KubeletProbeHeaderName = header.KubeletProbeKey + KubeletProbeHeaderName = header.KubeletProbeKey //nolint:staticheck // UserAgentKey is the constant for header "User-Agent". // diff --git a/pkg/http/header/header.go b/pkg/http/header/header.go index 143f8bedb..6a8265d6a 100644 --- a/pkg/http/header/header.go +++ b/pkg/http/header/header.go @@ -59,7 +59,7 @@ const ( // Prior to this deprecation, Istio with mTLS rewrote probes and their probes passed a // different user-agent. Therefore, this header was added to augment the probes. // - // Deprecated: this custom request header is no longer necessary since Istio now propagates the + // This custom request header is no longer necessary since Istio now propagates the // original request header `User-Agent` sent by the kubelet (e.g., User-Agent: kube-probe/1.29). // For updated usage, please utilize knative.dev/networking/pkg/http/header.UserAgentKey and // knative.dev/networking/pkg/http/header.KubeProbeUAPrefix diff --git a/pkg/status/status.go b/pkg/status/status.go index ca0315632..4d7ebe515 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -29,9 +29,9 @@ import ( "reflect" "strconv" "sync" + "sync/atomic" "time" - "go.uber.org/atomic" "go.uber.org/zap" "golang.org/x/time/rate" @@ -78,7 +78,7 @@ type ingressState struct { ing *v1alpha1.Ingress // pendingCount is the number of pods that haven't been successfully probed yet - pendingCount atomic.Int32 + pendingCount atomic.Int64 lastAccessed time.Time cancel func() @@ -87,7 +87,7 @@ type ingressState struct { // podState represents the probing state of a Pod (for a specific Ingress) type podState struct { // pendingCount is the number of probes for the Pod - pendingCount atomic.Int32 + pendingCount atomic.Int64 cancel func() } @@ -137,7 +137,7 @@ type Prober struct { ingressStates map[types.NamespacedName]*ingressState podContexts map[string]cancelContext - workQueue workqueue.RateLimitingInterface + workQueue workqueue.TypedRateLimitingInterface[any] targetLister ProbeTargetLister @@ -157,11 +157,11 @@ func NewProber( ingressStates: make(map[types.NamespacedName]*ingressState), podContexts: make(map[string]cancelContext), workQueue: workqueue.NewNamedRateLimitingQueue( - workqueue.NewMaxOfRateLimiter( + workqueue.NewTypedMaxOfRateLimiter( // Per item exponential backoff - workqueue.NewItemExponentialFailureRateLimiter(50*time.Millisecond, probeMaxRetryDelay), + workqueue.NewTypedItemExponentialFailureRateLimiter[any](50*time.Millisecond, probeMaxRetryDelay), // Global rate limiter - &workqueue.BucketRateLimiter{Limiter: rate.NewLimiter(rate.Limit(50), 100)}, + &workqueue.TypedBucketRateLimiter[any]{Limiter: rate.NewLimiter(rate.Limit(50), 100)}, ), "ProbingQueue"), targetLister: targetLister, @@ -231,7 +231,7 @@ func (m *Prober) IsReady(ctx context.Context, ing *v1alpha1.Ingress) (bool, erro } } - ingressState.pendingCount.Store(int32(len(workItems))) + ingressState.pendingCount.Store(int64(len(workItems))) for ip, ipWorkItems := range workItems { // Get or create the context for that IP @@ -252,10 +252,11 @@ func (m *Prober) IsReady(ctx context.Context, ing *v1alpha1.Ingress) (bool, erro podCtx, cancel := context.WithCancel(ingCtx) podState := &podState{ - pendingCount: *atomic.NewInt32(int32(len(ipWorkItems))), - cancel: cancel, + cancel: cancel, } + podState.pendingCount.Store(int64(len(ipWorkItems))) + // Quick and dirty way to join two contexts (i.e. podCtx is cancelled when either ingCtx or ipCtx are cancelled) go func() { select { @@ -277,7 +278,7 @@ func (m *Prober) IsReady(ctx context.Context, ing *v1alpha1.Ingress) (bool, erro for _, wi := range ipWorkItems { wi.podState = podState - wi.context = podCtx + wi.context = podCtx //nolint:fatcontext m.workQueue.AddAfter(wi, initialDelay) logger.Infof("Queuing probe for %s, IP: %s:%s (depth: %d)", wi.url, wi.podIP, wi.podPort, m.workQueue.Len()) @@ -427,12 +428,12 @@ func (m *Prober) processWorkItem() bool { func (m *Prober) onProbingSuccess(ingressState *ingressState, podState *podState) { // The last probe call for the Pod succeeded, the Pod is ready - if podState.pendingCount.Dec() == 0 { + if podState.pendingCount.Add(-1) == 0 { // Unlock the goroutine blocked on <-podCtx.Done() podState.cancel() // This is the last pod being successfully probed, the Ingress is ready - if ingressState.pendingCount.Dec() == 0 { + if ingressState.pendingCount.Add(-1) == 0 { m.readyCallback(ingressState.ing) } } @@ -447,9 +448,9 @@ func (m *Prober) onProbingCancellation(ingressState *ingressState, podState *pod } // Attempt to set pendingCount to 0. - if podState.pendingCount.CAS(pendingCount, 0) { + if podState.pendingCount.CompareAndSwap(pendingCount, 0) { // This is the last pod being successfully probed, the Ingress is ready - if ingressState.pendingCount.Dec() == 0 { + if ingressState.pendingCount.Add(-1) == 0 { m.readyCallback(ingressState.ing) } return diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index 9051446fa..c8d89592e 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -24,6 +24,7 @@ import ( "net/url" "strconv" "strings" + "sync/atomic" "testing" "time" @@ -33,7 +34,6 @@ import ( "knative.dev/networking/pkg/http/probe" "knative.dev/networking/pkg/ingress" - "go.uber.org/atomic" "go.uber.org/zap/zaptest" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/conformance/ingress/grpc.go b/test/conformance/ingress/grpc.go index f95333953..4f0b51cc1 100644 --- a/test/conformance/ingress/grpc.go +++ b/test/conformance/ingress/grpc.go @@ -64,7 +64,7 @@ func TestGRPC(t *testing.T) { }}, }) - conn, err := grpc.Dial( + conn, err := grpc.NewClient( domain+":80", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) { @@ -133,7 +133,7 @@ func TestGRPCSplit(t *testing.T) { }}, }) - conn, err := grpc.Dial( + conn, err := grpc.NewClient( domain+":80", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) { diff --git a/test/conformance/ingress/headers.go b/test/conformance/ingress/headers.go index e1a90d323..762e93442 100644 --- a/test/conformance/ingress/headers.go +++ b/test/conformance/ingress/headers.go @@ -80,7 +80,6 @@ func TestProbeHeaders(t *testing.T) { }} for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -187,7 +186,6 @@ func TestTagHeaders(t *testing.T) { }} for _, tt := range tests { - tt := tt t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/test/conformance/ingress/path.go b/test/conformance/ingress/path.go index 32a6dc7d1..3f66e8631 100644 --- a/test/conformance/ingress/path.go +++ b/test/conformance/ingress/path.go @@ -127,7 +127,6 @@ func TestPath(t *testing.T) { } for path, want := range tests { - path, want := path, want t.Run(path, func(t *testing.T) { t.Parallel() diff --git a/test/conformance/ingress/timeout.go b/test/conformance/ingress/timeout.go index ddeff9b6a..6484ef0e2 100644 --- a/test/conformance/ingress/timeout.go +++ b/test/conformance/ingress/timeout.go @@ -75,7 +75,6 @@ func TestTimeout(t *testing.T) { }} for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/test/prober.go b/test/prober.go index 493271628..ef0206b8e 100644 --- a/test/prober.go +++ b/test/prober.go @@ -24,9 +24,9 @@ import ( "net/http" "net/url" "sync" + "sync/atomic" "testing" - "go.uber.org/atomic" "golang.org/x/sync/errgroup" pkgTest "knative.dev/pkg/test" @@ -158,16 +158,16 @@ func (m *manager) Spawn(url *url.URL) Prober { return nil default: res, err := client.Do(req) - if p.requests.Inc() == p.minimumProbes { + if p.requests.Add(1) == p.minimumProbes { close(p.minDoneCh) } if err != nil { p.logf("%q error: %v", p.url, err) - p.failures.Inc() + p.failures.Add(1) } else if res.StatusCode != http.StatusOK { p.logf("%q status = %d, want: %d", p.url, res.StatusCode, http.StatusOK) p.logf("Response: %s", res) - p.failures.Inc() + p.failures.Add(1) } } } From 4957ba206fd0c38284537431f60f6c1e00c6c573 Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 9 Jan 2025 23:21:23 -0500 Subject: [PATCH 5/5] run ./hack/update-deps.sh --- go.mod | 1 - go.sum | 2 - vendor/go.uber.org/atomic/.codecov.yml | 19 ---- vendor/go.uber.org/atomic/.gitignore | 15 --- vendor/go.uber.org/atomic/CHANGELOG.md | 100 ------------------- vendor/go.uber.org/atomic/LICENSE.txt | 19 ---- vendor/go.uber.org/atomic/Makefile | 79 --------------- vendor/go.uber.org/atomic/README.md | 63 ------------ vendor/go.uber.org/atomic/bool.go | 81 ---------------- vendor/go.uber.org/atomic/bool_ext.go | 53 ---------- vendor/go.uber.org/atomic/doc.go | 23 ----- vendor/go.uber.org/atomic/duration.go | 82 ---------------- vendor/go.uber.org/atomic/duration_ext.go | 40 -------- vendor/go.uber.org/atomic/error.go | 51 ---------- vendor/go.uber.org/atomic/error_ext.go | 39 -------- vendor/go.uber.org/atomic/float64.go | 77 --------------- vendor/go.uber.org/atomic/float64_ext.go | 69 ------------- vendor/go.uber.org/atomic/gen.go | 27 ------ vendor/go.uber.org/atomic/int32.go | 102 -------------------- vendor/go.uber.org/atomic/int64.go | 102 -------------------- vendor/go.uber.org/atomic/nocmp.go | 35 ------- vendor/go.uber.org/atomic/string.go | 54 ----------- vendor/go.uber.org/atomic/string_ext.go | 45 --------- vendor/go.uber.org/atomic/time.go | 55 ----------- vendor/go.uber.org/atomic/time_ext.go | 36 ------- vendor/go.uber.org/atomic/uint32.go | 102 -------------------- vendor/go.uber.org/atomic/uint64.go | 102 -------------------- vendor/go.uber.org/atomic/uintptr.go | 102 -------------------- vendor/go.uber.org/atomic/unsafe_pointer.go | 58 ----------- vendor/go.uber.org/atomic/value.go | 31 ------ vendor/modules.txt | 3 - 31 files changed, 1667 deletions(-) delete mode 100644 vendor/go.uber.org/atomic/.codecov.yml delete mode 100644 vendor/go.uber.org/atomic/.gitignore delete mode 100644 vendor/go.uber.org/atomic/CHANGELOG.md delete mode 100644 vendor/go.uber.org/atomic/LICENSE.txt delete mode 100644 vendor/go.uber.org/atomic/Makefile delete mode 100644 vendor/go.uber.org/atomic/README.md delete mode 100644 vendor/go.uber.org/atomic/bool.go delete mode 100644 vendor/go.uber.org/atomic/bool_ext.go delete mode 100644 vendor/go.uber.org/atomic/doc.go delete mode 100644 vendor/go.uber.org/atomic/duration.go delete mode 100644 vendor/go.uber.org/atomic/duration_ext.go delete mode 100644 vendor/go.uber.org/atomic/error.go delete mode 100644 vendor/go.uber.org/atomic/error_ext.go delete mode 100644 vendor/go.uber.org/atomic/float64.go delete mode 100644 vendor/go.uber.org/atomic/float64_ext.go delete mode 100644 vendor/go.uber.org/atomic/gen.go delete mode 100644 vendor/go.uber.org/atomic/int32.go delete mode 100644 vendor/go.uber.org/atomic/int64.go delete mode 100644 vendor/go.uber.org/atomic/nocmp.go delete mode 100644 vendor/go.uber.org/atomic/string.go delete mode 100644 vendor/go.uber.org/atomic/string_ext.go delete mode 100644 vendor/go.uber.org/atomic/time.go delete mode 100644 vendor/go.uber.org/atomic/time_ext.go delete mode 100644 vendor/go.uber.org/atomic/uint32.go delete mode 100644 vendor/go.uber.org/atomic/uint64.go delete mode 100644 vendor/go.uber.org/atomic/uintptr.go delete mode 100644 vendor/go.uber.org/atomic/unsafe_pointer.go delete mode 100644 vendor/go.uber.org/atomic/value.go diff --git a/go.mod b/go.mod index c77697d18..dd5cc57bf 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.1 github.com/rs/dnscache v0.0.0-20230804202142-fc85eb664529 - go.uber.org/atomic v1.9.0 go.uber.org/zap v1.27.0 golang.org/x/sync v0.10.0 golang.org/x/time v0.6.0 diff --git a/go.sum b/go.sum index 1f6e4010e..b7861e707 100644 --- a/go.sum +++ b/go.sum @@ -330,8 +330,6 @@ go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= diff --git a/vendor/go.uber.org/atomic/.codecov.yml b/vendor/go.uber.org/atomic/.codecov.yml deleted file mode 100644 index 571116cc3..000000000 --- a/vendor/go.uber.org/atomic/.codecov.yml +++ /dev/null @@ -1,19 +0,0 @@ -coverage: - range: 80..100 - round: down - precision: 2 - - status: - project: # measuring the overall project coverage - default: # context, you can create multiple ones with custom titles - enabled: yes # must be yes|true to enable this status - target: 100 # specify the target coverage for each commit status - # option: "auto" (must increase from parent commit or pull request base) - # option: "X%" a static target percentage to hit - if_not_found: success # if parent is not found report status as success, error, or failure - if_ci_failed: error # if ci fails report status as success, error, or failure - -# Also update COVER_IGNORE_PKGS in the Makefile. -ignore: - - /internal/gen-atomicint/ - - /internal/gen-valuewrapper/ diff --git a/vendor/go.uber.org/atomic/.gitignore b/vendor/go.uber.org/atomic/.gitignore deleted file mode 100644 index 2e337a0ed..000000000 --- a/vendor/go.uber.org/atomic/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/bin -.DS_Store -/vendor -cover.html -cover.out -lint.log - -# Binaries -*.test - -# Profiling output -*.prof - -# Output of fossa analyzer -/fossa diff --git a/vendor/go.uber.org/atomic/CHANGELOG.md b/vendor/go.uber.org/atomic/CHANGELOG.md deleted file mode 100644 index 38f564e2b..000000000 --- a/vendor/go.uber.org/atomic/CHANGELOG.md +++ /dev/null @@ -1,100 +0,0 @@ -# Changelog -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [1.9.0] - 2021-07-15 -### Added -- Add `Float64.Swap` to match int atomic operations. -- Add `atomic.Time` type for atomic operations on `time.Time` values. - -[1.9.0]: https://github.com/uber-go/atomic/compare/v1.8.0...v1.9.0 - -## [1.8.0] - 2021-06-09 -### Added -- Add `atomic.Uintptr` type for atomic operations on `uintptr` values. -- Add `atomic.UnsafePointer` type for atomic operations on `unsafe.Pointer` values. - -[1.8.0]: https://github.com/uber-go/atomic/compare/v1.7.0...v1.8.0 - -## [1.7.0] - 2020-09-14 -### Added -- Support JSON serialization and deserialization of primitive atomic types. -- Support Text marshalling and unmarshalling for string atomics. - -### Changed -- Disallow incorrect comparison of atomic values in a non-atomic way. - -### Removed -- Remove dependency on `golang.org/x/{lint, tools}`. - -[1.7.0]: https://github.com/uber-go/atomic/compare/v1.6.0...v1.7.0 - -## [1.6.0] - 2020-02-24 -### Changed -- Drop library dependency on `golang.org/x/{lint, tools}`. - -[1.6.0]: https://github.com/uber-go/atomic/compare/v1.5.1...v1.6.0 - -## [1.5.1] - 2019-11-19 -- Fix bug where `Bool.CAS` and `Bool.Toggle` do work correctly together - causing `CAS` to fail even though the old value matches. - -[1.5.1]: https://github.com/uber-go/atomic/compare/v1.5.0...v1.5.1 - -## [1.5.0] - 2019-10-29 -### Changed -- With Go modules, only the `go.uber.org/atomic` import path is supported now. - If you need to use the old import path, please add a `replace` directive to - your `go.mod`. - -[1.5.0]: https://github.com/uber-go/atomic/compare/v1.4.0...v1.5.0 - -## [1.4.0] - 2019-05-01 -### Added - - Add `atomic.Error` type for atomic operations on `error` values. - -[1.4.0]: https://github.com/uber-go/atomic/compare/v1.3.2...v1.4.0 - -## [1.3.2] - 2018-05-02 -### Added -- Add `atomic.Duration` type for atomic operations on `time.Duration` values. - -[1.3.2]: https://github.com/uber-go/atomic/compare/v1.3.1...v1.3.2 - -## [1.3.1] - 2017-11-14 -### Fixed -- Revert optimization for `atomic.String.Store("")` which caused data races. - -[1.3.1]: https://github.com/uber-go/atomic/compare/v1.3.0...v1.3.1 - -## [1.3.0] - 2017-11-13 -### Added -- Add `atomic.Bool.CAS` for compare-and-swap semantics on bools. - -### Changed -- Optimize `atomic.String.Store("")` by avoiding an allocation. - -[1.3.0]: https://github.com/uber-go/atomic/compare/v1.2.0...v1.3.0 - -## [1.2.0] - 2017-04-12 -### Added -- Shadow `atomic.Value` from `sync/atomic`. - -[1.2.0]: https://github.com/uber-go/atomic/compare/v1.1.0...v1.2.0 - -## [1.1.0] - 2017-03-10 -### Added -- Add atomic `Float64` type. - -### Changed -- Support new `go.uber.org/atomic` import path. - -[1.1.0]: https://github.com/uber-go/atomic/compare/v1.0.0...v1.1.0 - -## [1.0.0] - 2016-07-18 - -- Initial release. - -[1.0.0]: https://github.com/uber-go/atomic/releases/tag/v1.0.0 diff --git a/vendor/go.uber.org/atomic/LICENSE.txt b/vendor/go.uber.org/atomic/LICENSE.txt deleted file mode 100644 index 8765c9fbc..000000000 --- a/vendor/go.uber.org/atomic/LICENSE.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2016 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/go.uber.org/atomic/Makefile b/vendor/go.uber.org/atomic/Makefile deleted file mode 100644 index 46c945b32..000000000 --- a/vendor/go.uber.org/atomic/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# Directory to place `go install`ed binaries into. -export GOBIN ?= $(shell pwd)/bin - -GOLINT = $(GOBIN)/golint -GEN_ATOMICINT = $(GOBIN)/gen-atomicint -GEN_ATOMICWRAPPER = $(GOBIN)/gen-atomicwrapper -STATICCHECK = $(GOBIN)/staticcheck - -GO_FILES ?= $(shell find . '(' -path .git -o -path vendor ')' -prune -o -name '*.go' -print) - -# Also update ignore section in .codecov.yml. -COVER_IGNORE_PKGS = \ - go.uber.org/atomic/internal/gen-atomicint \ - go.uber.org/atomic/internal/gen-atomicwrapper - -.PHONY: build -build: - go build ./... - -.PHONY: test -test: - go test -race ./... - -.PHONY: gofmt -gofmt: - $(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX)) - gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true - @[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" && cat $(FMT_LOG) && false) - -$(GOLINT): - cd tools && go install golang.org/x/lint/golint - -$(STATICCHECK): - cd tools && go install honnef.co/go/tools/cmd/staticcheck - -$(GEN_ATOMICWRAPPER): $(wildcard ./internal/gen-atomicwrapper/*) - go build -o $@ ./internal/gen-atomicwrapper - -$(GEN_ATOMICINT): $(wildcard ./internal/gen-atomicint/*) - go build -o $@ ./internal/gen-atomicint - -.PHONY: golint -golint: $(GOLINT) - $(GOLINT) ./... - -.PHONY: staticcheck -staticcheck: $(STATICCHECK) - $(STATICCHECK) ./... - -.PHONY: lint -lint: gofmt golint staticcheck generatenodirty - -# comma separated list of packages to consider for code coverage. -COVER_PKG = $(shell \ - go list -find ./... | \ - grep -v $(foreach pkg,$(COVER_IGNORE_PKGS),-e "^$(pkg)$$") | \ - paste -sd, -) - -.PHONY: cover -cover: - go test -coverprofile=cover.out -coverpkg $(COVER_PKG) -v ./... - go tool cover -html=cover.out -o cover.html - -.PHONY: generate -generate: $(GEN_ATOMICINT) $(GEN_ATOMICWRAPPER) - go generate ./... - -.PHONY: generatenodirty -generatenodirty: - @[ -z "$$(git status --porcelain)" ] || ( \ - echo "Working tree is dirty. Commit your changes first."; \ - git status; \ - exit 1 ) - @make generate - @status=$$(git status --porcelain); \ - [ -z "$$status" ] || ( \ - echo "Working tree is dirty after `make generate`:"; \ - echo "$$status"; \ - echo "Please ensure that the generated code is up-to-date." ) diff --git a/vendor/go.uber.org/atomic/README.md b/vendor/go.uber.org/atomic/README.md deleted file mode 100644 index 96b47a1f1..000000000 --- a/vendor/go.uber.org/atomic/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# atomic [![GoDoc][doc-img]][doc] [![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![Go Report Card][reportcard-img]][reportcard] - -Simple wrappers for primitive types to enforce atomic access. - -## Installation - -```shell -$ go get -u go.uber.org/atomic@v1 -``` - -### Legacy Import Path - -As of v1.5.0, the import path `go.uber.org/atomic` is the only supported way -of using this package. If you are using Go modules, this package will fail to -compile with the legacy import path path `github.com/uber-go/atomic`. - -We recommend migrating your code to the new import path but if you're unable -to do so, or if your dependencies are still using the old import path, you -will have to add a `replace` directive to your `go.mod` file downgrading the -legacy import path to an older version. - -``` -replace github.com/uber-go/atomic => github.com/uber-go/atomic v1.4.0 -``` - -You can do so automatically by running the following command. - -```shell -$ go mod edit -replace github.com/uber-go/atomic=github.com/uber-go/atomic@v1.4.0 -``` - -## Usage - -The standard library's `sync/atomic` is powerful, but it's easy to forget which -variables must be accessed atomically. `go.uber.org/atomic` preserves all the -functionality of the standard library, but wraps the primitive types to -provide a safer, more convenient API. - -```go -var atom atomic.Uint32 -atom.Store(42) -atom.Sub(2) -atom.CAS(40, 11) -``` - -See the [documentation][doc] for a complete API specification. - -## Development Status - -Stable. - ---- - -Released under the [MIT License](LICENSE.txt). - -[doc-img]: https://godoc.org/github.com/uber-go/atomic?status.svg -[doc]: https://godoc.org/go.uber.org/atomic -[ci-img]: https://github.com/uber-go/atomic/actions/workflows/go.yml/badge.svg -[ci]: https://github.com/uber-go/atomic/actions/workflows/go.yml -[cov-img]: https://codecov.io/gh/uber-go/atomic/branch/master/graph/badge.svg -[cov]: https://codecov.io/gh/uber-go/atomic -[reportcard-img]: https://goreportcard.com/badge/go.uber.org/atomic -[reportcard]: https://goreportcard.com/report/go.uber.org/atomic diff --git a/vendor/go.uber.org/atomic/bool.go b/vendor/go.uber.org/atomic/bool.go deleted file mode 100644 index 209df7bbc..000000000 --- a/vendor/go.uber.org/atomic/bool.go +++ /dev/null @@ -1,81 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" -) - -// Bool is an atomic type-safe wrapper for bool values. -type Bool struct { - _ nocmp // disallow non-atomic comparison - - v Uint32 -} - -var _zeroBool bool - -// NewBool creates a new Bool. -func NewBool(val bool) *Bool { - x := &Bool{} - if val != _zeroBool { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped bool. -func (x *Bool) Load() bool { - return truthy(x.v.Load()) -} - -// Store atomically stores the passed bool. -func (x *Bool) Store(val bool) { - x.v.Store(boolToInt(val)) -} - -// CAS is an atomic compare-and-swap for bool values. -func (x *Bool) CAS(old, new bool) (swapped bool) { - return x.v.CAS(boolToInt(old), boolToInt(new)) -} - -// Swap atomically stores the given bool and returns the old -// value. -func (x *Bool) Swap(val bool) (old bool) { - return truthy(x.v.Swap(boolToInt(val))) -} - -// MarshalJSON encodes the wrapped bool into JSON. -func (x *Bool) MarshalJSON() ([]byte, error) { - return json.Marshal(x.Load()) -} - -// UnmarshalJSON decodes a bool from JSON. -func (x *Bool) UnmarshalJSON(b []byte) error { - var v bool - if err := json.Unmarshal(b, &v); err != nil { - return err - } - x.Store(v) - return nil -} diff --git a/vendor/go.uber.org/atomic/bool_ext.go b/vendor/go.uber.org/atomic/bool_ext.go deleted file mode 100644 index a2e60e987..000000000 --- a/vendor/go.uber.org/atomic/bool_ext.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "strconv" -) - -//go:generate bin/gen-atomicwrapper -name=Bool -type=bool -wrapped=Uint32 -pack=boolToInt -unpack=truthy -cas -swap -json -file=bool.go - -func truthy(n uint32) bool { - return n == 1 -} - -func boolToInt(b bool) uint32 { - if b { - return 1 - } - return 0 -} - -// Toggle atomically negates the Boolean and returns the previous value. -func (b *Bool) Toggle() (old bool) { - for { - old := b.Load() - if b.CAS(old, !old) { - return old - } - } -} - -// String encodes the wrapped value as a string. -func (b *Bool) String() string { - return strconv.FormatBool(b.Load()) -} diff --git a/vendor/go.uber.org/atomic/doc.go b/vendor/go.uber.org/atomic/doc.go deleted file mode 100644 index ae7390ee6..000000000 --- a/vendor/go.uber.org/atomic/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -// Package atomic provides simple wrappers around numerics to enforce atomic -// access. -package atomic diff --git a/vendor/go.uber.org/atomic/duration.go b/vendor/go.uber.org/atomic/duration.go deleted file mode 100644 index 207594f5e..000000000 --- a/vendor/go.uber.org/atomic/duration.go +++ /dev/null @@ -1,82 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "time" -) - -// Duration is an atomic type-safe wrapper for time.Duration values. -type Duration struct { - _ nocmp // disallow non-atomic comparison - - v Int64 -} - -var _zeroDuration time.Duration - -// NewDuration creates a new Duration. -func NewDuration(val time.Duration) *Duration { - x := &Duration{} - if val != _zeroDuration { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped time.Duration. -func (x *Duration) Load() time.Duration { - return time.Duration(x.v.Load()) -} - -// Store atomically stores the passed time.Duration. -func (x *Duration) Store(val time.Duration) { - x.v.Store(int64(val)) -} - -// CAS is an atomic compare-and-swap for time.Duration values. -func (x *Duration) CAS(old, new time.Duration) (swapped bool) { - return x.v.CAS(int64(old), int64(new)) -} - -// Swap atomically stores the given time.Duration and returns the old -// value. -func (x *Duration) Swap(val time.Duration) (old time.Duration) { - return time.Duration(x.v.Swap(int64(val))) -} - -// MarshalJSON encodes the wrapped time.Duration into JSON. -func (x *Duration) MarshalJSON() ([]byte, error) { - return json.Marshal(x.Load()) -} - -// UnmarshalJSON decodes a time.Duration from JSON. -func (x *Duration) UnmarshalJSON(b []byte) error { - var v time.Duration - if err := json.Unmarshal(b, &v); err != nil { - return err - } - x.Store(v) - return nil -} diff --git a/vendor/go.uber.org/atomic/duration_ext.go b/vendor/go.uber.org/atomic/duration_ext.go deleted file mode 100644 index 4c18b0a9e..000000000 --- a/vendor/go.uber.org/atomic/duration_ext.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import "time" - -//go:generate bin/gen-atomicwrapper -name=Duration -type=time.Duration -wrapped=Int64 -pack=int64 -unpack=time.Duration -cas -swap -json -imports time -file=duration.go - -// Add atomically adds to the wrapped time.Duration and returns the new value. -func (d *Duration) Add(delta time.Duration) time.Duration { - return time.Duration(d.v.Add(int64(delta))) -} - -// Sub atomically subtracts from the wrapped time.Duration and returns the new value. -func (d *Duration) Sub(delta time.Duration) time.Duration { - return time.Duration(d.v.Sub(int64(delta))) -} - -// String encodes the wrapped value as a string. -func (d *Duration) String() string { - return d.Load().String() -} diff --git a/vendor/go.uber.org/atomic/error.go b/vendor/go.uber.org/atomic/error.go deleted file mode 100644 index 3be19c35e..000000000 --- a/vendor/go.uber.org/atomic/error.go +++ /dev/null @@ -1,51 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -// Error is an atomic type-safe wrapper for error values. -type Error struct { - _ nocmp // disallow non-atomic comparison - - v Value -} - -var _zeroError error - -// NewError creates a new Error. -func NewError(val error) *Error { - x := &Error{} - if val != _zeroError { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped error. -func (x *Error) Load() error { - return unpackError(x.v.Load()) -} - -// Store atomically stores the passed error. -func (x *Error) Store(val error) { - x.v.Store(packError(val)) -} diff --git a/vendor/go.uber.org/atomic/error_ext.go b/vendor/go.uber.org/atomic/error_ext.go deleted file mode 100644 index ffe0be21c..000000000 --- a/vendor/go.uber.org/atomic/error_ext.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -// atomic.Value panics on nil inputs, or if the underlying type changes. -// Stabilize by always storing a custom struct that we control. - -//go:generate bin/gen-atomicwrapper -name=Error -type=error -wrapped=Value -pack=packError -unpack=unpackError -file=error.go - -type packedError struct{ Value error } - -func packError(v error) interface{} { - return packedError{v} -} - -func unpackError(v interface{}) error { - if err, ok := v.(packedError); ok { - return err.Value - } - return nil -} diff --git a/vendor/go.uber.org/atomic/float64.go b/vendor/go.uber.org/atomic/float64.go deleted file mode 100644 index 8a1367184..000000000 --- a/vendor/go.uber.org/atomic/float64.go +++ /dev/null @@ -1,77 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "math" -) - -// Float64 is an atomic type-safe wrapper for float64 values. -type Float64 struct { - _ nocmp // disallow non-atomic comparison - - v Uint64 -} - -var _zeroFloat64 float64 - -// NewFloat64 creates a new Float64. -func NewFloat64(val float64) *Float64 { - x := &Float64{} - if val != _zeroFloat64 { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped float64. -func (x *Float64) Load() float64 { - return math.Float64frombits(x.v.Load()) -} - -// Store atomically stores the passed float64. -func (x *Float64) Store(val float64) { - x.v.Store(math.Float64bits(val)) -} - -// Swap atomically stores the given float64 and returns the old -// value. -func (x *Float64) Swap(val float64) (old float64) { - return math.Float64frombits(x.v.Swap(math.Float64bits(val))) -} - -// MarshalJSON encodes the wrapped float64 into JSON. -func (x *Float64) MarshalJSON() ([]byte, error) { - return json.Marshal(x.Load()) -} - -// UnmarshalJSON decodes a float64 from JSON. -func (x *Float64) UnmarshalJSON(b []byte) error { - var v float64 - if err := json.Unmarshal(b, &v); err != nil { - return err - } - x.Store(v) - return nil -} diff --git a/vendor/go.uber.org/atomic/float64_ext.go b/vendor/go.uber.org/atomic/float64_ext.go deleted file mode 100644 index df36b0107..000000000 --- a/vendor/go.uber.org/atomic/float64_ext.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "math" - "strconv" -) - -//go:generate bin/gen-atomicwrapper -name=Float64 -type=float64 -wrapped=Uint64 -pack=math.Float64bits -unpack=math.Float64frombits -swap -json -imports math -file=float64.go - -// Add atomically adds to the wrapped float64 and returns the new value. -func (f *Float64) Add(delta float64) float64 { - for { - old := f.Load() - new := old + delta - if f.CAS(old, new) { - return new - } - } -} - -// Sub atomically subtracts from the wrapped float64 and returns the new value. -func (f *Float64) Sub(delta float64) float64 { - return f.Add(-delta) -} - -// CAS is an atomic compare-and-swap for float64 values. -// -// Note: CAS handles NaN incorrectly. NaN != NaN using Go's inbuilt operators -// but CAS allows a stored NaN to compare equal to a passed in NaN. -// This avoids typical CAS loops from blocking forever, e.g., -// -// for { -// old := atom.Load() -// new = f(old) -// if atom.CAS(old, new) { -// break -// } -// } -// -// If CAS did not match NaN to match, then the above would loop forever. -func (f *Float64) CAS(old, new float64) (swapped bool) { - return f.v.CAS(math.Float64bits(old), math.Float64bits(new)) -} - -// String encodes the wrapped value as a string. -func (f *Float64) String() string { - // 'g' is the behavior for floats with %v. - return strconv.FormatFloat(f.Load(), 'g', -1, 64) -} diff --git a/vendor/go.uber.org/atomic/gen.go b/vendor/go.uber.org/atomic/gen.go deleted file mode 100644 index 1e9ef4f87..000000000 --- a/vendor/go.uber.org/atomic/gen.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -//go:generate bin/gen-atomicint -name=Int32 -wrapped=int32 -file=int32.go -//go:generate bin/gen-atomicint -name=Int64 -wrapped=int64 -file=int64.go -//go:generate bin/gen-atomicint -name=Uint32 -wrapped=uint32 -unsigned -file=uint32.go -//go:generate bin/gen-atomicint -name=Uint64 -wrapped=uint64 -unsigned -file=uint64.go -//go:generate bin/gen-atomicint -name=Uintptr -wrapped=uintptr -unsigned -file=uintptr.go diff --git a/vendor/go.uber.org/atomic/int32.go b/vendor/go.uber.org/atomic/int32.go deleted file mode 100644 index 640ea36a1..000000000 --- a/vendor/go.uber.org/atomic/int32.go +++ /dev/null @@ -1,102 +0,0 @@ -// @generated Code generated by gen-atomicint. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "strconv" - "sync/atomic" -) - -// Int32 is an atomic wrapper around int32. -type Int32 struct { - _ nocmp // disallow non-atomic comparison - - v int32 -} - -// NewInt32 creates a new Int32. -func NewInt32(val int32) *Int32 { - return &Int32{v: val} -} - -// Load atomically loads the wrapped value. -func (i *Int32) Load() int32 { - return atomic.LoadInt32(&i.v) -} - -// Add atomically adds to the wrapped int32 and returns the new value. -func (i *Int32) Add(delta int32) int32 { - return atomic.AddInt32(&i.v, delta) -} - -// Sub atomically subtracts from the wrapped int32 and returns the new value. -func (i *Int32) Sub(delta int32) int32 { - return atomic.AddInt32(&i.v, -delta) -} - -// Inc atomically increments the wrapped int32 and returns the new value. -func (i *Int32) Inc() int32 { - return i.Add(1) -} - -// Dec atomically decrements the wrapped int32 and returns the new value. -func (i *Int32) Dec() int32 { - return i.Sub(1) -} - -// CAS is an atomic compare-and-swap. -func (i *Int32) CAS(old, new int32) (swapped bool) { - return atomic.CompareAndSwapInt32(&i.v, old, new) -} - -// Store atomically stores the passed value. -func (i *Int32) Store(val int32) { - atomic.StoreInt32(&i.v, val) -} - -// Swap atomically swaps the wrapped int32 and returns the old value. -func (i *Int32) Swap(val int32) (old int32) { - return atomic.SwapInt32(&i.v, val) -} - -// MarshalJSON encodes the wrapped int32 into JSON. -func (i *Int32) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Load()) -} - -// UnmarshalJSON decodes JSON into the wrapped int32. -func (i *Int32) UnmarshalJSON(b []byte) error { - var v int32 - if err := json.Unmarshal(b, &v); err != nil { - return err - } - i.Store(v) - return nil -} - -// String encodes the wrapped value as a string. -func (i *Int32) String() string { - v := i.Load() - return strconv.FormatInt(int64(v), 10) -} diff --git a/vendor/go.uber.org/atomic/int64.go b/vendor/go.uber.org/atomic/int64.go deleted file mode 100644 index 9ab66b980..000000000 --- a/vendor/go.uber.org/atomic/int64.go +++ /dev/null @@ -1,102 +0,0 @@ -// @generated Code generated by gen-atomicint. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "strconv" - "sync/atomic" -) - -// Int64 is an atomic wrapper around int64. -type Int64 struct { - _ nocmp // disallow non-atomic comparison - - v int64 -} - -// NewInt64 creates a new Int64. -func NewInt64(val int64) *Int64 { - return &Int64{v: val} -} - -// Load atomically loads the wrapped value. -func (i *Int64) Load() int64 { - return atomic.LoadInt64(&i.v) -} - -// Add atomically adds to the wrapped int64 and returns the new value. -func (i *Int64) Add(delta int64) int64 { - return atomic.AddInt64(&i.v, delta) -} - -// Sub atomically subtracts from the wrapped int64 and returns the new value. -func (i *Int64) Sub(delta int64) int64 { - return atomic.AddInt64(&i.v, -delta) -} - -// Inc atomically increments the wrapped int64 and returns the new value. -func (i *Int64) Inc() int64 { - return i.Add(1) -} - -// Dec atomically decrements the wrapped int64 and returns the new value. -func (i *Int64) Dec() int64 { - return i.Sub(1) -} - -// CAS is an atomic compare-and-swap. -func (i *Int64) CAS(old, new int64) (swapped bool) { - return atomic.CompareAndSwapInt64(&i.v, old, new) -} - -// Store atomically stores the passed value. -func (i *Int64) Store(val int64) { - atomic.StoreInt64(&i.v, val) -} - -// Swap atomically swaps the wrapped int64 and returns the old value. -func (i *Int64) Swap(val int64) (old int64) { - return atomic.SwapInt64(&i.v, val) -} - -// MarshalJSON encodes the wrapped int64 into JSON. -func (i *Int64) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Load()) -} - -// UnmarshalJSON decodes JSON into the wrapped int64. -func (i *Int64) UnmarshalJSON(b []byte) error { - var v int64 - if err := json.Unmarshal(b, &v); err != nil { - return err - } - i.Store(v) - return nil -} - -// String encodes the wrapped value as a string. -func (i *Int64) String() string { - v := i.Load() - return strconv.FormatInt(int64(v), 10) -} diff --git a/vendor/go.uber.org/atomic/nocmp.go b/vendor/go.uber.org/atomic/nocmp.go deleted file mode 100644 index a8201cb4a..000000000 --- a/vendor/go.uber.org/atomic/nocmp.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -// nocmp is an uncomparable struct. Embed this inside another struct to make -// it uncomparable. -// -// type Foo struct { -// nocmp -// // ... -// } -// -// This DOES NOT: -// -// - Disallow shallow copies of structs -// - Disallow comparison of pointers to uncomparable structs -type nocmp [0]func() diff --git a/vendor/go.uber.org/atomic/string.go b/vendor/go.uber.org/atomic/string.go deleted file mode 100644 index 80df93d09..000000000 --- a/vendor/go.uber.org/atomic/string.go +++ /dev/null @@ -1,54 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -// String is an atomic type-safe wrapper for string values. -type String struct { - _ nocmp // disallow non-atomic comparison - - v Value -} - -var _zeroString string - -// NewString creates a new String. -func NewString(val string) *String { - x := &String{} - if val != _zeroString { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped string. -func (x *String) Load() string { - if v := x.v.Load(); v != nil { - return v.(string) - } - return _zeroString -} - -// Store atomically stores the passed string. -func (x *String) Store(val string) { - x.v.Store(val) -} diff --git a/vendor/go.uber.org/atomic/string_ext.go b/vendor/go.uber.org/atomic/string_ext.go deleted file mode 100644 index 83d92edaf..000000000 --- a/vendor/go.uber.org/atomic/string_ext.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -//go:generate bin/gen-atomicwrapper -name=String -type=string -wrapped=Value -file=string.go -// Note: No Swap as String wraps Value, which wraps the stdlib sync/atomic.Value which -// only supports Swap as of go1.17: https://github.com/golang/go/issues/39351 - -// String returns the wrapped value. -func (s *String) String() string { - return s.Load() -} - -// MarshalText encodes the wrapped string into a textual form. -// -// This makes it encodable as JSON, YAML, XML, and more. -func (s *String) MarshalText() ([]byte, error) { - return []byte(s.Load()), nil -} - -// UnmarshalText decodes text and replaces the wrapped string with it. -// -// This makes it decodable from JSON, YAML, XML, and more. -func (s *String) UnmarshalText(b []byte) error { - s.Store(string(b)) - return nil -} diff --git a/vendor/go.uber.org/atomic/time.go b/vendor/go.uber.org/atomic/time.go deleted file mode 100644 index 33460fc37..000000000 --- a/vendor/go.uber.org/atomic/time.go +++ /dev/null @@ -1,55 +0,0 @@ -// @generated Code generated by gen-atomicwrapper. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "time" -) - -// Time is an atomic type-safe wrapper for time.Time values. -type Time struct { - _ nocmp // disallow non-atomic comparison - - v Value -} - -var _zeroTime time.Time - -// NewTime creates a new Time. -func NewTime(val time.Time) *Time { - x := &Time{} - if val != _zeroTime { - x.Store(val) - } - return x -} - -// Load atomically loads the wrapped time.Time. -func (x *Time) Load() time.Time { - return unpackTime(x.v.Load()) -} - -// Store atomically stores the passed time.Time. -func (x *Time) Store(val time.Time) { - x.v.Store(packTime(val)) -} diff --git a/vendor/go.uber.org/atomic/time_ext.go b/vendor/go.uber.org/atomic/time_ext.go deleted file mode 100644 index 1e3dc978a..000000000 --- a/vendor/go.uber.org/atomic/time_ext.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import "time" - -//go:generate bin/gen-atomicwrapper -name=Time -type=time.Time -wrapped=Value -pack=packTime -unpack=unpackTime -imports time -file=time.go - -func packTime(t time.Time) interface{} { - return t -} - -func unpackTime(v interface{}) time.Time { - if t, ok := v.(time.Time); ok { - return t - } - return time.Time{} -} diff --git a/vendor/go.uber.org/atomic/uint32.go b/vendor/go.uber.org/atomic/uint32.go deleted file mode 100644 index 7859a9cc3..000000000 --- a/vendor/go.uber.org/atomic/uint32.go +++ /dev/null @@ -1,102 +0,0 @@ -// @generated Code generated by gen-atomicint. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "strconv" - "sync/atomic" -) - -// Uint32 is an atomic wrapper around uint32. -type Uint32 struct { - _ nocmp // disallow non-atomic comparison - - v uint32 -} - -// NewUint32 creates a new Uint32. -func NewUint32(val uint32) *Uint32 { - return &Uint32{v: val} -} - -// Load atomically loads the wrapped value. -func (i *Uint32) Load() uint32 { - return atomic.LoadUint32(&i.v) -} - -// Add atomically adds to the wrapped uint32 and returns the new value. -func (i *Uint32) Add(delta uint32) uint32 { - return atomic.AddUint32(&i.v, delta) -} - -// Sub atomically subtracts from the wrapped uint32 and returns the new value. -func (i *Uint32) Sub(delta uint32) uint32 { - return atomic.AddUint32(&i.v, ^(delta - 1)) -} - -// Inc atomically increments the wrapped uint32 and returns the new value. -func (i *Uint32) Inc() uint32 { - return i.Add(1) -} - -// Dec atomically decrements the wrapped uint32 and returns the new value. -func (i *Uint32) Dec() uint32 { - return i.Sub(1) -} - -// CAS is an atomic compare-and-swap. -func (i *Uint32) CAS(old, new uint32) (swapped bool) { - return atomic.CompareAndSwapUint32(&i.v, old, new) -} - -// Store atomically stores the passed value. -func (i *Uint32) Store(val uint32) { - atomic.StoreUint32(&i.v, val) -} - -// Swap atomically swaps the wrapped uint32 and returns the old value. -func (i *Uint32) Swap(val uint32) (old uint32) { - return atomic.SwapUint32(&i.v, val) -} - -// MarshalJSON encodes the wrapped uint32 into JSON. -func (i *Uint32) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Load()) -} - -// UnmarshalJSON decodes JSON into the wrapped uint32. -func (i *Uint32) UnmarshalJSON(b []byte) error { - var v uint32 - if err := json.Unmarshal(b, &v); err != nil { - return err - } - i.Store(v) - return nil -} - -// String encodes the wrapped value as a string. -func (i *Uint32) String() string { - v := i.Load() - return strconv.FormatUint(uint64(v), 10) -} diff --git a/vendor/go.uber.org/atomic/uint64.go b/vendor/go.uber.org/atomic/uint64.go deleted file mode 100644 index 2f2a7db63..000000000 --- a/vendor/go.uber.org/atomic/uint64.go +++ /dev/null @@ -1,102 +0,0 @@ -// @generated Code generated by gen-atomicint. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "strconv" - "sync/atomic" -) - -// Uint64 is an atomic wrapper around uint64. -type Uint64 struct { - _ nocmp // disallow non-atomic comparison - - v uint64 -} - -// NewUint64 creates a new Uint64. -func NewUint64(val uint64) *Uint64 { - return &Uint64{v: val} -} - -// Load atomically loads the wrapped value. -func (i *Uint64) Load() uint64 { - return atomic.LoadUint64(&i.v) -} - -// Add atomically adds to the wrapped uint64 and returns the new value. -func (i *Uint64) Add(delta uint64) uint64 { - return atomic.AddUint64(&i.v, delta) -} - -// Sub atomically subtracts from the wrapped uint64 and returns the new value. -func (i *Uint64) Sub(delta uint64) uint64 { - return atomic.AddUint64(&i.v, ^(delta - 1)) -} - -// Inc atomically increments the wrapped uint64 and returns the new value. -func (i *Uint64) Inc() uint64 { - return i.Add(1) -} - -// Dec atomically decrements the wrapped uint64 and returns the new value. -func (i *Uint64) Dec() uint64 { - return i.Sub(1) -} - -// CAS is an atomic compare-and-swap. -func (i *Uint64) CAS(old, new uint64) (swapped bool) { - return atomic.CompareAndSwapUint64(&i.v, old, new) -} - -// Store atomically stores the passed value. -func (i *Uint64) Store(val uint64) { - atomic.StoreUint64(&i.v, val) -} - -// Swap atomically swaps the wrapped uint64 and returns the old value. -func (i *Uint64) Swap(val uint64) (old uint64) { - return atomic.SwapUint64(&i.v, val) -} - -// MarshalJSON encodes the wrapped uint64 into JSON. -func (i *Uint64) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Load()) -} - -// UnmarshalJSON decodes JSON into the wrapped uint64. -func (i *Uint64) UnmarshalJSON(b []byte) error { - var v uint64 - if err := json.Unmarshal(b, &v); err != nil { - return err - } - i.Store(v) - return nil -} - -// String encodes the wrapped value as a string. -func (i *Uint64) String() string { - v := i.Load() - return strconv.FormatUint(uint64(v), 10) -} diff --git a/vendor/go.uber.org/atomic/uintptr.go b/vendor/go.uber.org/atomic/uintptr.go deleted file mode 100644 index ecf7a7727..000000000 --- a/vendor/go.uber.org/atomic/uintptr.go +++ /dev/null @@ -1,102 +0,0 @@ -// @generated Code generated by gen-atomicint. - -// Copyright (c) 2020-2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "encoding/json" - "strconv" - "sync/atomic" -) - -// Uintptr is an atomic wrapper around uintptr. -type Uintptr struct { - _ nocmp // disallow non-atomic comparison - - v uintptr -} - -// NewUintptr creates a new Uintptr. -func NewUintptr(val uintptr) *Uintptr { - return &Uintptr{v: val} -} - -// Load atomically loads the wrapped value. -func (i *Uintptr) Load() uintptr { - return atomic.LoadUintptr(&i.v) -} - -// Add atomically adds to the wrapped uintptr and returns the new value. -func (i *Uintptr) Add(delta uintptr) uintptr { - return atomic.AddUintptr(&i.v, delta) -} - -// Sub atomically subtracts from the wrapped uintptr and returns the new value. -func (i *Uintptr) Sub(delta uintptr) uintptr { - return atomic.AddUintptr(&i.v, ^(delta - 1)) -} - -// Inc atomically increments the wrapped uintptr and returns the new value. -func (i *Uintptr) Inc() uintptr { - return i.Add(1) -} - -// Dec atomically decrements the wrapped uintptr and returns the new value. -func (i *Uintptr) Dec() uintptr { - return i.Sub(1) -} - -// CAS is an atomic compare-and-swap. -func (i *Uintptr) CAS(old, new uintptr) (swapped bool) { - return atomic.CompareAndSwapUintptr(&i.v, old, new) -} - -// Store atomically stores the passed value. -func (i *Uintptr) Store(val uintptr) { - atomic.StoreUintptr(&i.v, val) -} - -// Swap atomically swaps the wrapped uintptr and returns the old value. -func (i *Uintptr) Swap(val uintptr) (old uintptr) { - return atomic.SwapUintptr(&i.v, val) -} - -// MarshalJSON encodes the wrapped uintptr into JSON. -func (i *Uintptr) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Load()) -} - -// UnmarshalJSON decodes JSON into the wrapped uintptr. -func (i *Uintptr) UnmarshalJSON(b []byte) error { - var v uintptr - if err := json.Unmarshal(b, &v); err != nil { - return err - } - i.Store(v) - return nil -} - -// String encodes the wrapped value as a string. -func (i *Uintptr) String() string { - v := i.Load() - return strconv.FormatUint(uint64(v), 10) -} diff --git a/vendor/go.uber.org/atomic/unsafe_pointer.go b/vendor/go.uber.org/atomic/unsafe_pointer.go deleted file mode 100644 index 169f793dc..000000000 --- a/vendor/go.uber.org/atomic/unsafe_pointer.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2021 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import ( - "sync/atomic" - "unsafe" -) - -// UnsafePointer is an atomic wrapper around unsafe.Pointer. -type UnsafePointer struct { - _ nocmp // disallow non-atomic comparison - - v unsafe.Pointer -} - -// NewUnsafePointer creates a new UnsafePointer. -func NewUnsafePointer(val unsafe.Pointer) *UnsafePointer { - return &UnsafePointer{v: val} -} - -// Load atomically loads the wrapped value. -func (p *UnsafePointer) Load() unsafe.Pointer { - return atomic.LoadPointer(&p.v) -} - -// Store atomically stores the passed value. -func (p *UnsafePointer) Store(val unsafe.Pointer) { - atomic.StorePointer(&p.v, val) -} - -// Swap atomically swaps the wrapped unsafe.Pointer and returns the old value. -func (p *UnsafePointer) Swap(val unsafe.Pointer) (old unsafe.Pointer) { - return atomic.SwapPointer(&p.v, val) -} - -// CAS is an atomic compare-and-swap. -func (p *UnsafePointer) CAS(old, new unsafe.Pointer) (swapped bool) { - return atomic.CompareAndSwapPointer(&p.v, old, new) -} diff --git a/vendor/go.uber.org/atomic/value.go b/vendor/go.uber.org/atomic/value.go deleted file mode 100644 index 671f3a382..000000000 --- a/vendor/go.uber.org/atomic/value.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2020 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package atomic - -import "sync/atomic" - -// Value shadows the type of the same name from sync/atomic -// https://godoc.org/sync/atomic#Value -type Value struct { - atomic.Value - - _ nocmp // disallow non-atomic comparison -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 16bde6ae2..cd09e5bcf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -187,9 +187,6 @@ go.opencensus.io/trace go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate -# go.uber.org/atomic v1.9.0 -## explicit; go 1.13 -go.uber.org/atomic # go.uber.org/multierr v1.11.0 ## explicit; go 1.19 go.uber.org/multierr