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/journald] remove duplicate function NewFactory and pass checkapi #29005

Merged
merged 1 commit into from
Nov 14, 2023
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 @@ -2,5 +2,4 @@ connector/servicegraphconnector
extension/encoding
extension/observer
processor/servicegraphprocessor
receiver/journaldreceiver
receiver/kafkareceiver
13 changes: 13 additions & 0 deletions receiver/journaldreceiver/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 journaldreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver"

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

// NewFactory creates a factory for journald receiver
func NewFactory() receiver.Factory {
return newFactoryAdapter()
}
19 changes: 19 additions & 0 deletions receiver/journaldreceiver/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 journaldreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver"

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver/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/journaldreceiver/journald.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/journaldreceiver/internal/metadata"
)

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

Expand Down
4 changes: 2 additions & 2 deletions receiver/journaldreceiver/journald_nonlinux.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/journaldreceiver/internal/metadata"
)

// NewFactory creates a dummy factory.
func NewFactory() receiver.Factory {
// newFactoryAdapter creates a dummy factory.
func newFactoryAdapter() receiver.Factory {
return receiver.NewFactory(
metadata.Type,
createDefaultConfig,
Expand Down
4 changes: 2 additions & 2 deletions receiver/journaldreceiver/journald_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
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 @@ -40,7 +40,7 @@ func TestLoadConfig(t *testing.T) {

func TestInputConfigFailure(t *testing.T) {
sink := new(consumertest.LogsSink)
factory := NewFactory()
factory := newFactoryAdapter()
badCfg := &JournaldConfig{
BaseConfig: adapter.BaseConfig{
Operators: []operator.Config{},
Expand Down