Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore][receiver/windowseventlog] remove duplicate function NewFactory and pass checkapi #29020

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/checkapi/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ processor/servicegraphprocessor
receiver/dockerstatsreceiver
receiver/journaldreceiver
receiver/kafkareceiver
receiver/windowseventlogreceiver
13 changes: 13 additions & 0 deletions receiver/windowseventlogreceiver/factory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package windowseventlogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver"

import (
"go.opentelemetry.io/collector/receiver"
)

// NewFactory creates a factory for windowseventlog receiver
func NewFactory() receiver.Factory {
return newFactoryAdapter()
}
19 changes: 19 additions & 0 deletions receiver/windowseventlogreceiver/factory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package windowseventlogreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver"

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver/internal/metadata"
)

func TestNewFactory(t *testing.T) {
t.Run("NewFactoryCorrectType", func(t *testing.T) {
factory := NewFactory()
require.EqualValues(t, metadata.Type, factory.Type())
})
}
4 changes: 2 additions & 2 deletions receiver/windowseventlogreceiver/receiver_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver/internal/metadata"
)

// NewFactory creates a factory for windowseventlog receiver
func NewFactory() receiver.Factory {
// newFactoryAdapter creates a dummy factory for windowseventlog receiver
func newFactoryAdapter() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
Expand Down
2 changes: 1 addition & 1 deletion receiver/windowseventlogreceiver/receiver_others_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

func TestDefaultConfigFailure(t *testing.T) {
factory := NewFactory()
factory := newFactoryAdapter()
cfg := factory.CreateDefaultConfig()
require.NotNil(t, cfg, "failed to create default config")
require.NoError(t, componenttest.CheckConfigStruct(cfg))
Expand Down
4 changes: 2 additions & 2 deletions receiver/windowseventlogreceiver/receiver_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver/internal/metadata"
)

// NewFactory creates a factory for windowseventlog receiver
func NewFactory() receiver.Factory {
// newFactoryAdapter creates a factory for windowseventlog receiver
func newFactoryAdapter() receiver.Factory {
return adapter.NewFactory(ReceiverType{}, metadata.LogsStability)
}

Expand Down
14 changes: 7 additions & 7 deletions receiver/windowseventlogreceiver/receiver_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

func TestDefaultConfig(t *testing.T) {
factory := NewFactory()
factory := newFactoryAdapter()
cfg := factory.CreateDefaultConfig()
require.NotNil(t, cfg, "failed to create default config")
require.NoError(t, componenttest.CheckConfigStruct(cfg))
Expand All @@ -39,7 +39,7 @@ func TestDefaultConfig(t *testing.T) {
func TestLoadConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)
factory := NewFactory()
factory := newFactoryAdapter()
cfg := factory.CreateDefaultConfig()

sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
Expand All @@ -60,7 +60,7 @@ func TestCreateWithInvalidInputConfig(t *testing.T) {
}(),
}

_, err := NewFactory().CreateLogsReceiver(
_, err := newFactoryAdapter().CreateLogsReceiver(
context.Background(),
receivertest.NewNopCreateSettings(),
cfg,
Expand All @@ -73,7 +73,7 @@ func TestReadWindowsEventLogger(t *testing.T) {
logMessage := "Test log"

ctx := context.Background()
factory := NewFactory()
factory := newFactoryAdapter()
createSettings := receivertest.NewNopCreateSettings()
cfg := createTestConfig()
sink := new(consumertest.LogsSink)
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestReadWindowsEventLoggerRaw(t *testing.T) {
logMessage := "Test log"

ctx := context.Background()
factory := NewFactory()
factory := newFactoryAdapter()
createSettings := receivertest.NewNopCreateSettings()
cfg := createTestConfig()
cfg.InputConfig.Raw = true
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestReadWindowsEventLoggerWithExcludeProvider(t *testing.T) {
src := "otel"

ctx := context.Background()
factory := NewFactory()
factory := newFactoryAdapter()
createSettings := receivertest.NewNopCreateSettings()
cfg := createTestConfig()
cfg.InputConfig.ExcludeProviders = []string{src}
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestReadWindowsEventLoggerRawWithExcludeProvider(t *testing.T) {
src := "otel"

ctx := context.Background()
factory := NewFactory()
factory := newFactoryAdapter()
createSettings := receivertest.NewNopCreateSettings()
cfg := createTestConfig()
cfg.InputConfig.Raw = true
Expand Down