diff --git a/pkg/jsonrpc/client.go b/pkg/jsonrpc/client.go index 78332b84..833bb955 100644 --- a/pkg/jsonrpc/client.go +++ b/pkg/jsonrpc/client.go @@ -94,8 +94,12 @@ func (c *Client) SendMsgWithTimeout(method string, params interface{}, timeout t // For debug purpose stdenc := json.NewEncoder(os.Stdin) stdenc.SetIndent("", "\t") - stdenc.Encode(msg) - stdenc.Encode(&resp) + if encodeErr := stdenc.Encode(msg); encodeErr != nil { + logrus.WithError(encodeErr).Warn("failed to encode the request message") + } + if encodeErr := stdenc.Encode(&resp); encodeErr != nil { + logrus.WithError(encodeErr).Warn("failed to encode the response message") + } }() marshaledParams, err := json.Marshal(msg.Params) diff --git a/pkg/spdk/spdk_test.go b/pkg/spdk/spdk_test.go index 615d2efe..12fbe011 100644 --- a/pkg/spdk/spdk_test.go +++ b/pkg/spdk/spdk_test.go @@ -111,7 +111,8 @@ func (s *TestSuite) TestSPDKBasic(c *C) { c.Assert(err, IsNil) // Do blindly cleanup - spdkCli.DeleteDevice(defaultDeviceName, defaultDeviceName) + err = spdkCli.DeleteDevice(defaultDeviceName, defaultDeviceName) + c.Assert(err, IsNil) bdevAioName, lvsName, lvsUUID, err := spdkCli.AddDevice(defaultDevicePath, defaultDeviceName, types.MiB) c.Assert(err, IsNil) diff --git a/pkg/spdk/types/bdev.go b/pkg/spdk/types/bdev.go index 3ae95f72..15d71dd9 100644 --- a/pkg/spdk/types/bdev.go +++ b/pkg/spdk/types/bdev.go @@ -129,10 +129,6 @@ type BdevGetBdevsRequest struct { Timeout uint64 `json:"timeout,omitempty"` } -type BdevGetBdevsResponse struct { - bdevs []BdevInfo -} - type BdevLvolFragmap struct { ClusterSize uint64 `json:"cluster_size"` NumClusters uint64 `json:"num_clusters"` diff --git a/pkg/util/device.go b/pkg/util/device.go index 45478b7f..c3beb0a6 100644 --- a/pkg/util/device.go +++ b/pkg/util/device.go @@ -125,7 +125,7 @@ func DetectDevice(path string, executor *commonNs.Executor) (*KernelDevice, erro return nil, fmt.Errorf("invalid major:minor %s for device %s with path %s", dev.Nvme.Name, f[1], path) } } - break + break // nolint:staticcheck } if dev == nil { return nil, fmt.Errorf("failed to get device with path %s", path) diff --git a/scripts/validate b/scripts/validate index 3081c0ac..5c83da06 100755 --- a/scripts/validate +++ b/scripts/validate @@ -10,20 +10,8 @@ PACKAGES="$(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | echo Running: go vet go vet ${PACKAGES} -if [ ! -z "${DRONE_REPO}" ] && [ ! -z "${DRONE_PULL_REQUEST}" ]; then - wget https://github.com/$DRONE_REPO/pull/$DRONE_PULL_REQUEST.patch - echo "Running: golangci-lint run --new-from-patch=${DRONE_PULL_REQUEST}.patch" - golangci-lint run --new-from-patch="${DRONE_PULL_REQUEST}.patch" - rm "${DRONE_PULL_REQUEST}.patch" -elif [ ! -z "${DRONE_COMMIT_REF}" ]; then - echo "Running: golangci-lint run --new-from-rev=${DRONE_COMMIT_REF}" - golangci-lint run --new-from-rev=${DRONE_COMMIT_REF} -else - git symbolic-ref -q HEAD && REV="origin/HEAD" || REV="HEAD^" - headSHA=$(git rev-parse --short=12 ${REV}) - echo "Running: golangci-lint run --new-from-rev=${headSHA}" - golangci-lint run --new-from-rev=${headSHA} -fi +echo "Running: golangci-lint" +golangci-lint run --timeout=5m echo Running: go fmt test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"