Use sync/atomic instead of go.uber.org/atomic
This commit is contained in:
parent
24cf7c5bcd
commit
b9c8e359ab
2
go.mod
2
go.mod
@ -30,7 +30,6 @@ require (
|
|||||||
github.com/spf13/pflag v1.0.5
|
github.com/spf13/pflag v1.0.5
|
||||||
github.com/stretchr/testify v1.8.1
|
github.com/stretchr/testify v1.8.1
|
||||||
github.com/tdewolff/minify/v2 v2.12.4
|
github.com/tdewolff/minify/v2 v2.12.4
|
||||||
go.uber.org/atomic v1.10.0
|
|
||||||
go.uber.org/zap v1.24.0
|
go.uber.org/zap v1.24.0
|
||||||
golang.org/x/crypto v0.5.0
|
golang.org/x/crypto v0.5.0
|
||||||
golang.org/x/net v0.5.0
|
golang.org/x/net v0.5.0
|
||||||
@ -139,6 +138,7 @@ require (
|
|||||||
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||||
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
go.uber.org/multierr v1.8.0 // indirect
|
go.uber.org/multierr v1.8.0 // indirect
|
||||||
golang.org/x/mod v0.7.0 // indirect
|
golang.org/x/mod v0.7.0 // indirect
|
||||||
golang.org/x/sys v0.4.0 // indirect
|
golang.org/x/sys v0.4.0 // indirect
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package leaderelection
|
package leaderelection
|
||||||
@ -6,9 +6,9 @@ package leaderelection
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.uber.org/atomic"
|
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
@ -45,7 +45,7 @@ func New(podInfo *downward.PodInfo, deployment *appsv1.Deployment, opts ...kubec
|
|||||||
return nil, nil, fmt.Errorf("could not create internal client for leader election: %w", err)
|
return nil, nil, fmt.Errorf("could not create internal client for leader election: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
isLeader := &isLeaderTracker{tracker: atomic.NewBool(false)}
|
isLeader := &isLeaderTracker{tracker: &atomic.Bool{}}
|
||||||
|
|
||||||
identity := podInfo.Name
|
identity := podInfo.Name
|
||||||
leaseName := deployment.Name
|
leaseName := deployment.Name
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package leaderelection
|
package leaderelection
|
||||||
@ -6,11 +6,11 @@ package leaderelection
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/atomic"
|
|
||||||
coordinationv1 "k8s.io/api/coordination/v1"
|
coordinationv1 "k8s.io/api/coordination/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
kubefake "k8s.io/client-go/kubernetes/fake"
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
||||||
@ -63,7 +63,7 @@ func Test_releaseLock_Update(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
internalClient := kubefake.NewSimpleClientset()
|
internalClient := kubefake.NewSimpleClientset()
|
||||||
isLeader := &isLeaderTracker{tracker: atomic.NewBool(false)}
|
isLeader := &isLeaderTracker{tracker: &atomic.Bool{}}
|
||||||
|
|
||||||
leaderElectorCtx, cancel := context.WithCancel(context.Background())
|
leaderElectorCtx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package server
|
package server
|
||||||
@ -9,9 +9,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.uber.org/atomic"
|
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
|
||||||
"go.pinniped.dev/internal/certauthority"
|
"go.pinniped.dev/internal/certauthority"
|
||||||
@ -23,8 +23,8 @@ type contextKey int
|
|||||||
const bootstrapKey contextKey = iota
|
const bootstrapKey contextKey = iota
|
||||||
|
|
||||||
func withBootstrapConnCtx(ctx context.Context, _ net.Conn) context.Context {
|
func withBootstrapConnCtx(ctx context.Context, _ net.Conn) context.Context {
|
||||||
isBootstrap := atomic.NewBool(false) // safe for concurrent access
|
isBootstrap := atomic.Bool{} // safe for concurrent access
|
||||||
return context.WithValue(ctx, bootstrapKey, isBootstrap)
|
return context.WithValue(ctx, bootstrapKey, &isBootstrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setIsBootstrapConn(ctx context.Context) {
|
func setIsBootstrapConn(ctx context.Context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user