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

builder: Remove deprecated include-core flag #4616

Merged
merged 4 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Remove deprecated consumererror.Combine (#4597)
- Remove `configmapprovider.NewDefault`, `configmapprovider.NewExpand`, `configmapprovider.NewMerge` (#4600)
- Move `configtest.LoadConfig` and `configtest.LoadConfigAndValidate` to `servicetest` (#4606)
- Builder: Remove deprecated `include-core` flag (#4616)

## 💡 Enhancements 💡

Expand Down
13 changes: 2 additions & 11 deletions cmd/builder/internal/builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
50 changes: 11 additions & 39 deletions cmd/builder/internal/builder/templates/components.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 0 additions & 6 deletions cmd/builder/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
dist:
module: go.opentelemetry.io/collector/builder/test/nocore
otelcol_version: 0.40.0
include_core: false
otelcol_version: 0.41.0

extensions:
- import: go.opentelemetry.io/collector/extension/zpagesextension
gomod: go.opentelemetry.io/collector v0.41.0

receivers:
- import: go.opentelemetry.io/collector/receiver/otlpreceiver
gomod: go.opentelemetry.io/collector v0.40.0
gomod: go.opentelemetry.io/collector v0.41.0

exporters:
- import: go.opentelemetry.io/collector/exporter/loggingexporter
gomod: go.opentelemetry.io/collector v0.40.0
extensions:
- import: go.opentelemetry.io/collector/extension/zpagesextension
gomod: go.opentelemetry.io/collector v0.40.0
gomod: go.opentelemetry.io/collector v0.41.0
File renamed without changes.
18 changes: 15 additions & 3 deletions cmd/builder/test/replaces.builder.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
dist:
module: go.opentelemetry.io/collector/builder/test/replaces
otelcol_version: 0.40.0
otelcol_version: 0.41.0

extensions:
- import: go.opentelemetry.io/collector/extension/zpagesextension
gomod: go.opentelemetry.io/collector v0.41.0

receivers:
- import: go.opentelemetry.io/collector/receiver/otlpreceiver
gomod: go.opentelemetry.io/collector v0.41.0

processors:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/routingprocessor v0.40.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.40.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/routingprocessor v0.41.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor v0.41.0

exporters:
- import: go.opentelemetry.io/collector/exporter/loggingexporter
gomod: go.opentelemetry.io/collector v0.41.0

replaces:
- github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.40.0
37 changes: 10 additions & 27 deletions cmd/otelcorecol/components.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.