Skip to content

Commit 5cd3c47

Browse files
committed
swap all interface{} to any
1 parent ccd08eb commit 5cd3c47

39 files changed

Lines changed: 151 additions & 151 deletions

config/component.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ package config
1515
type ComponentConfigurable interface {
1616
// ProvideDefault returns a pointer to a structure that will be
1717
// written with the decoded configuration.
18-
ProvideDefault() (interface{}, error)
18+
ProvideDefault() (any, error)
1919
}
2020

2121
// ComponentCreator is the interface that wraps the Create method.
2222
type ComponentCreator interface {
2323
// Create returns a pointer to an output structure given a pointer
2424
// to an input structure. This interface is expected to be implemented
2525
// by components that are creatable through a configuration.
26-
Create(i interface{}) (interface{}, error)
26+
Create(i any) (any, error)
2727
}
2828

2929
// Pluggable is the interface that groups
@@ -35,17 +35,17 @@ type Pluggable interface {
3535

3636
// decodingHandler is the type of any function that, given a ComponentConfigurable
3737
// and a Decoder, returns a pointer to a structure that was decoded.
38-
type decodingHandler func(c ComponentConfigurable, d Decoder) (interface{}, error)
38+
type decodingHandler func(c ComponentConfigurable, d Decoder) (any, error)
3939

4040
// withDecoderOptions returns a decodingHandler closed over some DecoderOptions.
4141
func withDecoderOptions(opts *DecoderOptions) decodingHandler {
42-
return func(c ComponentConfigurable, d Decoder) (interface{}, error) {
42+
return func(c ComponentConfigurable, d Decoder) (any, error) {
4343
return configure(c, d, opts)
4444
}
4545
}
4646

4747
// Configure returns the decoded target.
48-
func configure(c ComponentConfigurable, d Decoder, opts *DecoderOptions) (interface{}, error) {
48+
func configure(c ComponentConfigurable, d Decoder, opts *DecoderOptions) (any, error) {
4949
target, err := c.ProvideDefault() // target is ptr
5050
if err != nil {
5151
return nil, err

config/component_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestCreateTargetComponentHCL(t *testing.T) {
3030
testCases := []struct {
3131
File string
3232
Plug Pluggable
33-
Expected interface{}
33+
Expected any
3434
}{
3535
{
3636
File: "targets/sqs-minimal-example.hcl",
@@ -263,7 +263,7 @@ func TestCreateObserverComponentHCL(t *testing.T) {
263263
testCases := []struct {
264264
File string
265265
Plug Pluggable
266-
Expected interface{}
266+
Expected any
267267
}{
268268
{
269269
File: "observer.hcl",
@@ -313,7 +313,7 @@ func TestCreateObserverComponentHCL(t *testing.T) {
313313
// Test Helpers
314314
// SQS
315315
func testSQSTargetAdapter(f func(c *target.SQSTargetConfig) (*target.SQSTargetConfig, error)) target.SQSTargetAdapter {
316-
return func(i interface{}) (interface{}, error) {
316+
return func(i any) (any, error) {
317317
cfg, ok := i.(*target.SQSTargetConfig)
318318
if !ok {
319319
return nil, errors.New("invalid input, expected SQSTargetConfig")
@@ -331,7 +331,7 @@ func testSQSTargetFunc(c *target.SQSTargetConfig) (*target.SQSTargetConfig, erro
331331

332332
// EventHub
333333
func testEventHubTargetAdapter(f func(c *target.EventHubConfig) (*target.EventHubConfig, error)) target.EventHubTargetAdapter {
334-
return func(i interface{}) (interface{}, error) {
334+
return func(i any) (any, error) {
335335
cfg, ok := i.(*target.EventHubConfig)
336336
if !ok {
337337
return nil, errors.New("invalid input, expected EventHubTargetConfig")
@@ -349,7 +349,7 @@ func testEventHubTargetFunc(c *target.EventHubConfig) (*target.EventHubConfig, e
349349

350350
// HTTP
351351
func testHTTPTargetAdapter(f func(c *target.HTTPTargetConfig) (*target.HTTPTargetConfig, error)) target.HTTPTargetAdapter {
352-
return func(i interface{}) (interface{}, error) {
352+
return func(i any) (any, error) {
353353
cfg, ok := i.(*target.HTTPTargetConfig)
354354
if !ok {
355355
return nil, errors.New("invalid input, expected HTTPTargetConfig")
@@ -367,7 +367,7 @@ func testHTTPTargetFunc(c *target.HTTPTargetConfig) (*target.HTTPTargetConfig, e
367367

368368
// Kafka
369369
func testKafkaTargetAdapter(f func(c *target.KafkaConfig) (*target.KafkaConfig, error)) target.KafkaTargetAdapter {
370-
return func(i interface{}) (interface{}, error) {
370+
return func(i any) (any, error) {
371371
cfg, ok := i.(*target.KafkaConfig)
372372
if !ok {
373373
return nil, errors.New("invalid input, expected KafkaTargetConfig")
@@ -385,7 +385,7 @@ func testKafkaTargetFunc(c *target.KafkaConfig) (*target.KafkaConfig, error) {
385385

386386
// Kinesis
387387
func testKinesisTargetAdapter(f func(c *target.KinesisTargetConfig) (*target.KinesisTargetConfig, error)) target.KinesisTargetAdapter {
388-
return func(i interface{}) (interface{}, error) {
388+
return func(i any) (any, error) {
389389
cfg, ok := i.(*target.KinesisTargetConfig)
390390
if !ok {
391391
return nil, errors.New("invalid input, expected KinesisTargetConfig")
@@ -403,7 +403,7 @@ func testKinesisTargetFunc(c *target.KinesisTargetConfig) (*target.KinesisTarget
403403

404404
// PubSub
405405
func testPubSubTargetAdapter(f func(c *target.PubSubTargetConfig) (*target.PubSubTargetConfig, error)) target.PubSubTargetAdapter {
406-
return func(i interface{}) (interface{}, error) {
406+
return func(i any) (any, error) {
407407
cfg, ok := i.(*target.PubSubTargetConfig)
408408
if !ok {
409409
return nil, errors.New("invalid input, expected PubSubTargetConfig")
@@ -421,7 +421,7 @@ func testPubSubTargetFunc(c *target.PubSubTargetConfig) (*target.PubSubTargetCon
421421

422422
// StatsD
423423
func testStatsDAdapter(f func(c *statsreceiver.StatsDStatsReceiverConfig) (*statsreceiver.StatsDStatsReceiverConfig, error)) statsreceiver.StatsDStatsReceiverAdapter {
424-
return func(i interface{}) (interface{}, error) {
424+
return func(i any) (any, error) {
425425
cfg, ok := i.(*statsreceiver.StatsDStatsReceiverConfig)
426426
if !ok {
427427
return nil, errors.New("invalid input, expected StatsDStatsReceiverConfig")

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func NewHclConfig(fileContents []byte, filename string) (*Config, error) {
235235
}
236236

237237
// CreateComponent creates a pluggable component given the Decoder options.
238-
func (c *Config) CreateComponent(p Pluggable, opts *DecoderOptions) (interface{}, error) {
238+
func (c *Config) CreateComponent(p Pluggable, opts *DecoderOptions) (any, error) {
239239
componentConfigure := withDecoderOptions(opts)
240240

241241
decodedConfig, err := componentConfigure(p, c.Decoder)

config/decode.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
type Decoder interface {
2626
// Decode decodes onto target given DecoderOptions.
2727
// The target argument must be a pointer to an allocated structure.
28-
Decode(opts *DecoderOptions, target interface{}) error
28+
Decode(opts *DecoderOptions, target any) error
2929
}
3030

3131
// DecoderOptions represent the options for a Decoder.
@@ -45,7 +45,7 @@ type hclDecoder struct {
4545
// The target argument must be a pointer to an allocated structure.
4646
// If the HCL input is nil, we assume there is nothing to do and the target
4747
// stays unaffected. If the target is nil, we assume is not decodable.
48-
func (h *hclDecoder) Decode(opts *DecoderOptions, target interface{}) error {
48+
func (h *hclDecoder) Decode(opts *DecoderOptions, target any) error {
4949
// Decoder Options cannot be missing
5050
if opts == nil {
5151
return errors.New("missing DecoderOptions for hclDecoder")
@@ -155,6 +155,6 @@ type defaultsDecoder struct{}
155155
// Decode for defaultsDecoder leaves the target unaffected.
156156
// The target argument must be a pointer to an allocated structure.
157157
// If the target is nil, we assume is not decodable.
158-
func (d *defaultsDecoder) Decode(opts *DecoderOptions, target interface{}) error {
158+
func (d *defaultsDecoder) Decode(opts *DecoderOptions, target any) error {
159159
return nil
160160
}

config/decode_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ test_string = "ateststring"
4141
testCases := []struct {
4242
TestName string
4343
DecoderOpts *DecoderOptions
44-
Target interface{}
45-
Expected interface{}
44+
Target any
45+
Expected any
4646
}{
4747
{
4848
"nil_target",
@@ -114,8 +114,8 @@ test_int = env("TEST_INT")
114114
testCases := []struct {
115115
TestName string
116116
DecoderOpts *DecoderOptions
117-
Target interface{}
118-
Expected interface{}
117+
Target any
118+
Expected any
119119
}{
120120
{
121121
"Hcl_eval_context_with_env_fun_and_var",

docs/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestMain(m *testing.M) {
3333

3434
var jsScriptPath = filepath.Join(assets.AssetsRootDir, "docs", "configuration", "transformations", "custom-scripts", "create-a-script-filter-example.js")
3535

36-
func checkComponentForZeros(t *testing.T, component interface{}) {
36+
func checkComponentForZeros(t *testing.T, component any) {
3737
assert := assert.New(t)
3838

3939
// Indirect dereferences the pointer for us

docs/configuration_source_docs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func testSourceConfig(t *testing.T, filepath string, fullExample bool) {
5555

5656
use := c.Data.Source.Use
5757

58-
var configObject interface{}
58+
var configObject any
5959
switch use.Name {
6060
case "kafka":
6161
configObject = &kafkasource.Configuration{}

docs/configuration_target_docs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func testFilterTargetConfig(t *testing.T, filepath string, fullExample bool) {
7474

7575
func testTargetComponent(t *testing.T, name string, body hcl.Body, fullExample bool) {
7676
assert := assert.New(t)
77-
var configObject interface{}
77+
var configObject any
7878
switch name {
7979
case "eventhub":
8080
configObject = &target.EventHubConfig{}

docs/configuration_transformations_docs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func testTransformationConfig(t *testing.T, filepath string, fullExample bool) {
141141
use := transformation.Use
142142

143143
// Pick the config to compare against
144-
var configObject interface{}
144+
var configObject any
145145
switch use.Name {
146146
case "spEnrichedFilter":
147147
configObject = &filter.AtomicFilterConfig{}

pkg/source/inmemory/in_memory_source.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ func configfunction(messages chan []string) func(c *configuration) (sourceiface.
4444
}
4545
}
4646

47-
type adapter func(i interface{}) (interface{}, error)
47+
type adapter func(i any) (any, error)
4848

49-
func (f adapter) Create(i interface{}) (interface{}, error) {
49+
func (f adapter) Create(i any) (any, error) {
5050
return f(i)
5151
}
5252

53-
func (f adapter) ProvideDefault() (interface{}, error) {
53+
func (f adapter) ProvideDefault() (any, error) {
5454
cfg := &configuration{}
5555

5656
return cfg, nil
5757
}
5858

5959
func adapterGenerator(f func(c *configuration) (sourceiface.Source, error)) adapter {
60-
return func(i interface{}) (interface{}, error) {
60+
return func(i any) (any, error) {
6161
cfg, ok := i.(*configuration)
6262
if !ok {
6363
return nil, errors.New("invalid input")

0 commit comments

Comments
 (0)