From ad2dc45ea925bcf3f2b1fa35b970024a45d08401 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 9 Dec 2022 14:54:28 -0800 Subject: [PATCH] Remove deprecated funcs service.NewCommand and service.NewSvcHandler. (#6722) Signed-off-by: Bogdan Drutu Signed-off-by: Bogdan Drutu --- .chloggen/rmlllllll.yaml | 11 ++++++++ {service => otelcol}/collector_windows.go | 5 ++-- {service => otelcol}/command.go | 4 +-- {service => otelcol}/command_components.go | 2 +- .../command_components_test.go | 4 +-- {service => otelcol}/flags.go | 2 +- {service => otelcol}/flags_test.go | 2 +- otelcol/moved.go | 27 ++++++++++++++++--- otelcol/moved_windows.go | 25 ----------------- 9 files changed, 43 insertions(+), 39 deletions(-) create mode 100755 .chloggen/rmlllllll.yaml rename {service => otelcol}/collector_windows.go (97%) rename {service => otelcol}/command.go (94%) rename {service => otelcol}/command_components.go (96%) rename {service => otelcol}/command_components_test.go (94%) rename {service => otelcol}/flags.go (97%) rename {service => otelcol}/flags_test.go (99%) delete mode 100644 otelcol/moved_windows.go diff --git a/.chloggen/rmlllllll.yaml b/.chloggen/rmlllllll.yaml new file mode 100755 index 000000000000..3ec34be10632 --- /dev/null +++ b/.chloggen/rmlllllll.yaml @@ -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] diff --git a/service/collector_windows.go b/otelcol/collector_windows.go similarity index 97% rename from service/collector_windows.go rename to otelcol/collector_windows.go index c4ea72e18c6a..025d930afd6d 100644 --- a/service/collector_windows.go +++ b/otelcol/collector_windows.go @@ -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" @@ -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()} } @@ -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) diff --git a/service/command.go b/otelcol/command.go similarity index 94% rename from service/command.go rename to otelcol/command.go index 372c14c9cab0..c56a90791f03 100644 --- a/service/command.go +++ b/otelcol/command.go @@ -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" @@ -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 } diff --git a/service/command_components.go b/otelcol/command_components.go similarity index 96% rename from service/command_components.go rename to otelcol/command_components.go index afc78fefafae..2776ca0128fa 100644 --- a/service/command_components.go +++ b/otelcol/command_components.go @@ -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" diff --git a/service/command_components_test.go b/otelcol/command_components_test.go similarity index 94% rename from service/command_components_test.go rename to otelcol/command_components_test.go index a4d9f5c119e1..892825b0d45d 100644 --- a/service/command_components_test.go +++ b/otelcol/command_components_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package service +package otelcol import ( "bytes" @@ -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) { @@ -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"}) diff --git a/service/flags.go b/otelcol/flags.go similarity index 97% rename from service/flags.go rename to otelcol/flags.go index 7d7637589ae1..4de2f08b854e 100644 --- a/service/flags.go +++ b/otelcol/flags.go @@ -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" diff --git a/service/flags_test.go b/otelcol/flags_test.go similarity index 99% rename from service/flags_test.go rename to otelcol/flags_test.go index 9661fc342f96..3a8e3bd40287 100644 --- a/service/flags_test.go +++ b/otelcol/flags_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package service +package otelcol import ( "testing" diff --git a/otelcol/moved.go b/otelcol/moved.go index dbf84776bf1d..ee42d85d2727 100644 --- a/otelcol/moved.go +++ b/otelcol/moved.go @@ -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" ) @@ -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 +} diff --git a/otelcol/moved_windows.go b/otelcol/moved_windows.go deleted file mode 100644 index b90eb9fc625a..000000000000 --- a/otelcol/moved_windows.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build windows -// +build windows - -package otelcol // import "go.opentelemetry.io/collector/otelcol" - -import ( - "go.opentelemetry.io/collector/service" -) - -// NewSvcHandler constructs a new svc.Handler using the given CollectorSettings. -var NewSvcHandler = service.NewSvcHandler //nolint:staticcheck