Skip to content

Commit

Permalink
Merge pull request #39 from werf/fix-update-all-dependencies
Browse files Browse the repository at this point in the history
fix: update all modules and reformat
  • Loading branch information
ilya-lesikov authored Mar 17, 2023
2 parents f85d532 + 79e3590 commit 444ab06
Show file tree
Hide file tree
Showing 20 changed files with 308 additions and 701 deletions.
42 changes: 42 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
run:
timeout: 10m
skip-dirs:
- playground

linters-settings:
gofumpt:
extra-rules: true
gci:
sections:
- standard
- default
- prefix(github.com/werf/)
gocritic:
disabled-checks:
- ifElseChain
errorlint:
comparison: false
asserts: false

linters:
disable-all: true
enable:
# Default linters.
- deadcode
- ineffassign
- structcheck
- typecheck
- varcheck

# Extra linters.
- asciicheck
- bidichk
- bodyclose
- errname
- errorlint
- exportloopref
- gci
- gocritic
- gofumpt
- misspell

75 changes: 68 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,74 @@
module github.com/werf/lockgate

go 1.14
go 1.20

require (
github.com/gofrs/flock v0.7.1
github.com/google/uuid v1.1.2
github.com/gofrs/flock v0.8.1
github.com/google/uuid v1.3.0
github.com/spaolacci/murmur3 v1.1.0
github.com/werf/kubedog v0.6.2
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
k8s.io/apimachinery v0.20.4
k8s.io/client-go v0.20.4
github.com/werf/kubedog v0.9.10
golang.org/x/crypto v0.7.0
k8s.io/apimachinery v0.26.2
k8s.io/client-go v0.26.2
)

require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/avelino/slugify v0.0.0-20180501145920-855f152bd774 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gookit/color v1.5.2 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/werf/logboek v0.5.4 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.2 // indirect
k8s.io/cli-runtime v0.26.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230217203603-ff9a8e8fa21d // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
832 changes: 175 additions & 657 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/distributed_locker/distributed_locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (l *DistributedLocker) leaseRenewWorker(handle lockgate.LockHandle, opts lo
}

if !l.isLeaseRenewWorkerActive(handle) {
debug("(leaseRenewWorker %q %q) already stopped, ignore check")
debug("(leaseRenewWorker %q %q) already stopped, ignore check", handle.LockName, handle.UUID)
continue
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/distributed_locker/distributed_locker_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"time"

"github.com/werf/lockgate"

"github.com/google/uuid"

"github.com/werf/lockgate"
)

const (
Expand Down
7 changes: 4 additions & 3 deletions pkg/distributed_locker/factory.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package distributed_locker

import (
"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"

"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"
)

func NewKubernetesLocker(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName string, namespace string) *DistributedLocker {
func NewKubernetesLocker(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName, namespace string) *DistributedLocker {
store := optimistic_locking_store.NewKubernetesResourceAnnotationsStore(kubernetesInterface, gvr, resourceName, namespace)
backend := NewOptimisticLockingStorageBasedBackend(store)
return NewDistributedLocker(backend)
Expand All @@ -23,7 +24,7 @@ func NewHttpBackendHandlerWithInMemoryStore() *HttpBackendHandler {
return NewHttpBackendHandler(backend)
}

func NewHttpBackendHandlerWithKubernetesStore(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName string, namespace string) *HttpBackendHandler {
func NewHttpBackendHandlerWithKubernetesStore(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName, namespace string) *HttpBackendHandler {
store := optimistic_locking_store.NewKubernetesResourceAnnotationsStore(kubernetesInterface, gvr, resourceName, namespace)
backend := NewOptimisticLockingStorageBasedBackend(store)
return NewHttpBackendHandler(backend)
Expand Down
7 changes: 3 additions & 4 deletions pkg/distributed_locker/http_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"

"github.com/werf/lockgate"

"github.com/werf/lockgate/pkg/util"
)

Expand All @@ -22,7 +21,7 @@ func NewHttpBackend(urlEndpoint string) *HttpBackend {
}

func (backend *HttpBackend) Acquire(lockName string, opts AcquireOptions) (lockgate.LockHandle, error) {
var request = AcquireRequest{
request := AcquireRequest{
LockName: lockName,
Opts: opts,
}
Expand All @@ -35,7 +34,7 @@ func (backend *HttpBackend) Acquire(lockName string, opts AcquireOptions) (lockg
}

func (backend *HttpBackend) RenewLease(handle lockgate.LockHandle) error {
var request = RenewLeaseRequest{LockHandle: handle}
request := RenewLeaseRequest{LockHandle: handle}
var response RenewLeaseResponse

if err := util.PerformHttpPost(backend.HttpClient, fmt.Sprintf("%s/%s", backend.URLEndpoint, "renew-lease"), request, &response); err != nil {
Expand All @@ -45,7 +44,7 @@ func (backend *HttpBackend) RenewLease(handle lockgate.LockHandle) error {
}

func (backend *HttpBackend) Release(handle lockgate.LockHandle) error {
var request = ReleaseRequest{LockHandle: handle}
request := ReleaseRequest{LockHandle: handle}
var response ReleaseResponse

if err := util.PerformHttpPost(backend.HttpClient, fmt.Sprintf("%s/%s", backend.URLEndpoint, "release"), request, &response); err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/distributed_locker/http_backend_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"

"github.com/werf/lockgate"

"github.com/werf/lockgate/pkg/util"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/werf/lockgate"

"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"
"github.com/werf/lockgate/pkg/util"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"k8s.io/apimachinery/pkg/api/errors"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -20,7 +19,7 @@ type KubernetesResourceAnnotationsStore struct {
Namespace string
}

func NewKubernetesResourceAnnotationsStore(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName string, namespace string) *KubernetesResourceAnnotationsStore {
func NewKubernetesResourceAnnotationsStore(kubernetesInterface dynamic.Interface, gvr schema.GroupVersionResource, resourceName, namespace string) *KubernetesResourceAnnotationsStore {
return &KubernetesResourceAnnotationsStore{
KubernetesInterface: kubernetesInterface,
GVR: gvr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package optimistic_locking_store

import "errors"

var (
ErrRecordVersionChanged = errors.New("record version changed")
)
var ErrRecordVersionChanged = errors.New("record version changed")

type OptimisticLockingStore interface {
GetValue(key string) (*Value, error)
Expand Down
6 changes: 2 additions & 4 deletions pkg/file_lock/file_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import (
"github.com/werf/lockgate/pkg/util"
)

var (
LegacyHashFunction = false
)
var LegacyHashFunction = false

func NewFileLock(name string, locksDir string) LockObject {
func NewFileLock(name, locksDir string) LockObject {
return &FileLock{BaseLock: BaseLock{Name: name}, LocksDir: locksDir}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/file_locker/file_locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"os"
"sync"

"github.com/werf/lockgate"

"github.com/google/uuid"

"github.com/werf/lockgate"
"github.com/werf/lockgate/pkg/file_lock"
)

Expand All @@ -19,7 +19,7 @@ type FileLocker struct {
}

func NewFileLocker(locksDir string) (*FileLocker, error) {
if err := os.MkdirAll(locksDir, 0755); err != nil {
if err := os.MkdirAll(locksDir, 0o755); err != nil {
return nil, fmt.Errorf("cannot create dir %s: %s", locksDir, err)
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/util/hashsum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"fmt"
"strings"

"golang.org/x/crypto/sha3"

"github.com/spaolacci/murmur3"
"golang.org/x/crypto/sha3"
)

// TODO: remove murmurhash, use sha256 for file locks
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/http_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func PerformHttpPost(client *http.Client, url string, request, response interfac
return fmt.Errorf("got bad response %s by url %q request:\n%s", resp.Status, url, body)
} else {
if err := json.Unmarshal(body, response); err != nil {
return fmt.Errorf("unable to unmarshal json body by url %q request: %s", err)
return fmt.Errorf("unable to unmarshal json body by url %q request: %s", url, err)
}
}

Expand Down
1 change: 0 additions & 1 deletion playground/http_locker_1/http_locker_1.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/werf/lockgate"

"github.com/werf/lockgate/pkg/distributed_locker"
)

Expand Down
3 changes: 1 addition & 2 deletions playground/lock_server/lock_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"fmt"
"os"

"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"

"github.com/werf/lockgate/pkg/distributed_locker"
"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"
)

func run() error {
Expand Down
4 changes: 1 addition & 3 deletions playground/lock_server_kubernetes/lock_server_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/werf/kubedog/pkg/kube"

"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"

"github.com/werf/lockgate/pkg/distributed_locker"
"github.com/werf/lockgate/pkg/distributed_locker/optimistic_locking_store"
)

func run() error {
Expand Down
3 changes: 1 addition & 2 deletions playground/one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (
"os"
"time"

"github.com/werf/lockgate"

"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/werf/kubedog/pkg/kube"
"github.com/werf/lockgate"
)

func do() error {
Expand Down
3 changes: 1 addition & 2 deletions playground/two/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"os"
"time"

"github.com/werf/lockgate"

"github.com/werf/kubedog/pkg/kube"
"github.com/werf/lockgate"
)

func do() error {
Expand Down

0 comments on commit 444ab06

Please # to comment.