fix: enable gofumpt instead of gofmt linter in client
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@ -23,9 +23,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var defaultV2AuthPrefix = "/v2/auth"
|
||||||
defaultV2AuthPrefix = "/v2/auth"
|
|
||||||
)
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
|
@ -493,7 +493,8 @@ func (f fakeCancelContext) Value(key any) any { return 1 }
|
|||||||
|
|
||||||
func withTimeout(parent context.Context, _timeout time.Duration) (
|
func withTimeout(parent context.Context, _timeout time.Duration) (
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
cancel context.CancelFunc) {
|
cancel context.CancelFunc,
|
||||||
|
) {
|
||||||
ctx = parent
|
ctx = parent
|
||||||
cancel = func() {
|
cancel = func() {
|
||||||
ctx = nil
|
ctx = nil
|
||||||
|
@ -22,9 +22,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var cURLDebug = false
|
||||||
cURLDebug = false
|
|
||||||
)
|
|
||||||
|
|
||||||
func EnablecURLDebug() {
|
func EnablecURLDebug() {
|
||||||
cURLDebug = true
|
cURLDebug = true
|
||||||
|
@ -79,9 +79,7 @@ const (
|
|||||||
PrevNoExist = PrevExistType("false")
|
PrevNoExist = PrevExistType("false")
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var defaultV2KeysPrefix = "/v2/keys"
|
||||||
defaultV2KeysPrefix = "/v2/keys"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewKeysAPI builds a KeysAPI that interacts with etcd's key-value
|
// NewKeysAPI builds a KeysAPI that interacts with etcd's key-value
|
||||||
// API over HTTP.
|
// API over HTTP.
|
||||||
|
@ -20,7 +20,7 @@ import "os"
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// PrivateDirMode grants owner to make/remove files inside the directory.
|
// PrivateDirMode grants owner to make/remove files inside the directory.
|
||||||
PrivateDirMode = 0700
|
PrivateDirMode = 0o700
|
||||||
)
|
)
|
||||||
|
|
||||||
// OpenDir opens a directory for syncing.
|
// OpenDir opens a directory for syncing.
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// PrivateFileMode grants owner to read/write a file.
|
// PrivateFileMode grants owner to read/write a file.
|
||||||
PrivateFileMode = 0600
|
PrivateFileMode = 0o600
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsDirWriteable checks if dir is writable by writing and removing a file
|
// IsDirWriteable checks if dir is writable by writing and removing a file
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
func TestIsDirWriteable(t *testing.T) {
|
func TestIsDirWriteable(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
require.NoErrorf(t, IsDirWriteable(tmpdir), "unexpected IsDirWriteable error")
|
require.NoErrorf(t, IsDirWriteable(tmpdir), "unexpected IsDirWriteable error")
|
||||||
require.NoErrorf(t, os.Chmod(tmpdir, 0444), "unexpected os.Chmod error")
|
require.NoErrorf(t, os.Chmod(tmpdir, 0o444), "unexpected os.Chmod error")
|
||||||
me, err := user.Current()
|
me, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// err can be non-nil when cross compiled
|
// err can be non-nil when cross compiled
|
||||||
@ -68,7 +68,7 @@ func TestCreateDirAll(t *testing.T) {
|
|||||||
func TestExist(t *testing.T) {
|
func TestExist(t *testing.T) {
|
||||||
fdir := filepath.Join(os.TempDir(), fmt.Sprint(time.Now().UnixNano()+rand.Int63n(1000)))
|
fdir := filepath.Join(os.TempDir(), fmt.Sprint(time.Now().UnixNano()+rand.Int63n(1000)))
|
||||||
os.RemoveAll(fdir)
|
os.RemoveAll(fdir)
|
||||||
if err := os.Mkdir(fdir, 0666); err != nil {
|
if err := os.Mkdir(fdir, 0o666); err != nil {
|
||||||
t.Skip(err)
|
t.Skip(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(fdir)
|
defer os.RemoveAll(fdir)
|
||||||
@ -150,7 +150,7 @@ func TestDirPermission(t *testing.T) {
|
|||||||
// create a new dir with 0700
|
// create a new dir with 0700
|
||||||
require.NoError(t, CreateDirAll(zaptest.NewLogger(t), tmpdir2))
|
require.NoError(t, CreateDirAll(zaptest.NewLogger(t), tmpdir2))
|
||||||
// check dir permission with mode different than created dir
|
// check dir permission with mode different than created dir
|
||||||
if err := CheckDirPermission(tmpdir2, 0600); err == nil {
|
if err := CheckDirPermission(tmpdir2, 0o600); err == nil {
|
||||||
t.Errorf("expected error, got nil")
|
t.Errorf("expected error, got nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ErrLocked = errors.New("fileutil: file already locked")
|
||||||
ErrLocked = errors.New("fileutil: file already locked")
|
|
||||||
)
|
|
||||||
|
|
||||||
type LockedFile struct{ *os.File }
|
type LockedFile struct{ *os.File }
|
||||||
|
@ -135,7 +135,7 @@ func interestingGoroutines() (gs []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldSkip := func() bool {
|
shouldSkip := func() bool {
|
||||||
var uninterestingMsgs = [...]string{
|
uninterestingMsgs := [...]string{
|
||||||
"sync.(*WaitGroup).Done",
|
"sync.(*WaitGroup).Done",
|
||||||
"os.(*file).close",
|
"os.(*file).close",
|
||||||
"os.(*Process).Release",
|
"os.(*Process).Release",
|
||||||
|
@ -23,9 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var ErrNotTCP = errors.New("only tcp connections have keepalive")
|
||||||
ErrNotTCP = errors.New("only tcp connections have keepalive")
|
|
||||||
)
|
|
||||||
|
|
||||||
// LimitListener returns a Listener that accepts at most n simultaneous
|
// LimitListener returns a Listener that accepts at most n simultaneous
|
||||||
// connections from the provided Listener.
|
// connections from the provided Listener.
|
||||||
|
@ -330,7 +330,7 @@ func SelfCert(lg *zap.Logger, dirpath string, hosts []string, selfSignedCertVali
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
keyOut, err := os.OpenFile(keyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
info.Logger.Warn(
|
info.Logger.Warn(
|
||||||
"cannot key file",
|
"cannot key file",
|
||||||
|
@ -610,7 +610,7 @@ func TestNewListenerWithACRLFile(t *testing.T) {
|
|||||||
require.NoErrorf(t, err, "unable to create revocation list")
|
require.NoErrorf(t, err, "unable to create revocation list")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.WriteFile(tlsInfo.CRLFile, revocationListContents, 0600)
|
err = os.WriteFile(tlsInfo.CRLFile, revocationListContents, 0o600)
|
||||||
require.NoErrorf(t, err, "unable to write revocation list")
|
require.NoErrorf(t, err, "unable to write revocation list")
|
||||||
|
|
||||||
chHandshakeFailure := make(chan error, 1)
|
chHandshakeFailure := make(chan error, 1)
|
||||||
|
@ -55,7 +55,8 @@ func TestDialCancel(t *testing.T) {
|
|||||||
ep := "unix://dialcancel:12345"
|
ep := "unix://dialcancel:12345"
|
||||||
cfg := Config{
|
cfg := Config{
|
||||||
Endpoints: []string{ep},
|
Endpoints: []string{ep},
|
||||||
DialTimeout: 30 * time.Second}
|
DialTimeout: 30 * time.Second,
|
||||||
|
}
|
||||||
c, err := NewClient(t, cfg)
|
c, err := NewClient(t, cfg)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -338,7 +339,7 @@ func TestSyncFiltersMembers(t *testing.T) {
|
|||||||
|
|
||||||
func TestMinSupportedVersion(t *testing.T) {
|
func TestMinSupportedVersion(t *testing.T) {
|
||||||
testutil.BeforeTest(t)
|
testutil.BeforeTest(t)
|
||||||
var tests = []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
currentVersion semver.Version
|
currentVersion semver.Version
|
||||||
minSupportedVersion semver.Version
|
minSupportedVersion semver.Version
|
||||||
@ -379,7 +380,7 @@ func TestMinSupportedVersion(t *testing.T) {
|
|||||||
|
|
||||||
func TestClientRejectOldCluster(t *testing.T) {
|
func TestClientRejectOldCluster(t *testing.T) {
|
||||||
testutil.BeforeTest(t)
|
testutil.BeforeTest(t)
|
||||||
var tests = []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
endpoints []string
|
endpoints []string
|
||||||
versions []string
|
versions []string
|
||||||
|
@ -18,8 +18,10 @@ import (
|
|||||||
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CompareTarget int
|
type (
|
||||||
type CompareResult int
|
CompareTarget int
|
||||||
|
CompareResult int
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CompareVersion CompareTarget = iota
|
CompareVersion CompareTarget = iota
|
||||||
|
@ -26,9 +26,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ErrLocked is returned by TryLock when Mutex is already locked by another session.
|
// ErrLocked is returned by TryLock when Mutex is already locked by another session.
|
||||||
var ErrLocked = errors.New("mutex: Locked by another session")
|
var (
|
||||||
var ErrSessionExpired = errors.New("mutex: session is expired")
|
ErrLocked = errors.New("mutex: Locked by another session")
|
||||||
var ErrLockReleased = errors.New("mutex: lock has already been released")
|
ErrSessionExpired = errors.New("mutex: session is expired")
|
||||||
|
ErrLockReleased = errors.New("mutex: lock has already been released")
|
||||||
|
)
|
||||||
|
|
||||||
// Mutex implements the sync Locker interface with etcd
|
// Mutex implements the sync Locker interface with etcd
|
||||||
type Mutex struct {
|
type Mutex struct {
|
||||||
@ -164,6 +166,7 @@ func (lm *lockerMutex) Lock() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lm *lockerMutex) Unlock() {
|
func (lm *lockerMutex) Unlock() {
|
||||||
client := lm.s.Client()
|
client := lm.s.Client()
|
||||||
if err := lm.Mutex.Unlock(client.Ctx()); err != nil {
|
if err := lm.Mutex.Unlock(client.Ctx()); err != nil {
|
||||||
|
@ -80,12 +80,15 @@ func (op OpResponse) Txn() *TxnResponse { return op.txn }
|
|||||||
func (resp *PutResponse) OpResponse() OpResponse {
|
func (resp *PutResponse) OpResponse() OpResponse {
|
||||||
return OpResponse{put: resp}
|
return OpResponse{put: resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resp *GetResponse) OpResponse() OpResponse {
|
func (resp *GetResponse) OpResponse() OpResponse {
|
||||||
return OpResponse{get: resp}
|
return OpResponse{get: resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resp *DeleteResponse) OpResponse() OpResponse {
|
func (resp *DeleteResponse) OpResponse() OpResponse {
|
||||||
return OpResponse{del: resp}
|
return OpResponse{del: resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resp *TxnResponse) OpResponse() OpResponse {
|
func (resp *TxnResponse) OpResponse() OpResponse {
|
||||||
return OpResponse{txn: resp}
|
return OpResponse{txn: resp}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,10 @@ func (s *syncer) SyncBase(ctx context.Context) (<-chan clientv3.GetResponse, cha
|
|||||||
|
|
||||||
var key string
|
var key string
|
||||||
|
|
||||||
opts := []clientv3.OpOption{clientv3.WithLimit(batchLimit), clientv3.WithRev(s.rev),
|
opts := []clientv3.OpOption{
|
||||||
clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend)}
|
clientv3.WithLimit(batchLimit), clientv3.WithRev(s.rev),
|
||||||
|
clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend),
|
||||||
|
}
|
||||||
|
|
||||||
if len(s.prefix) == 0 {
|
if len(s.prefix) == 0 {
|
||||||
// If len(s.prefix) == 0, we will sync the entire key-value space.
|
// If len(s.prefix) == 0, we will sync the entire key-value space.
|
||||||
|
@ -101,6 +101,7 @@ func RetryKVClient(c *Client) pb.KVClient {
|
|||||||
kc: pb.NewKVClient(c.conn),
|
kc: pb.NewKVClient(c.conn),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rkv *retryKVClient) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (resp *pb.RangeResponse, err error) {
|
func (rkv *retryKVClient) Range(ctx context.Context, in *pb.RangeRequest, opts ...grpc.CallOption) (resp *pb.RangeResponse, err error) {
|
||||||
return rkv.kc.Range(ctx, in, append(opts, withRepeatablePolicy())...)
|
return rkv.kc.Range(ctx, in, append(opts, withRepeatablePolicy())...)
|
||||||
}
|
}
|
||||||
|
@ -359,14 +359,12 @@ func contextErrToGRPCErr(err error) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var defaultOptions = &options{
|
||||||
defaultOptions = &options{
|
|
||||||
retryPolicy: nonRepeatable,
|
retryPolicy: nonRepeatable,
|
||||||
max: 0, // disable
|
max: 0, // disable
|
||||||
backoffFunc: backoffLinearWithJitter(50*time.Millisecond /*jitter*/, 0.10),
|
backoffFunc: backoffLinearWithJitter(50*time.Millisecond /*jitter*/, 0.10),
|
||||||
retryAuth: true,
|
retryAuth: true,
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// backoffFunc denotes a family of functions that control the backoff duration between call retries.
|
// backoffFunc denotes a family of functions that control the backoff duration between call retries.
|
||||||
//
|
//
|
||||||
|
@ -14,8 +14,10 @@
|
|||||||
|
|
||||||
package clientv3
|
package clientv3
|
||||||
|
|
||||||
type SortTarget int
|
type (
|
||||||
type SortOrder int
|
SortTarget int
|
||||||
|
SortOrder int
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SortNone SortOrder = iota
|
SortNone SortOrder = iota
|
||||||
|
@ -221,8 +221,7 @@ type watchRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// progressRequest is issued by the subscriber to request watch progress
|
// progressRequest is issued by the subscriber to request watch progress
|
||||||
type progressRequest struct {
|
type progressRequest struct{}
|
||||||
}
|
|
||||||
|
|
||||||
// watcherStream represents a registered watcher
|
// watcherStream represents a registered watcher
|
||||||
type watcherStream struct {
|
type watcherStream struct {
|
||||||
@ -261,8 +260,10 @@ func NewWatchFromWatchClient(wc pb.WatchClient, c *Client) Watcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// never closes
|
// never closes
|
||||||
var valCtxCh = make(chan struct{})
|
var (
|
||||||
var zeroTime = time.Unix(0, 0)
|
valCtxCh = make(chan struct{})
|
||||||
|
zeroTime = time.Unix(0, 0)
|
||||||
|
)
|
||||||
|
|
||||||
// ctx with only the values; never Done
|
// ctx with only the values; never Done
|
||||||
type valCtx struct{ context.Context }
|
type valCtx struct{ context.Context }
|
||||||
|
Reference in New Issue
Block a user