Skip to content

Commit

Permalink
Remove deprecated funcs service.NewCommand and service.NewSvcHandler. (
Browse files Browse the repository at this point in the history
…#6722)

Signed-off-by: Bogdan Drutu <[email protected]>

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Dec 9, 2022
1 parent 9153f82 commit ad2dc45
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 39 deletions.
11 changes: 11 additions & 0 deletions .chloggen/rmlllllll.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: service

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated funcs `service.NewCommand` and `service.NewSvcHandler`.

# One or more tracking issues or pull requests related to the change
issues: [5564]
5 changes: 2 additions & 3 deletions service/collector_windows.go → otelcol/collector_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//go:build windows
// +build windows

package service // import "go.opentelemetry.io/collector/service"
package otelcol // import "go.opentelemetry.io/collector/otelcol"

import (
"context"
Expand All @@ -40,7 +40,6 @@ type windowsService struct {
}

// NewSvcHandler constructs a new svc.Handler using the given CollectorSettings.
// Deprecated: [v0.67.0] use otelcol.NewSvcHandler
func NewSvcHandler(set CollectorSettings) svc.Handler {
return &windowsService{settings: set, flags: flags()}
}
Expand Down Expand Up @@ -159,7 +158,7 @@ func newWithWindowsEventLogCore(set CollectorSettings, flags *flag.FlagSet, elog
[]zap.Option{zap.WrapCore(withWindowsCore(elog))},
set.LoggingOptions...,
)
return New(set)
return NewCollector(set)
}

var _ zapcore.Core = (*windowsEventLogCore)(nil)
Expand Down
4 changes: 2 additions & 2 deletions service/command.go → otelcol/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package service // import "go.opentelemetry.io/collector/service"
package otelcol // import "go.opentelemetry.io/collector/otelcol"

import (
"errors"
Expand Down Expand Up @@ -46,7 +46,7 @@ func NewCommand(set CollectorSettings) *cobra.Command {
return err
}
}
col, err := New(set)
col, err := NewCollector(set)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package service // import "go.opentelemetry.io/collector/service"
package otelcol // import "go.opentelemetry.io/collector/otelcol"

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package service
package otelcol

import (
"bytes"
Expand All @@ -26,7 +26,6 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/featuregate"
)

func TestNewBuildSubCommand(t *testing.T) {
Expand All @@ -40,7 +39,6 @@ func TestNewBuildSubCommand(t *testing.T) {
BuildInfo: component.NewDefaultBuildInfo(),
Factories: factories,
ConfigProvider: cfgProvider,
telemetry: newColTelemetry(featuregate.NewRegistry()),
}
cmd := NewCommand(set)
cmd.SetArgs([]string{"components"})
Expand Down
2 changes: 1 addition & 1 deletion service/flags.go → otelcol/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package service // import "go.opentelemetry.io/collector/service"
package otelcol // import "go.opentelemetry.io/collector/otelcol"

import (
"errors"
Expand Down
2 changes: 1 addition & 1 deletion service/flags_test.go → otelcol/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package service
package otelcol

import (
"testing"
Expand Down
27 changes: 24 additions & 3 deletions otelcol/moved.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
package otelcol // import "go.opentelemetry.io/collector/otelcol"

import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/confmap/converter/expandconverter"
"go.opentelemetry.io/collector/confmap/provider/envprovider"
"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"go.opentelemetry.io/collector/confmap/provider/httpprovider"
"go.opentelemetry.io/collector/confmap/provider/yamlprovider"
"go.opentelemetry.io/collector/service"
)

Expand Down Expand Up @@ -62,8 +68,23 @@ type ConfigProviderSettings = service.ConfigProviderSettings //nolint:staticchec
// * Then unmarshalls the confmap.Conf into the service Config.
var NewConfigProvider = service.NewConfigProvider //nolint:staticcheck

// NewCommand constructs a new cobra.Command using the given CollectorSettings.
var NewCommand = service.NewCommand //nolint:staticcheck

// Config defines the configuration for the various elements of collector or agent.
type Config = service.Config //nolint:staticcheck

func newDefaultConfigProviderSettings(uris []string) ConfigProviderSettings {
return ConfigProviderSettings{
ResolverSettings: confmap.ResolverSettings{
URIs: uris,
Providers: makeMapProvidersMap(fileprovider.New(), envprovider.New(), yamlprovider.New(), httpprovider.New()),
Converters: []confmap.Converter{expandconverter.New()},
},
}
}

func makeMapProvidersMap(providers ...confmap.Provider) map[string]confmap.Provider {
ret := make(map[string]confmap.Provider, len(providers))
for _, provider := range providers {
ret[provider.Scheme()] = provider
}
return ret
}
25 changes: 0 additions & 25 deletions otelcol/moved_windows.go

This file was deleted.

0 comments on commit ad2dc45

Please sign in to comment.