From 1f94f10598242eb047d31136d3a6a104d3477adc Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Mon, 8 Jul 2024 17:50:59 +0200 Subject: [PATCH 1/2] Update agent to golang 1.22 --- .github/workflows/ci.yaml | 12 ++++++------ .tool-versions | 4 ++-- go.mod | 2 +- go.sum | 9 +++++++++ packaging/suse/trento-agent.spec | 2 +- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 909c1a9c..aa30ffa7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.22 - uses: actions/cache@v4.0.2 id: go-cache with: @@ -49,7 +49,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.48.0 + version: v1.59.1 skip-cache: true args: "--timeout=3m" @@ -71,7 +71,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.22 - uses: actions/cache@v4.0.2 id: go-cache with: @@ -94,7 +94,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.22 - uses: actions/cache@v4.0.2 id: go-cache with: @@ -124,7 +124,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: 1.22 - uses: actions/cache@v4.0.2 id: go-cache with: @@ -218,7 +218,7 @@ jobs: osc checkout $OBS_PROJECT trento-agent -o $OSC_CHECKOUT_DIR cp $FOLDER/_service $OSC_CHECKOUT_DIR rm -v $OSC_CHECKOUT_DIR/*.tar.gz - pushd $OSC_CHECKOUT_DIR + pushd $OSC_CHECKOUT_DIR osc service manualrun cp /__w/agent/agent/vendor.tar.gz . - name: prepare trento-agent.changes file diff --git a/.tool-versions b/.tool-versions index 7d686d37..7aac4b80 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -golang 1.18.1 -mockery 2.32.3 \ No newline at end of file +golang 1.22.5 +mockery 2.32.3 diff --git a/go.mod b/go.mod index 3dfe40ee..ed902be8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/trento-project/agent -go 1.18 +go 1.22 require ( github.com/clbanning/mxj/v2 v2.5.7 diff --git a/go.sum b/go.sum index 32c5c6de..f847aa58 100644 --- a/go.sum +++ b/go.sum @@ -41,6 +41,7 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM= github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chigopher/pathlib v1.0.0 h1:SbsCrFX4vDf4M2d8mT/RTzuVlKOjTKoPHK0HidsQFak= github.com/chigopher/pathlib v1.0.0/go.mod h1:3+YPPV21mU9vyw8Mjp+F33CyCfE6iOzinpiqBcccv7I= @@ -71,6 +72,7 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY= +github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -121,6 +123,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/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/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -164,6 +167,7 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1: github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -172,9 +176,11 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -195,6 +201,7 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/moby/sys/mountinfo v0.6.2 h1:BzJjoreD5BMFNmD9Rus6gdd1pLuecOFPt8wC+Vygl78= github.com/moby/sys/mountinfo v0.6.2/go.mod h1:IJb6JQeOklcdMU9F5xQ8ZALD+CUr5VlGpwtX+VE0rpI= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= @@ -211,6 +218,7 @@ github.com/rabbitmq/amqp091-go v1.3.4 h1:tXuIslN1nhDqs2t6Jrz3BAoqvt4qIZzxvdbdcxW github.com/rabbitmq/amqp091-go v1.3.4/go.mod h1:ogQDLSOACsLPsIq0NpbtiifNZi2YOz0VTJ0kHRghqbM= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= @@ -584,6 +592,7 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/packaging/suse/trento-agent.spec b/packaging/suse/trento-agent.spec index 311e966e..0a46b20f 100644 --- a/packaging/suse/trento-agent.spec +++ b/packaging/suse/trento-agent.spec @@ -28,7 +28,7 @@ Source: %{name}-%{version}.tar.gz Source1: vendor.tar.gz ExclusiveArch: aarch64 x86_64 ppc64le s390x BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: golang(API) = 1.18 +BuildRequires: golang(API) = 1.22 Requires: golang-github-prometheus-node_exporter Provides: %{name} = %{version}-%{release} Provides: trento = %{version}-%{release} From 7b08aa7b55f394201e8dbbc7f91b6fca4585daf7 Mon Sep 17 00:00:00 2001 From: Carmine Di Monaco Date: Tue, 1 Oct 2024 10:42:20 +0200 Subject: [PATCH 2/2] golangci-lint fixes --- .golangci.yaml | 6 ------ .tool-versions | 1 + cmd/config_test.go | 2 +- cmd/id.go | 2 +- cmd/version.go | 2 +- internal/factsengine/factscache/cache_test.go | 14 +++++++------- .../factsengine/gatherers/ascsers_cluster_test.go | 2 +- internal/factsengine/gatherers/cibadmin_test.go | 2 +- internal/factsengine/gatherers/plugin_test.go | 4 ++-- internal/factsengine/gatherers/sbddump_test.go | 8 ++++---- internal/factsengine/policy.go | 2 +- pkg/factsengine/entities/fact_value_test.go | 8 ++++---- pkg/factsengine/plugininterface/interface.go | 2 +- test/helpers/http.go | 2 +- 14 files changed, 26 insertions(+), 31 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 9a731d64..76e34404 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,19 +1,15 @@ linters: enable: - - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - unused - - varcheck # - asasalint - containedctx # - cyclop - - depguard - dogsled - dupl - durationcheck @@ -31,14 +27,12 @@ linters: - gomoddirectives - gomodguard - gosec - - ifshort - importas - lll - misspell - nilerr - nilnil - nonamedreturns - - nosnakecase - prealloc - predeclared - revive diff --git a/.tool-versions b/.tool-versions index 7aac4b80..a59e0c08 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,3 @@ golang 1.22.5 mockery 2.32.3 +golangci-lint 1.59.1 diff --git a/cmd/config_test.go b/cmd/config_test.go index be1cc685..40a86334 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -34,7 +34,7 @@ func (suite *AgentCmdTestSuite) SetupTest() { cmd := cmd.NewRootCmd() for _, command := range cmd.Commands() { - command.Run = func(cmd *cobra.Command, args []string) { + command.Run = func(_ *cobra.Command, _ []string) { // do nothing } } diff --git a/cmd/id.go b/cmd/id.go index 83acbedf..ad661f0c 100644 --- a/cmd/id.go +++ b/cmd/id.go @@ -12,7 +12,7 @@ func NewAgentIDCmd() *cobra.Command { idCmd := &cobra.Command{ //nolint Use: "id", Short: "Print the agent identifier", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { agentID, err := agent.GetAgentID(afero.NewOsFs()) if err != nil { return err diff --git a/cmd/version.go b/cmd/version.go index fe4012af..766f78b8 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -13,7 +13,7 @@ func NewVersionCmd() *cobra.Command { Use: "version", Short: "Print the version number of Trento", Long: `All software has versions. This is Trento's`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("Trento installed from %s version %s\nbuilt with %s %s/%s\n", version.InstallationSource, version.Version, runtime.Version(), runtime.GOOS, runtime.GOARCH) //nolint }, } diff --git a/internal/factsengine/factscache/cache_test.go b/internal/factsengine/factscache/cache_test.go index b1d888b4..bce6f25a 100644 --- a/internal/factsengine/factscache/cache_test.go +++ b/internal/factsengine/factscache/cache_test.go @@ -31,10 +31,10 @@ func (suite *FactsCacheTestSuite) SetupTest() { // nolint:errcheck func (suite *FactsCacheTestSuite) TestEntries() { cache := factscache.NewFactsCache() - cache.GetOrUpdate("entry1", func(args ...interface{}) (interface{}, error) { + cache.GetOrUpdate("entry1", func(_ ...interface{}) (interface{}, error) { return "", nil }) - cache.GetOrUpdate("entry2", func(args ...interface{}) (interface{}, error) { + cache.GetOrUpdate("entry2", func(_ ...interface{}) (interface{}, error) { return "", nil }) entries := cache.Entries() @@ -45,7 +45,7 @@ func (suite *FactsCacheTestSuite) TestEntries() { func (suite *FactsCacheTestSuite) TestGetOrUpdate() { cache := factscache.NewFactsCache() - updateFunc := func(args ...interface{}) (interface{}, error) { + updateFunc := func(_ ...interface{}) (interface{}, error) { return suite.returnValue, nil } @@ -59,7 +59,7 @@ func (suite *FactsCacheTestSuite) TestGetOrUpdateWithError() { cache := factscache.NewFactsCache() someError := "some error" - updateFunc := func(args ...interface{}) (interface{}, error) { + updateFunc := func(_ ...interface{}) (interface{}, error) { return nil, fmt.Errorf(someError) } @@ -71,7 +71,7 @@ func (suite *FactsCacheTestSuite) TestGetOrUpdateWithError() { func (suite *FactsCacheTestSuite) TestGetOrUpdateCacheHit() { cache := factscache.NewFactsCache() - updateFunc := func(args ...interface{}) (interface{}, error) { + updateFunc := func(_ ...interface{}) (interface{}, error) { suite.count++ return suite.returnValue, nil } @@ -143,7 +143,7 @@ func (suite *FactsCacheTestSuite) TestGetOrUpdateCacheConcurrent() { } func (suite *FactsCacheTestSuite) TestPureGetOrUpdate() { - updateFunc := func(args ...interface{}) (interface{}, error) { + updateFunc := func(_ ...interface{}) (interface{}, error) { suite.count++ return suite.returnValue, nil } @@ -158,7 +158,7 @@ func (suite *FactsCacheTestSuite) TestPureGetOrUpdate() { func (suite *FactsCacheTestSuite) TestPureGetOrUpdateCacheHit() { cache := factscache.NewFactsCache() - updateFunc := func(args ...interface{}) (interface{}, error) { + updateFunc := func(_ ...interface{}) (interface{}, error) { suite.count++ return suite.returnValue, nil } diff --git a/internal/factsengine/gatherers/ascsers_cluster_test.go b/internal/factsengine/gatherers/ascsers_cluster_test.go index 9650cc7a..47ca0a88 100644 --- a/internal/factsengine/gatherers/ascsers_cluster_test.go +++ b/internal/factsengine/gatherers/ascsers_cluster_test.go @@ -58,7 +58,7 @@ func (suite *AscsErsClusterTestSuite) TestAscsErsClusterGatherCmdNotFound() { func (suite *AscsErsClusterTestSuite) TestAscsErsClusterGatherCacheCastingError() { cache := factscache.NewFactsCache() - _, err := cache.GetOrUpdate("cibadmin", func(args ...interface{}) (interface{}, error) { + _, err := cache.GetOrUpdate("cibadmin", func(_ ...interface{}) (interface{}, error) { return 1, nil }) suite.NoError(err) diff --git a/internal/factsengine/gatherers/cibadmin_test.go b/internal/factsengine/gatherers/cibadmin_test.go index 21c844e1..92119eb0 100644 --- a/internal/factsengine/gatherers/cibadmin_test.go +++ b/internal/factsengine/gatherers/cibadmin_test.go @@ -247,7 +247,7 @@ func (suite *CibAdminTestSuite) TestCibAdminGatherWithCache() { func (suite *CibAdminTestSuite) TestCibAdminGatherCacheCastingError() { cache := factscache.NewFactsCache() - _, err := cache.GetOrUpdate("cibadmin", func(args ...interface{}) (interface{}, error) { + _, err := cache.GetOrUpdate("cibadmin", func(_ ...interface{}) (interface{}, error) { return 1, nil }) suite.NoError(err) diff --git a/internal/factsengine/gatherers/plugin_test.go b/internal/factsengine/gatherers/plugin_test.go index 3df14c94..3783cde9 100644 --- a/internal/factsengine/gatherers/plugin_test.go +++ b/internal/factsengine/gatherers/plugin_test.go @@ -21,13 +21,13 @@ func TestPluginTestSuite(t *testing.T) { type testPluginLoader struct{} -func (l *testPluginLoader) Load(pluginPath string) (gatherers.FactGatherer, error) { +func (l *testPluginLoader) Load(_ string) (gatherers.FactGatherer, error) { return &mocks.FactGatherer{}, nil } type errorPluginLoader struct{} -func (l *errorPluginLoader) Load(pluginPath string) (gatherers.FactGatherer, error) { +func (l *errorPluginLoader) Load(_ string) (gatherers.FactGatherer, error) { return nil, errors.New("kaboom") } diff --git a/internal/factsengine/gatherers/sbddump_test.go b/internal/factsengine/gatherers/sbddump_test.go index 8edd34e6..c0f24166 100644 --- a/internal/factsengine/gatherers/sbddump_test.go +++ b/internal/factsengine/gatherers/sbddump_test.go @@ -2,7 +2,7 @@ package gatherers_test import ( "errors" - "io/ioutil" + "io" "os" "testing" @@ -49,7 +49,7 @@ func (suite *SBDDumpTestSuite) TestSBDDumpUnableToDumpDevice() { mockExecutor := new(utilsMocks.CommandExecutor) mockOutputFile, _ := os.Open(helpers.GetFixturePath("gatherers/dev.vdc.sbddump.output")) - mockOutput, _ := ioutil.ReadAll(mockOutputFile) + mockOutput, _ := io.ReadAll(mockOutputFile) mockExecutor.On("Exec", "sbd", "-d", "/dev/vdb", "dump").Return(nil, errors.New("a failure")) mockExecutor.On("Exec", "sbd", "-d", "/dev/vdc", "dump").Return(mockOutput, nil) @@ -99,10 +99,10 @@ func (suite *SBDDumpTestSuite) TestSBDDumpGatherer() { mockExecutor := new(utilsMocks.CommandExecutor) deviceVDBMockOutputFile, _ := os.Open(helpers.GetFixturePath("gatherers/dev.vdb.sbddump.output")) - deviceVDBMockOutput, _ := ioutil.ReadAll(deviceVDBMockOutputFile) + deviceVDBMockOutput, _ := io.ReadAll(deviceVDBMockOutputFile) deviceVDCMockOutputFile, _ := os.Open(helpers.GetFixturePath("gatherers/dev.vdc.sbddump.output")) - deviceVDCMockOutput, _ := ioutil.ReadAll(deviceVDCMockOutputFile) + deviceVDCMockOutput, _ := io.ReadAll(deviceVDCMockOutputFile) mockExecutor.On("Exec", "sbd", "-d", "/dev/vdb", "dump").Return(deviceVDBMockOutput, nil) mockExecutor.On("Exec", "sbd", "-d", "/dev/vdc", "dump").Return(deviceVDCMockOutput, nil) diff --git a/internal/factsengine/policy.go b/internal/factsengine/policy.go index be4e49c6..3fe071b9 100644 --- a/internal/factsengine/policy.go +++ b/internal/factsengine/policy.go @@ -13,7 +13,7 @@ const ( FactsGatheringRequested = "Trento.Checks.V1.FactsGatheringRequested" ) -func (c *FactsEngine) handleEvent(contentType string, request []byte) error { +func (c *FactsEngine) handleEvent(_ string, request []byte) error { eventType, err := events.EventType(request) if err != nil { return errors.Wrap(err, "Error getting event type") diff --git a/pkg/factsengine/entities/fact_value_test.go b/pkg/factsengine/entities/fact_value_test.go index 88623242..9f9dc474 100644 --- a/pkg/factsengine/entities/fact_value_test.go +++ b/pkg/factsengine/entities/fact_value_test.go @@ -96,7 +96,7 @@ func (suite *FactValueTestSuite) TestNewFactValueWithStringConversion() { } for _, tt := range cases { - suite.T().Run(tt.description, func(t *testing.T) { + suite.T().Run(tt.description, func(_ *testing.T) { factValue, err := entities.NewFactValue(tt.factValue, entities.WithStringConversion()) suite.Equal(tt.expected, factValue) @@ -181,7 +181,7 @@ func (suite *FactValueTestSuite) TestFactValueAsInterface() { } for _, tt := range cases { - suite.T().Run(tt.description, func(t *testing.T) { + suite.T().Run(tt.description, func(_ *testing.T) { i := tt.factValue.AsInterface() suite.Equal(i, tt.expected) @@ -324,7 +324,7 @@ func (suite *FactValueTestSuite) TestFactValueMapGetValue() { } for _, tt := range cases { - suite.T().Run(tt.description, func(t *testing.T) { + suite.T().Run(tt.description, func(_ *testing.T) { factValue, err := mapValue.GetValue(tt.key) suite.Equal(factValue, tt.expected) @@ -368,7 +368,7 @@ func (suite *FactValueTestSuite) TestParseStringToFactValue() { } for _, tt := range cases { - suite.T().Run(tt.description, func(t *testing.T) { + suite.T().Run(tt.description, func(_ *testing.T) { factValue := entities.ParseStringToFactValue(tt.str) suite.Equal(factValue, tt.expected) diff --git a/pkg/factsengine/plugininterface/interface.go b/pkg/factsengine/plugininterface/interface.go index 78ce9460..4cb3ff11 100644 --- a/pkg/factsengine/plugininterface/interface.go +++ b/pkg/factsengine/plugininterface/interface.go @@ -34,6 +34,6 @@ func (p *GathererPlugin) Server(*plugin.MuxBroker) (interface{}, error) { return &GathererRPCServer{Impl: p.Impl}, nil } -func (GathererPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error) { +func (GathererPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error) { return &GathererRPC{client: c}, nil } diff --git a/test/helpers/http.go b/test/helpers/http.go index 127c2cc1..a4091011 100644 --- a/test/helpers/http.go +++ b/test/helpers/http.go @@ -37,6 +37,6 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { } // ErroringRoundTripFunc implements the RoundTripper interface -func (f ErroringRoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) { +func (f ErroringRoundTripFunc) RoundTrip(_ *http.Request) (*http.Response, error) { return nil, f() }