Skip to content

Commit

Permalink
builder: Remove deprecated include-core flag
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Dec 30, 2021
1 parent 3db1d11 commit 32537cf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 83 deletions.
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
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.

0 comments on commit 32537cf

Please sign in to comment.