Skip to content

Commit 676e18d

Browse files
authored
Bump up github.com/go-viper/mapstructure/v2 dependency (#8764)
* Bump up github.com/go-viper/mapstructure/v2 dependency * Update unit tests * Update unit tests
1 parent f5defdd commit 676e18d

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

NOTICE-fips.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,11 +3641,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36413641

36423642
--------------------------------------------------------------------------------
36433643
Dependency : github.com/go-viper/mapstructure/v2
3644-
Version: v2.2.1
3644+
Version: v2.3.0
36453645
Licence type (autodetected): MIT
36463646
--------------------------------------------------------------------------------
36473647

3648-
Contents of probable licence file $GOMODCACHE/github.com/go-viper/mapstructure/v2@v2.2.1/LICENSE:
3648+
Contents of probable licence file $GOMODCACHE/github.com/go-viper/mapstructure/v2@v2.3.0/LICENSE:
36493649

36503650
The MIT License (MIT)
36513651

NOTICE.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,11 +3641,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36413641

36423642
--------------------------------------------------------------------------------
36433643
Dependency : github.com/go-viper/mapstructure/v2
3644-
Version: v2.2.1
3644+
Version: v2.3.0
36453645
Licence type (autodetected): MIT
36463646
--------------------------------------------------------------------------------
36473647

3648-
Contents of probable licence file $GOMODCACHE/github.com/go-viper/mapstructure/v2@v2.2.1/LICENSE:
3648+
Contents of probable licence file $GOMODCACHE/github.com/go-viper/mapstructure/v2@v2.3.0/LICENSE:
36493649

36503650
The MIT License (MIT)
36513651

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ require (
3333
github.com/elastic/opentelemetry-collector-components/processor/elastictraceprocessor v0.6.0
3434
github.com/fatih/color v1.18.0
3535
github.com/fsnotify/fsnotify v1.9.0
36-
github.com/go-viper/mapstructure/v2 v2.2.1
36+
github.com/go-viper/mapstructure/v2 v2.3.0
3737
github.com/gofrs/flock v0.12.1
3838
github.com/gofrs/uuid/v5 v5.3.1
3939
github.com/google/go-cmp v0.7.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v
730730
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
731731
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
732732
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
733-
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
734-
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
733+
github.com/go-viper/mapstructure/v2 v2.3.0 h1:27XbWsHIqhbdR5TIC911OfYvgSaW93HM+dX7970Q7jk=
734+
github.com/go-viper/mapstructure/v2 v2.3.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
735735
github.com/go-zookeeper/zk v1.0.4 h1:DPzxraQx7OrPyXq2phlGlNSIyWEsAox0RJmjTseMV6I=
736736
github.com/go-zookeeper/zk v1.0.4/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw=
737737
github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU=

internal/pkg/otel/run_nofips_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestStartCollector(t *testing.T) {
2727
},
2828
{
2929
configFile: "nonexistent-component.yml",
30-
expectedErrorMessage: `error decoding 'extensions': unknown type: "zpages"`,
30+
expectedErrorMessage: `'extensions' unknown type: "zpages"`,
3131
},
3232
}
3333

pkg/component/component_test.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package component
66

77
import (
8-
"errors"
8+
"encoding/json"
99
"fmt"
1010
"os"
1111
"path/filepath"
@@ -16,15 +16,14 @@ import (
1616
"testing"
1717
"time"
1818

19-
"github.com/elastic/go-ucfg"
20-
2119
"github.com/elastic/elastic-agent-client/v7/pkg/client"
2220
"github.com/elastic/elastic-agent-client/v7/pkg/proto"
2321
"github.com/elastic/elastic-agent-libs/logp"
24-
2522
"github.com/elastic/elastic-agent/internal/pkg/agent/transpiler"
2623
"github.com/elastic/elastic-agent/internal/pkg/eql"
24+
"github.com/elastic/go-ucfg"
2725

26+
"github.com/go-viper/mapstructure/v2"
2827
"github.com/google/go-cmp/cmp"
2928
"github.com/google/go-cmp/cmp/cmpopts"
3029
"google.golang.org/protobuf/types/known/structpb"
@@ -700,7 +699,7 @@ func TestToComponents(t *testing.T) {
700699
ID: "filestream-default-filestream-1",
701700
Type: client.UnitTypeInput,
702701
LogLevel: defaultUnitLogLevel,
703-
Err: fmt.Errorf("decoding error: %w", fmt.Errorf("decoding failed due to the following error(s):\n\n%w", errors.Join(errors.New("'meta' expected a map, got 'slice'")))),
702+
Err: fmt.Errorf("decoding error: %w", makeMapStructureErr(t)),
704703
},
705704
},
706705
RuntimeManager: DefaultRuntimeManager,
@@ -790,7 +789,7 @@ func TestToComponents(t *testing.T) {
790789
ID: "cloudbeat-default-cloudbeat-1-unit",
791790
Type: client.UnitTypeInput,
792791
LogLevel: defaultUnitLogLevel,
793-
Err: fmt.Errorf("decoding error: %w", fmt.Errorf("decoding failed due to the following error(s):\n\n%w", errors.Join(errors.New("'meta' expected a map, got 'slice'")))),
792+
Err: fmt.Errorf("decoding error: %w", makeMapStructureErr(t)),
794793
},
795794
},
796795
RuntimeManager: DefaultRuntimeManager,
@@ -3118,3 +3117,18 @@ func TestFlattenedDataStreamIsolatedUnits(t *testing.T) {
31183117
}
31193118
}
31203119
}
3120+
3121+
func makeMapStructureErr(t *testing.T) error {
3122+
t.Helper()
3123+
3124+
jsonStr := `{ "meta": [] }`
3125+
3126+
var data map[string]interface{}
3127+
err := json.Unmarshal([]byte(jsonStr), &data)
3128+
require.NoError(t, err)
3129+
3130+
var output struct {
3131+
Meta struct{} `mapstructure:"meta"`
3132+
}
3133+
return mapstructure.Decode(data, &output)
3134+
}

pkg/component/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestExpectedConfig(t *testing.T) {
183183
},
184184
},
185185
},
186-
Err: errors.New("decoding error: decoding failed due to the following error(s):\n\n'meta' expected a map, got 'slice'"),
186+
Err: errors.New("decoding error: decoding failed due to the following error(s):\n\n'meta' expected a map or struct, got \"slice\""),
187187
},
188188
}
189189

0 commit comments

Comments
 (0)