From bd9c6f316357f6dc309e20fc171829a7491ccd75 Mon Sep 17 00:00:00 2001 From: Alexei Ledenev Date: Sat, 15 Mar 2025 21:48:28 +0200 Subject: [PATCH] update Go 1.24 and latest linter rules; fix linter errors (#266) * update Go 1.24 and latest linter rules; fix linter errors * update Go version to 1.24 in CodeQL analysis and Dockerfile --- .github/workflows/build.yaml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/release.yaml | 2 +- .golangci.yaml | 23 +++++++------- .pre-commit-config.yaml | 13 +++++--- Makefile | 4 +-- docker/Dockerfile | 2 +- go.mod | 21 ++++++------ go.sum | 40 +++++++++++------------ pkg/chaos/docker/kill.go | 46 +++++++++++++-------------- pkg/chaos/netem/cmd/delay.go | 6 ++-- pkg/chaos/netem/cmd/loss_ge.go | 4 +-- pkg/chaos/netem/cmd/loss_state.go | 4 +-- pkg/container/http_client.go | 8 ++--- 14 files changed, 89 insertions(+), 88 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8750b642..b6b4144c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,7 +22,7 @@ jobs: - name: Setup Go Environment uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.24' cache: true cache-dependency-path: go.sum - name: Run Lint and Test Coverage diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 24fe4128..db244e0a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,7 +39,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.24' # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3f627dda..29533f25 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: - name: Set Up Go uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.24' cache: true cache-dependency-path: go.sum - name: Build Release Binaries diff --git a/.golangci.yaml b/.golangci.yaml index fb974b7a..927e882f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,7 +1,4 @@ run: - # which dirs to skip - skip-dirs: - - mocks # Timeout for analysis, e.g. 30s, 5m. # Default: 1m timeout: 5m @@ -15,12 +12,12 @@ run: allow-parallel-runners: true linters-settings: - govet: - check-shadowing: true + # shadow linter replaces govet's check-shadowing + shadow: + strict: false gocyclo: min-complexity: 15 - maligned: - suggest-new: true + # maligned is deprecated dupl: threshold: 100 goconst: @@ -72,7 +69,6 @@ linters: - errorlint - exhaustive # - exhaustivestruct TODO: check how to fix it - - exportloopref # - forbidigo TODO: configure forbidden code patterns # - forcetypeassert - funlen @@ -84,10 +80,10 @@ linters: - gocritic - gocyclo # - godox - - goerr113 + - err113 - gofmt - goimports - - gomnd + - mnd # - gomoddirectives - gosec - gosimple @@ -117,7 +113,7 @@ linters: # - staticcheck doesn't work with go1.19 # - structcheck disabled because of generics - stylecheck - - tenv + - usetesting - testableexamples - typecheck - unconvert @@ -127,10 +123,13 @@ linters: # - varcheck depricated 1.49 # - wastedassign disabled because of generics - whitespace - - wrapcheck + # - wrapcheck # Temporarily disabled due to false positives # - wsl issues: + # Exclude specific directories from linting + exclude-dirs: + - mocks exclude-rules: - path: _test\.go linters: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index efb958e7..06cb2daa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-added-large-files - repo: https://github.com/jumanjihouse/pre-commit-hooks @@ -8,17 +8,20 @@ repos: hooks: - id: git-dirty - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.4.0 + rev: v2.14.0 hooks: - id: pretty-format-golang + additional_dependencies: + - setuptools # Add this line - repo: https://github.com/mattlqx/pre-commit-sign - rev: v1.1.3 + rev: v1.2.0 hooks: - id: sign-commit - repo: https://github.com/syntaqx/git-hooks - rev: v0.0.17 + rev: v0.0.18 hooks: - id: forbid-binary + exclude: ^docs/img/ # Exclude all files in docs/img directory - id: go-test - id: go-mod-tidy - repo: local @@ -27,4 +30,4 @@ repos: name: lint-check entry: make lint language: system - files: \.go + files: \.go \ No newline at end of file diff --git a/Makefile b/Makefile index 5b268274..8d632365 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ release: clean ; $(info $(M) building binaries for multiple os/arch...) @ ## Bui setup-tools: setup-lint setup-gocov setup-gocov-xml setup-go-junit-report setup-lint: - $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 + $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest setup-gocov: $(GO) install github.com/axw/gocov/gocov@v1.1.0 setup-gocov-xml: @@ -75,7 +75,7 @@ setup-gocov-xml: setup-go-junit-report: $(GO) install github.com/jstemmer/go-junit-report/v2@latest setup-mockery: - $(GO) get github.com/vektra/mockery/v2@v2.40.3 + $(GO) install github.com/vektra/mockery/v2@latest # Tests diff --git a/docker/Dockerfile b/docker/Dockerfile index 6e79149f..9d220e85 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ # # ----- Go Builder Image ------ # -FROM --platform=$BUILDPLATFORM golang:1.21 AS builder +FROM --platform=$BUILDPLATFORM golang:1.24 AS builder # curl git bash RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/go.mod b/go.mod index e349d9ae..55639abb 100644 --- a/go.mod +++ b/go.mod @@ -2,25 +2,25 @@ module github.com/alexei-led/pumba require ( github.com/docker/docker v23.0.3+incompatible - github.com/docker/go-connections v0.4.0 - github.com/johntdyer/slackrus v0.0.0-20210521205746-42486fb4c48c - github.com/opencontainers/image-spec v1.1.0-rc4 + github.com/docker/go-connections v0.5.0 + github.com/johntdyer/slackrus v0.0.0-20230315191314-80bc92dee4fc + github.com/opencontainers/image-spec v1.1.1 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 - github.com/stretchr/testify v1.8.4 - github.com/urfave/cli v1.22.12 - golang.org/x/sync v0.6.0 + github.com/stretchr/testify v1.10.0 + github.com/urfave/cli v1.22.16 + golang.org/x/sync v0.12.0 ) require ( github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22 // indirect + github.com/johntdyer/slack-go v0.0.0-20230314151037-c5bf334f9b6e // indirect github.com/kr/text v0.2.0 // indirect github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -28,9 +28,8 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/time v0.1.0 // indirect golang.org/x/tools v0.17.0 // indirect @@ -39,4 +38,4 @@ require ( gotest.tools/v3 v3.0.2 // indirect ) -go 1.21 +go 1.24 diff --git a/go.sum b/go.sum index 0d0b9698..3ea91179 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc= +github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -14,8 +14,8 @@ github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m3 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v23.0.3+incompatible h1:9GhVsShNWz1hO//9BNg/dpMnZW25KydO4wtVxWAIbho= github.com/docker/docker v23.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -24,10 +24,10 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22 h1:jKUP9TQ0c7X3w6+IPyMit07RE42MtTWNd77sN2cHngQ= -github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22/go.mod h1:u0Jo4f2dNlTJeeOywkM6bLwxq6gC3pZ9rEFHn3AhTdk= -github.com/johntdyer/slackrus v0.0.0-20210521205746-42486fb4c48c h1:4eD0DM7IEOQI5egyzKdPXncs61BxMtYwwzJPCRQFU0Y= -github.com/johntdyer/slackrus v0.0.0-20210521205746-42486fb4c48c/go.mod h1:j1kV/8f3jowErEq4XyeypkCdvg5EeHkf0YCKCcq5Ybo= +github.com/johntdyer/slack-go v0.0.0-20230314151037-c5bf334f9b6e h1:5tRmeUw/tXT/DvaoloWTWwlyrEZrKA7pnrz/X+g9s34= +github.com/johntdyer/slack-go v0.0.0-20230314151037-c5bf334f9b6e/go.mod h1:u0Jo4f2dNlTJeeOywkM6bLwxq6gC3pZ9rEFHn3AhTdk= +github.com/johntdyer/slackrus v0.0.0-20230315191314-80bc92dee4fc h1:enUIjGI+ljPLV2X3Mu3noR0P3m2NaIFGRsp96J8RBio= +github.com/johntdyer/slackrus v0.0.0-20230315191314-80bc92dee4fc/go.mod h1:EM3NFHkhmCX05s6UvxWSJ8h/3mluH4tF6bYr9FXF1Cg= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -42,8 +42,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= -github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -56,16 +56,18 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8= -github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ= +github.com/urfave/cli v1.22.16/go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -80,13 +82,11 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/pkg/chaos/docker/kill.go b/pkg/chaos/docker/kill.go index 43c05f47..3309d42d 100644 --- a/pkg/chaos/docker/kill.go +++ b/pkg/chaos/docker/kill.go @@ -23,29 +23,29 @@ var linuxSignals = map[string]syscall.Signal{ "SIGQUIT": syscall.SIGQUIT, "SIGILL": syscall.SIGILL, "SIGTRAP": syscall.SIGTRAP, - "SIGIOT": syscall.Signal(0x6), //nolint:gomnd // SIGIOT (use number since this signal is not defined for Windows) + "SIGIOT": syscall.Signal(0x6), //nolint:mnd // SIGIOT (use number since this signal is not defined for Windows) "SIGBUS": syscall.SIGBUS, "SIGFPE": syscall.SIGFPE, "SIGKILL": syscall.SIGKILL, - "SIGUSR1": syscall.Signal(0x1e), //nolint:gomnd // SIGUSR1 (use number since this signal is not defined for Windows) + "SIGUSR1": syscall.Signal(0x1e), //nolint:mnd // SIGUSR1 (use number since this signal is not defined for Windows) "SIGSEGV": syscall.SIGSEGV, - "SIGUSR2": syscall.Signal(0x1f), //nolint:gomnd // SIGUSR2 (use number since this signal is not defined for Windows) + "SIGUSR2": syscall.Signal(0x1f), //nolint:mnd // SIGUSR2 (use number since this signal is not defined for Windows) "SIGPIPE": syscall.SIGPIPE, "SIGALRM": syscall.SIGALRM, "SIGTERM": syscall.SIGTERM, - "SIGCHLD": syscall.Signal(0x14), //nolint:gomnd // SIGCHLD (use number since this signal is not defined for Windows) - "SIGCONT": syscall.Signal(0x13), //nolint:gomnd // SIGCONT (use number since this signal is not defined for Windows) - "SIGSTOP": syscall.Signal(0x11), //nolint:gomnd // SIGSTOP (use number since this signal is not defined for Windows) - "SIGTSTP": syscall.Signal(0x12), //nolint:gomnd // SIGTSTP (use number since this signal is not defined for Windows) - "SIGTTIN": syscall.Signal(0x15), //nolint:gomnd // SIGTTIN (use number since this signal is not defined for Windows) - "SIGTTOU": syscall.Signal(0x16), //nolint:gomnd // SIGTTOU (use number since this signal is not defined for Windows) - "SIGURG": syscall.Signal(0x10), //nolint:gomnd // SIGURG (use number since this signal is not defined for Windows) - "SIGXCPU": syscall.Signal(0x18), //nolint:gomnd // SIGXCPU (use number since this signal is not defined for Windows) - "SIGXFSZ": syscall.Signal(0x19), //nolint:gomnd // SIGXFSZ (use number since this signal is not defined for Windows) - "SIGVTALRM": syscall.Signal(0x1a), //nolint:gomnd // SIGVTALRM (use number since this signal is not defined for Windows) - "SIGPROF": syscall.Signal(0x1b), //nolint:gomnd // SIGPROF (use number since this signal is not defined for Windows) - "SIGWINCH": syscall.Signal(0x1c), //nolint:gomnd // SIGWINCH (use number since this signal is not defined for Windows) - "SIGIO": syscall.Signal(0x17), //nolint:gomnd // SIGIO (use number since this signal is not defined for Windows) + "SIGCHLD": syscall.Signal(0x14), //nolint:mnd // SIGCHLD (use number since this signal is not defined for Windows) + "SIGCONT": syscall.Signal(0x13), //nolint:mnd // SIGCONT (use number since this signal is not defined for Windows) + "SIGSTOP": syscall.Signal(0x11), //nolint:mnd // SIGSTOP (use number since this signal is not defined for Windows) + "SIGTSTP": syscall.Signal(0x12), //nolint:mnd // SIGTSTP (use number since this signal is not defined for Windows) + "SIGTTIN": syscall.Signal(0x15), //nolint:mnd // SIGTTIN (use number since this signal is not defined for Windows) + "SIGTTOU": syscall.Signal(0x16), //nolint:mnd // SIGTTOU (use number since this signal is not defined for Windows) + "SIGURG": syscall.Signal(0x10), //nolint:mnd // SIGURG (use number since this signal is not defined for Windows) + "SIGXCPU": syscall.Signal(0x18), //nolint:mnd // SIGXCPU (use number since this signal is not defined for Windows) + "SIGXFSZ": syscall.Signal(0x19), //nolint:mnd // SIGXFSZ (use number since this signal is not defined for Windows) + "SIGVTALRM": syscall.Signal(0x1a), //nolint:mnd // SIGVTALRM (use number since this signal is not defined for Windows) + "SIGPROF": syscall.Signal(0x1b), //nolint:mnd // SIGPROF (use number since this signal is not defined for Windows) + "SIGWINCH": syscall.Signal(0x1c), //nolint:mnd // SIGWINCH (use number since this signal is not defined for Windows) + "SIGIO": syscall.Signal(0x17), //nolint:mnd // SIGIO (use number since this signal is not defined for Windows) } // `docker kill` command @@ -98,22 +98,22 @@ func (k *killCommand) Run(ctx context.Context, random bool) error { return nil } - // select single random container from matching container and replace list with selected item + // select single random ctr from matching ctr and replace list with selected item if random { if c := container.RandomContainer(containers); c != nil { containers = []*container.Container{c} } } - for _, container := range containers { + for _, ctr := range containers { log.WithFields(log.Fields{ - "container": container, - "signal": k.signal, - }).Debug("killing container") - c := container + "ctr": ctr, + "signal": k.signal, + }).Debug("killing ctr") + c := ctr err = k.client.KillContainer(ctx, c, k.signal, k.dryRun) if err != nil { - return errors.Wrap(err, "failed to kill container") + return errors.Wrap(err, "failed to kill ctr") } } return nil diff --git a/pkg/chaos/netem/cmd/delay.go b/pkg/chaos/netem/cmd/delay.go index 83c1cfd7..ef97cd1c 100644 --- a/pkg/chaos/netem/cmd/delay.go +++ b/pkg/chaos/netem/cmd/delay.go @@ -24,17 +24,17 @@ func NewDelayCLICommand(ctx context.Context) *cli.Command { cli.IntFlag{ Name: "time, t", Usage: "delay time; in milliseconds", - Value: 100, //nolint:gomnd + Value: 100, //nolint:mnd }, cli.IntFlag{ Name: "jitter, j", Usage: "random delay variation (jitter); in milliseconds; example: 100ms ± 10ms", - Value: 10, //nolint:gomnd + Value: 10, //nolint:mnd }, cli.Float64Flag{ Name: "correlation, c", Usage: "delay correlation; in percentage", - Value: 20, //nolint:gomnd + Value: 20, //nolint:mnd }, cli.StringFlag{ Name: "distribution, d", diff --git a/pkg/chaos/netem/cmd/loss_ge.go b/pkg/chaos/netem/cmd/loss_ge.go index 69ec3acc..b38b950d 100644 --- a/pkg/chaos/netem/cmd/loss_ge.go +++ b/pkg/chaos/netem/cmd/loss_ge.go @@ -29,12 +29,12 @@ func NewLossGECLICommand(ctx context.Context) *cli.Command { cli.Float64Flag{ Name: "pb, r", Usage: "transition probability into the good state", - Value: 100.0, //nolint:gomnd + Value: 100.0, //nolint:mnd }, cli.Float64Flag{ Name: "one-h", Usage: "loss probability in the bad state", - Value: 100.0, //nolint:gomnd + Value: 100.0, //nolint:mnd }, cli.Float64Flag{ Name: "one-k", diff --git a/pkg/chaos/netem/cmd/loss_state.go b/pkg/chaos/netem/cmd/loss_state.go index 306e15cb..4b4be172 100644 --- a/pkg/chaos/netem/cmd/loss_state.go +++ b/pkg/chaos/netem/cmd/loss_state.go @@ -28,7 +28,7 @@ func NewLossStateCLICommand(ctx context.Context) *cli.Command { cli.Float64Flag{ Name: "p31", Usage: "probability to go from state (3) to state (1)", - Value: 100.0, //nolint:gomnd + Value: 100.0, //nolint:mnd }, cli.Float64Flag{ Name: "p32", @@ -38,7 +38,7 @@ func NewLossStateCLICommand(ctx context.Context) *cli.Command { cli.Float64Flag{ Name: "p23", Usage: "probability to go from state (2) to state (3)", - Value: 100.0, //nolint:gomnd + Value: 100.0, //nolint:mnd }, cli.Float64Flag{ Name: "p14", diff --git a/pkg/container/http_client.go b/pkg/container/http_client.go index b04c4ab9..34105bf2 100644 --- a/pkg/container/http_client.go +++ b/pkg/container/http_client.go @@ -38,13 +38,13 @@ func newHTTPClient(address *url.URL, tlsConfig *tls.Config, timeout time.Duratio switch address.Scheme { default: - httpTransport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { - return net.DialTimeout(network, addr, timeout) //nolint:wrapcheck + httpTransport.DialContext = func(_ context.Context, network, addr string) (net.Conn, error) { + return net.DialTimeout(network, addr, timeout) //nolint:wrapcheck // we can't wrap this error } case "unix": socketPath := address.Path - unixDial := func(ctx context.Context, network, addr string) (net.Conn, error) { - return net.DialTimeout("unix", socketPath, timeout) //nolint:wrapcheck + unixDial := func(_ context.Context, _ string, _ string) (net.Conn, error) { + return net.DialTimeout("unix", socketPath, timeout) //nolint:wrapcheck // we can't wrap this error } httpTransport.DialContext = unixDial // Override the main URL object so the HTTP lib won't complain