From c90acefacb0357f5e85273376991718dc2504461 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 31 Aug 2020 15:17:51 +0200 Subject: [PATCH 1/3] Makefile: Add `formatcheck` target - `make formatcheck` outputs the list of files that need formatting - `make format` applies the formatting and now also outputs the diffs. Signed-off-by: InsanePrawn --- Makefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4ff687d..017f6d0 100644 --- a/Makefile +++ b/Makefile @@ -202,14 +202,20 @@ cover-full: ##################### DEV TARGETS ##################### # not part of the build, must do that manually -.PHONY: generate format +.PHONY: generate formatcheck format generate: generate-platform-test-list protoc -I=replication/logic/pdu --go_out=plugins=grpc:replication/logic/pdu replication/logic/pdu/pdu.proto $(GO_ENV_VARS) $(GO) generate $(GO_BUILDFLAGS) -x ./... +GOIMPORTS := goimports -srcdir . -local 'github.com/zrepl/zrepl' +FINDSRCFILES := find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go' + +formatcheck: + @ $(GOIMPORTS) -l $(shell $(FINDSRCFILES)) + format: - goimports -srcdir . -local 'github.com/zrepl/zrepl' -w $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -name '*.pb.go' -not -name '*_enumer.go') + @ $(GOIMPORTS) -w -d $(shell $(FINDSRCFILES)) ##################### NOARCH ##################### .PHONY: noarch $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/_zrepl.zsh_completion $(ARTIFACTDIR)/go_env.txt docs docs-clean From 7a5883d40488f1c0f3bc679a09a9da462660c3a6 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 31 Aug 2020 15:56:40 +0200 Subject: [PATCH 2/3] circleci: Add `make formatcheck` Signed-off-by: InsanePrawn --- .circleci/config.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef4017b..f8a60a8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,6 +60,15 @@ jobs: - run: make zrepl-bin - run: make vet + - run: + shell: /bin/bash + command: | + needformat="$(make formatcheck)" + if [ -n "$needformat" ]; then + echo "$needformat" + exit 1 + fi + exit 0 - run: make lint - run: make release - run: make test-go From 180c3d9ae1a6e30078d0bdfd58ee73848a0dee01 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Mon, 31 Aug 2020 16:04:00 +0200 Subject: [PATCH 3/3] Reformat all files with `make format`. Signed-off-by: InsanePrawn --- cli/cli.go | 1 + daemon/daemon.go | 1 + daemon/hooks/hooks_test.go | 1 + daemon/job/active.go | 1 + daemon/job/active_test.go | 1 + daemon/job/build_jobs_sendrecvoptions.go | 1 + daemon/job/passive.go | 1 + daemon/job/snapjob.go | 1 + daemon/logging/build_logging.go | 1 + daemon/logging/trace/trace.go | 1 + daemon/snapper/snapper.go | 1 + endpoint/endpoint.go | 1 + endpoint/endpoint_abstractions_cache.go | 1 + endpoint/endpoint_guarantees.go | 1 + endpoint/endpoint_zfs_abstraction_last_received_hold.go | 1 + endpoint/endpoint_zfs_abstraction_replication_cursor.go | 1 + platformtest/harness/harness.go | 1 + platformtest/tests/holds.go | 1 + platformtest/tests/idempotentBookmark.go | 1 + platformtest/tests/recvForceIntoEncryptedErr.go | 1 + platformtest/tests/recvRollback.go | 1 + platformtest/tests/replication.go | 1 + replication/driver/replication_driver.go | 5 +++-- replication/driver/replication_driver_test.go | 1 + replication/driver/replication_stepqueue_test.go | 1 + replication/logic/replication_logic.go | 1 + replication/logic/replication_logic_policy.go | 1 + rpc/rpc_client.go | 3 ++- transport/tcp/serve_tcp_ipmap.go | 3 ++- transport/transport.go | 1 + util/semaphore/semaphore.go | 3 ++- util/semaphore/semaphore_test.go | 1 + zfs/placeholder.go | 1 + 33 files changed, 38 insertions(+), 5 deletions(-) diff --git a/cli/cli.go b/cli/cli.go index 4e6feb9..a88cfe7 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/daemon/daemon.go b/daemon/daemon.go index f6a90bc..2da69bc 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -12,6 +12,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/endpoint" "github.com/zrepl/zrepl/util/envconst" diff --git a/daemon/hooks/hooks_test.go b/daemon/hooks/hooks_test.go index 0a25b05..d498e08 100644 --- a/daemon/hooks/hooks_test.go +++ b/daemon/hooks/hooks_test.go @@ -10,6 +10,7 @@ import ( "text/template" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/daemon/job/active.go b/daemon/job/active.go index 56d9003..5bf422c 100644 --- a/daemon/job/active.go +++ b/daemon/job/active.go @@ -9,6 +9,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/daemon/job/active_test.go b/daemon/job/active_test.go index 59d9b53..0affb06 100644 --- a/daemon/job/active_test.go +++ b/daemon/job/active_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/endpoint" "github.com/zrepl/zrepl/transport" ) diff --git a/daemon/job/build_jobs_sendrecvoptions.go b/daemon/job/build_jobs_sendrecvoptions.go index 0db9553..2c399c7 100644 --- a/daemon/job/build_jobs_sendrecvoptions.go +++ b/daemon/job/build_jobs_sendrecvoptions.go @@ -2,6 +2,7 @@ package job import ( "github.com/pkg/errors" + "github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/daemon/filters" "github.com/zrepl/zrepl/endpoint" diff --git a/daemon/job/passive.go b/daemon/job/passive.go index a75d0d5..9414124 100644 --- a/daemon/job/passive.go +++ b/daemon/job/passive.go @@ -6,6 +6,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/daemon/job/snapjob.go b/daemon/job/snapjob.go index 3ce7ee4..82a75af 100644 --- a/daemon/job/snapjob.go +++ b/daemon/job/snapjob.go @@ -7,6 +7,7 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/daemon/logging/build_logging.go b/daemon/logging/build_logging.go index 847f5f5..0aff33e 100644 --- a/daemon/logging/build_logging.go +++ b/daemon/logging/build_logging.go @@ -9,6 +9,7 @@ import ( "github.com/mattn/go-isatty" "github.com/pkg/errors" + "github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/logger" diff --git a/daemon/logging/trace/trace.go b/daemon/logging/trace/trace.go index 1768061..23a0a14 100644 --- a/daemon/logging/trace/trace.go +++ b/daemon/logging/trace/trace.go @@ -100,6 +100,7 @@ import ( "github.com/kr/pretty" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/util/chainlock" ) diff --git a/daemon/snapper/snapper.go b/daemon/snapper/snapper.go index b2460de..cd4335b 100644 --- a/daemon/snapper/snapper.go +++ b/daemon/snapper/snapper.go @@ -8,6 +8,7 @@ import ( "time" "github.com/pkg/errors" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 45b2bd5..d7447d0 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -10,6 +10,7 @@ import ( "github.com/kr/pretty" "github.com/pkg/errors" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/replication/logic/pdu" diff --git a/endpoint/endpoint_abstractions_cache.go b/endpoint/endpoint_abstractions_cache.go index 19058cf..2ba2f3e 100644 --- a/endpoint/endpoint_abstractions_cache.go +++ b/endpoint/endpoint_abstractions_cache.go @@ -6,6 +6,7 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/util/chainlock" ) diff --git a/endpoint/endpoint_guarantees.go b/endpoint/endpoint_guarantees.go index 1b94c28..ce91550 100644 --- a/endpoint/endpoint_guarantees.go +++ b/endpoint/endpoint_guarantees.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/pkg/errors" + "github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/zfs" ) diff --git a/endpoint/endpoint_zfs_abstraction_last_received_hold.go b/endpoint/endpoint_zfs_abstraction_last_received_hold.go index 93fdcae..ca133a4 100644 --- a/endpoint/endpoint_zfs_abstraction_last_received_hold.go +++ b/endpoint/endpoint_zfs_abstraction_last_received_hold.go @@ -6,6 +6,7 @@ import ( "regexp" "github.com/pkg/errors" + "github.com/zrepl/zrepl/zfs" ) diff --git a/endpoint/endpoint_zfs_abstraction_replication_cursor.go b/endpoint/endpoint_zfs_abstraction_replication_cursor.go index f58f78a..d084872 100644 --- a/endpoint/endpoint_zfs_abstraction_replication_cursor.go +++ b/endpoint/endpoint_zfs_abstraction_replication_cursor.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/pkg/errors" + "github.com/zrepl/zrepl/zfs" ) diff --git a/platformtest/harness/harness.go b/platformtest/harness/harness.go index 01d538c..65c0e98 100644 --- a/platformtest/harness/harness.go +++ b/platformtest/harness/harness.go @@ -11,6 +11,7 @@ import ( "github.com/fatih/color" "github.com/pkg/errors" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/config" diff --git a/platformtest/tests/holds.go b/platformtest/tests/holds.go index e0b09e6..f1541a7 100644 --- a/platformtest/tests/holds.go +++ b/platformtest/tests/holds.go @@ -4,6 +4,7 @@ import ( "path" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/platformtest" "github.com/zrepl/zrepl/zfs" ) diff --git a/platformtest/tests/idempotentBookmark.go b/platformtest/tests/idempotentBookmark.go index 94c6e0f..c6b2118 100644 --- a/platformtest/tests/idempotentBookmark.go +++ b/platformtest/tests/idempotentBookmark.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/stretchr/testify/assert" + "github.com/zrepl/zrepl/platformtest" "github.com/zrepl/zrepl/zfs" ) diff --git a/platformtest/tests/recvForceIntoEncryptedErr.go b/platformtest/tests/recvForceIntoEncryptedErr.go index f9d6fe0..37677e7 100644 --- a/platformtest/tests/recvForceIntoEncryptedErr.go +++ b/platformtest/tests/recvForceIntoEncryptedErr.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/platformtest" "github.com/zrepl/zrepl/zfs" ) diff --git a/platformtest/tests/recvRollback.go b/platformtest/tests/recvRollback.go index 149e694..59d342e 100644 --- a/platformtest/tests/recvRollback.go +++ b/platformtest/tests/recvRollback.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/platformtest" "github.com/zrepl/zrepl/zfs" ) diff --git a/platformtest/tests/replication.go b/platformtest/tests/replication.go index 0dc5290..18c7945 100644 --- a/platformtest/tests/replication.go +++ b/platformtest/tests/replication.go @@ -10,6 +10,7 @@ import ( "github.com/kr/pretty" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/daemon/filters" "github.com/zrepl/zrepl/endpoint" "github.com/zrepl/zrepl/platformtest" diff --git a/replication/driver/replication_driver.go b/replication/driver/replication_driver.go index 88a43d0..c2cea85 100644 --- a/replication/driver/replication_driver.go +++ b/replication/driver/replication_driver.go @@ -10,11 +10,12 @@ import ( "time" "github.com/pkg/errors" - "github.com/zrepl/zrepl/daemon/logging/trace" - "github.com/zrepl/zrepl/zfs" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/zrepl/zrepl/daemon/logging/trace" + "github.com/zrepl/zrepl/zfs" + "github.com/zrepl/zrepl/replication/report" "github.com/zrepl/zrepl/util/chainlock" "github.com/zrepl/zrepl/util/envconst" diff --git a/replication/driver/replication_driver_test.go b/replication/driver/replication_driver_test.go index 257d93b..e5c477a 100644 --- a/replication/driver/replication_driver_test.go +++ b/replication/driver/replication_driver_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/replication/report" diff --git a/replication/driver/replication_stepqueue_test.go b/replication/driver/replication_stepqueue_test.go index f79c163..6520038 100644 --- a/replication/driver/replication_stepqueue_test.go +++ b/replication/driver/replication_stepqueue_test.go @@ -12,6 +12,7 @@ import ( "github.com/montanaflynn/stats" "github.com/stretchr/testify/assert" + "github.com/zrepl/zrepl/daemon/logging/trace" ) diff --git a/replication/logic/replication_logic.go b/replication/logic/replication_logic.go index 6fd3379..3e26b1a 100644 --- a/replication/logic/replication_logic.go +++ b/replication/logic/replication_logic.go @@ -9,6 +9,7 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + "github.com/zrepl/zrepl/daemon/logging/trace" "github.com/zrepl/zrepl/logger" diff --git a/replication/logic/replication_logic_policy.go b/replication/logic/replication_logic_policy.go index 9024128..1c897a9 100644 --- a/replication/logic/replication_logic_policy.go +++ b/replication/logic/replication_logic_policy.go @@ -2,6 +2,7 @@ package logic import ( "github.com/pkg/errors" + "github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/replication/logic/pdu" ) diff --git a/rpc/rpc_client.go b/rpc/rpc_client.go index af8cbfd..27fecc4 100644 --- a/rpc/rpc_client.go +++ b/rpc/rpc_client.go @@ -10,9 +10,10 @@ import ( "sync/atomic" "time" - "github.com/zrepl/zrepl/daemon/logging/trace" "google.golang.org/grpc" + "github.com/zrepl/zrepl/daemon/logging/trace" + "github.com/google/uuid" "github.com/zrepl/zrepl/replication/logic" diff --git a/transport/tcp/serve_tcp_ipmap.go b/transport/tcp/serve_tcp_ipmap.go index d0d2442..32986e2 100644 --- a/transport/tcp/serve_tcp_ipmap.go +++ b/transport/tcp/serve_tcp_ipmap.go @@ -8,8 +8,9 @@ import ( "strings" "github.com/pkg/errors" - "github.com/zrepl/zrepl/transport" "golang.org/x/sys/unix" + + "github.com/zrepl/zrepl/transport" ) type ipMapEntry struct { diff --git a/transport/transport.go b/transport/transport.go index 887e4dc..abb28ca 100644 --- a/transport/transport.go +++ b/transport/transport.go @@ -8,6 +8,7 @@ import ( "syscall" "github.com/pkg/errors" + "github.com/zrepl/zrepl/daemon/logging" "github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/rpc/dataconn/timeoutconn" diff --git a/util/semaphore/semaphore.go b/util/semaphore/semaphore.go index 8fefaf7..287a283 100644 --- a/util/semaphore/semaphore.go +++ b/util/semaphore/semaphore.go @@ -3,8 +3,9 @@ package semaphore import ( "context" - "github.com/zrepl/zrepl/daemon/logging/trace" wsemaphore "golang.org/x/sync/semaphore" + + "github.com/zrepl/zrepl/daemon/logging/trace" ) type S struct { diff --git a/util/semaphore/semaphore_test.go b/util/semaphore/semaphore_test.go index 017a86c..b2fb592 100644 --- a/util/semaphore/semaphore_test.go +++ b/util/semaphore/semaphore_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/zrepl/zrepl/daemon/logging/trace" ) diff --git a/zfs/placeholder.go b/zfs/placeholder.go index 00700d6..b43c855 100644 --- a/zfs/placeholder.go +++ b/zfs/placeholder.go @@ -7,6 +7,7 @@ import ( "fmt" "github.com/pkg/errors" + "github.com/zrepl/zrepl/zfs/zfscmd" )