Skip to content

Commit ad13eee

Browse files
author
Hyunuk Lim
committed
fix: revert all the renamed variables
1 parent 73f1397 commit ad13eee

File tree

19 files changed

+40
-40
lines changed

19 files changed

+40
-40
lines changed

component/experimental/component/factory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type ConfigSourceFactory interface {
4444
// configuration and should not cause side-effects that prevent the creation
4545
// of multiple instances of the Source.
4646
// The object returned by this method needs to pass the checks implemented by
47-
// 'configtest.CheckConfigStruct'. It is recommended to have such check in the
47+
// 'configtest.ValidateConfig'. It is recommended to have such check in the
4848
// tests of any implementation of the ConfigSourceFactory interface.
4949
CreateDefaultConfig() config.Source
5050

component/exporter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type ExporterFactory interface {
7070
// configuration and should not cause side-effects that prevent the creation
7171
// of multiple instances of the Exporter.
7272
// The object returned by this method needs to pass the checks implemented by
73-
// 'configtest.CheckConfigStruct'. It is recommended to have these checks in the
73+
// 'configtest.ValidateConfig'. It is recommended to have these checks in the
7474
// tests of any implementation of the Factory interface.
7575
CreateDefaultConfig() config.Exporter
7676

component/extension.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type ExtensionFactory interface {
6969
// configuration and should not cause side-effects that prevent the creation
7070
// of multiple instances of the Extension.
7171
// The object returned by this method needs to pass the checks implemented by
72-
// 'configtest.CheckConfigStruct'. It is recommended to have these checks in the
72+
// 'configtest.ValidateConfig'. It is recommended to have these checks in the
7373
// tests of any implementation of the Factory interface.
7474
CreateDefaultConfig() config.Extension
7575

component/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type ProcessorFactory interface {
7575
// configuration and should not cause side-effects that prevent the creation
7676
// of multiple instances of the Processor.
7777
// The object returned by this method needs to pass the checks implemented by
78-
// 'configtest.CheckConfigStruct'. It is recommended to have these checks in the
78+
// 'configtest.ValidateConfig'. It is recommended to have these checks in the
7979
// tests of any implementation of the Factory interface.
8080
CreateDefaultConfig() config.Processor
8181

component/receiver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type ReceiverFactory interface {
7979
// configuration and should not cause side-effects that prevent the creation
8080
// of multiple instances of the Receiver.
8181
// The object returned by this method needs to pass the checks implemented by
82-
// 'configtest.CheckConfigStruct'. It is recommended to have these checks in the
82+
// 'configtest.ValidateConfig'. It is recommended to have these checks in the
8383
// tests of any implementation of the Factory interface.
8484
CreateDefaultConfig() config.Receiver
8585

config/configcheck/configcheck.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,28 @@ import (
2020
"go.opentelemetry.io/collector/consumer/consumererror"
2121
)
2222

23-
// CheckConfigStructFromFactories checks if all configurations for the given factories
23+
// ValidateConfigFromFactories checks if all configurations for the given factories
2424
// are satisfying the patterns used by the collector.
25-
func CheckConfigStructFromFactories(factories component.Factories) error {
25+
func ValidateConfigFromFactories(factories component.Factories) error {
2626
var errs []error
2727

2828
for _, factory := range factories.Receivers {
29-
if err := configtest.CheckConfigStruct(factory.CreateDefaultConfig()); err != nil {
29+
if err := configtest.ValidateConfig(factory.CreateDefaultConfig()); err != nil {
3030
errs = append(errs, err)
3131
}
3232
}
3333
for _, factory := range factories.Processors {
34-
if err := configtest.CheckConfigStruct(factory.CreateDefaultConfig()); err != nil {
34+
if err := configtest.ValidateConfig(factory.CreateDefaultConfig()); err != nil {
3535
errs = append(errs, err)
3636
}
3737
}
3838
for _, factory := range factories.Exporters {
39-
if err := configtest.CheckConfigStruct(factory.CreateDefaultConfig()); err != nil {
39+
if err := configtest.ValidateConfig(factory.CreateDefaultConfig()); err != nil {
4040
errs = append(errs, err)
4141
}
4242
}
4343
for _, factory := range factories.Extensions {
44-
if err := configtest.CheckConfigStruct(factory.CreateDefaultConfig()); err != nil {
44+
if err := configtest.ValidateConfig(factory.CreateDefaultConfig()); err != nil {
4545
errs = append(errs, err)
4646
}
4747
}

config/configcheck/configcheck_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ import (
2525
"go.opentelemetry.io/collector/service/defaultcomponents"
2626
)
2727

28-
func TestCheckConfigStructFromFactories_Success(t *testing.T) {
28+
func TestValidateConfigFromFactories_Success(t *testing.T) {
2929
factories, err := defaultcomponents.Components()
3030
require.NoError(t, err)
3131

32-
err = CheckConfigStructFromFactories(factories)
32+
err = ValidateConfigFromFactories(factories)
3333
require.NoError(t, err)
3434
}
3535

36-
func TestCheckConfigStructFromFactories_Failure(t *testing.T) {
36+
func TestValidateConfigFromFactories_Failure(t *testing.T) {
3737
factories, err := defaultcomponents.Components()
3838
require.NoError(t, err)
3939

4040
// Add a factory returning config not following pattern to force error.
4141
f := &badConfigExtensionFactory{}
4242
factories.Extensions[f.Type()] = f
4343

44-
err = CheckConfigStructFromFactories(factories)
44+
err = ValidateConfigFromFactories(factories)
4545
require.Error(t, err)
4646
}
4747

config/configtest/configtest.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ func LoadConfigAndValidate(fileName string, factories component.Factories) (*con
5050
return cfg, cfg.Validate()
5151
}
5252

53-
// CheckConfigStruct enforces that given configuration object is following the patterns
53+
// ValidateConfig enforces that given configuration object is following the patterns
5454
// used by the collector. This ensures consistency between different implementations
5555
// of components and extensions. It is recommended for implementers of components
5656
// to call this function on their tests passing the default configuration of the
5757
// component factory.
58-
func CheckConfigStruct(config interface{}) error {
58+
func ValidateConfig(config interface{}) error {
5959
t := reflect.TypeOf(config)
6060
if t.Kind() == reflect.Ptr {
6161
t = t.Elem()
@@ -65,18 +65,18 @@ func CheckConfigStruct(config interface{}) error {
6565
return fmt.Errorf("config must be a struct or a pointer to one, the passed object is a %s", t.Kind())
6666
}
6767

68-
return CheckConfigStructDataType(t)
68+
return validateConfigDataType(t)
6969
}
7070

71-
// CheckConfigStructDataType performs a descending validation of the given type.
71+
// validateConfigDataType performs a descending validation of the given type.
7272
// If the type is a struct it goes to each of its fields to check for the proper
7373
// tags.
74-
func CheckConfigStructDataType(t reflect.Type) error {
74+
func validateConfigDataType(t reflect.Type) error {
7575
var errs []error
7676

7777
switch t.Kind() {
7878
case reflect.Ptr:
79-
if err := CheckConfigStructDataType(t.Elem()); err != nil {
79+
if err := validateConfigDataType(t.Elem()); err != nil {
8080
errs = append(errs, err)
8181
}
8282
case reflect.Struct:
@@ -158,11 +158,11 @@ func checkStructFieldTags(f reflect.StructField) error {
158158
switch f.Type.Kind() {
159159
case reflect.Struct:
160160
// It is another struct, continue down-level.
161-
return CheckConfigStructDataType(f.Type)
161+
return validateConfigDataType(f.Type)
162162

163163
case reflect.Map, reflect.Slice, reflect.Array:
164164
// The element of map, array, or slice can be itself a configuration object.
165-
return CheckConfigStructDataType(f.Type.Elem())
165+
return validateConfigDataType(f.Type.Elem())
166166

167167
default:
168168
fieldTag := tagParts[0]

config/configtest/configtest_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ func TestLoadConfigAndValidate(t *testing.T) {
8282
assert.Equal(t, cfg, cfgValidate)
8383
}
8484

85-
func TestCheckConfigStructPointerAndValue(t *testing.T) {
85+
func TestValidateConfigPointerAndValue(t *testing.T) {
8686
config := struct {
8787
SomeFiled string `mapstructure:"test"`
8888
}{}
89-
assert.NoError(t, CheckConfigStruct(config))
90-
assert.NoError(t, CheckConfigStruct(&config))
89+
assert.NoError(t, ValidateConfig(config))
90+
assert.NoError(t, ValidateConfig(&config))
9191
}
9292

93-
func TestCheckConfigStruct(t *testing.T) {
93+
func TestValidateConfig(t *testing.T) {
9494
type BadConfigTag struct {
9595
BadTagField int `mapstructure:"test-dash"`
9696
}
@@ -206,7 +206,7 @@ func TestCheckConfigStruct(t *testing.T) {
206206

207207
for _, tt := range tests {
208208
t.Run(tt.name, func(t *testing.T) {
209-
err := CheckConfigStruct(tt.config)
209+
err := ValidateConfig(tt.config)
210210
if tt.wantErrMsgSubStr == "" {
211211
assert.NoError(t, err)
212212
} else {

exporter/loggingexporter/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestCreateDefaultConfig(t *testing.T) {
2828
factory := NewFactory()
2929
cfg := factory.CreateDefaultConfig()
3030
assert.NotNil(t, cfg, "failed to create default config")
31-
assert.NoError(t, configtest.CheckConfigStruct(cfg))
31+
assert.NoError(t, configtest.ValidateConfig(cfg))
3232
}
3333

3434
func TestCreateMetricsExporter(t *testing.T) {

0 commit comments

Comments
 (0)