From 32537cfcadcbd30974719dd8b98059b727dc3471 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Thu, 30 Dec 2021 10:51:30 -0800 Subject: [PATCH] builder: Remove deprecated include-core flag Signed-off-by: Bogdan Drutu --- cmd/builder/internal/builder/config.go | 13 +---- .../builder/templates/components.go.tmpl | 50 ++++--------------- cmd/builder/internal/command.go | 6 --- cmd/otelcorecol/components.go | 37 ++++---------- 4 files changed, 23 insertions(+), 83 deletions(-) diff --git a/cmd/builder/internal/builder/config.go b/cmd/builder/internal/builder/config.go index e2e2f83f133..92252c49523 100644 --- a/cmd/builder/internal/builder/config.go +++ b/cmd/builder/internal/builder/config.go @@ -54,10 +54,8 @@ type Distribution struct { Go string `mapstructure:"go"` Description string `mapstructure:"description"` OtelColVersion string `mapstructure:"otelcol_version"` - // IncludeCore is deprecated and note that if this is being used, it will be removed in a subsequent release - IncludeCore bool `mapstructure:"include_core"` - OutputPath string `mapstructure:"output_path"` - Version string `mapstructure:"version"` + OutputPath string `mapstructure:"output_path"` + Version string `mapstructure:"version"` } // Module represents a receiver, exporter, processor or extension for the distribution @@ -102,13 +100,6 @@ func (c *Config) Validate() error { c.Distribution.Go = path } - // create a warning message that include_core is deprecated and will be removed in a subsequent release - if c.Distribution.IncludeCore { - c.Logger.Warn("IncludeCore is deprecated. Starting from v0.41.0, you need to include all components explicitly.") - } else { - c.Logger.Info("IncludeCore is deprecated, starting from v0.41.0. The new behavior won't affect your distribution, just remove the option from the manifest.") - } - c.Logger.Info("Using go", zap.String("go-executable", c.Distribution.Go)) return nil diff --git a/cmd/builder/internal/builder/templates/components.go.tmpl b/cmd/builder/internal/builder/templates/components.go.tmpl index f98b1dd74b8..0188bfa90d5 100644 --- a/cmd/builder/internal/builder/templates/components.go.tmpl +++ b/cmd/builder/internal/builder/templates/components.go.tmpl @@ -16,72 +16,44 @@ import ( {{- range .Receivers}} {{.Name}} "{{.Import}}" {{- end}} - {{- if .Distribution.IncludeCore}} - "go.opentelemetry.io/collector/service/defaultcomponents" - {{- end}} ) func components() (component.Factories, error) { var err error - var factories component.Factories - - {{- if .Distribution.IncludeCore}} - factories, err = defaultcomponents.Components() - if err != nil { - return component.Factories{}, err - } - {{- else}} - factories = component.Factories{} - {{- end}} + factories := component.Factories{} - extensions := []component.ExtensionFactory{ + factories.Extensions, err = component.MakeExtensionFactoryMap( {{- range .Extensions}} {{.Name}}.NewFactory(), {{- end}} - } - for _, ext := range factories.Extensions { - extensions = append(extensions, ext) - } - factories.Extensions, err = component.MakeExtensionFactoryMap(extensions...) + ) if err != nil { return component.Factories{}, err } - receivers := []component.ReceiverFactory{ + factories.Receivers, err = component.MakeReceiverFactoryMap( {{- range .Receivers}} - {{.Name}}.NewFactory(), - {{- end}} - } - for _, rcv := range factories.Receivers { - receivers = append(receivers, rcv) - } - factories.Receivers, err = component.MakeReceiverFactoryMap(receivers...) + {{.Name}}.NewFactory(), + {{- end}} + ) if err != nil { return component.Factories{}, err } - exporters := []component.ExporterFactory{ + factories.Exporters, err = component.MakeExporterFactoryMap( {{- range .Exporters}} {{.Name}}.NewFactory(), {{- end}} - } - for _, exp := range factories.Exporters { - exporters = append(exporters, exp) - } - factories.Exporters, err = component.MakeExporterFactoryMap(exporters...) + ) if err != nil { return component.Factories{}, err } - processors := []component.ProcessorFactory{ + factories.Processors, err = component.MakeProcessorFactoryMap( {{- range .Processors}} {{.Name}}.NewFactory(), {{- end}} - } - for _, pr := range factories.Processors { - processors = append(processors, pr) - } - factories.Processors, err = component.MakeProcessorFactoryMap(processors...) + ) if err != nil { return component.Factories{}, err } diff --git a/cmd/builder/internal/command.go b/cmd/builder/internal/command.go index b499f8bda1a..ced26b5e5a4 100644 --- a/cmd/builder/internal/command.go +++ b/cmd/builder/internal/command.go @@ -61,12 +61,6 @@ func Command() (*cobra.Command, error) { cmd.Flags().StringVar(&cfg.Distribution.Name, "name", "otelcol-custom", "The executable name for the OpenTelemetry Collector distribution") cmd.Flags().StringVar(&cfg.Distribution.Description, "description", "Custom OpenTelemetry Collector distribution", "A descriptive name for the OpenTelemetry Collector distribution") cmd.Flags().StringVar(&cfg.Distribution.Version, "version", "1.0.0", "The version for the OpenTelemetry Collector distribution") - // IncludeCore is deprecated and will be removed in a subsequent release - cmd.Flags().BoolVar(&cfg.Distribution.IncludeCore, "include-core", true, "Deprecated: starting from v0.41.0, core components are not going to be implicitly included.") - if err := cmd.Flags().MarkDeprecated("include-core", "IncludeCore is deprecated, please explicitly list all the components required"); err != nil { - cfg.Logger.Error("failed to mark the IncludeCore flag is deprecated", zap.Error(err)) - return nil, err - } cmd.Flags().StringVar(&cfg.Distribution.OtelColVersion, "otelcol-version", cfg.Distribution.OtelColVersion, "Which version of OpenTelemetry Collector to use as base") cmd.Flags().StringVar(&cfg.Distribution.OutputPath, "output-path", cfg.Distribution.OutputPath, "Where to write the resulting files") cmd.Flags().StringVar(&cfg.Distribution.Go, "go", "", "The Go binary to use during the compilation phase. Default: go from the PATH") diff --git a/cmd/otelcorecol/components.go b/cmd/otelcorecol/components.go index 8d09a104a08..f6e364893ab 100644 --- a/cmd/otelcorecol/components.go +++ b/cmd/otelcorecol/components.go @@ -16,53 +16,36 @@ import ( func components() (component.Factories, error) { var err error - var factories component.Factories - factories = component.Factories{} + factories := component.Factories{} - extensions := []component.ExtensionFactory{ + factories.Extensions, err = component.MakeExtensionFactoryMap( ballastextension.NewFactory(), zpagesextension.NewFactory(), - } - for _, ext := range factories.Extensions { - extensions = append(extensions, ext) - } - factories.Extensions, err = component.MakeExtensionFactoryMap(extensions...) + ) if err != nil { return component.Factories{}, err } - receivers := []component.ReceiverFactory{ - otlpreceiver.NewFactory(), - } - for _, rcv := range factories.Receivers { - receivers = append(receivers, rcv) - } - factories.Receivers, err = component.MakeReceiverFactoryMap(receivers...) + factories.Receivers, err = component.MakeReceiverFactoryMap( + otlpreceiver.NewFactory(), + ) if err != nil { return component.Factories{}, err } - exporters := []component.ExporterFactory{ + factories.Exporters, err = component.MakeExporterFactoryMap( loggingexporter.NewFactory(), otlpexporter.NewFactory(), otlphttpexporter.NewFactory(), - } - for _, exp := range factories.Exporters { - exporters = append(exporters, exp) - } - factories.Exporters, err = component.MakeExporterFactoryMap(exporters...) + ) if err != nil { return component.Factories{}, err } - processors := []component.ProcessorFactory{ + factories.Processors, err = component.MakeProcessorFactoryMap( batchprocessor.NewFactory(), memorylimiterprocessor.NewFactory(), - } - for _, pr := range factories.Processors { - processors = append(processors, pr) - } - factories.Processors, err = component.MakeProcessorFactoryMap(processors...) + ) if err != nil { return component.Factories{}, err }