Skip to content

Commit

Permalink
Move default unmarshaler to service to avoid using deprecate configs. (
Browse files Browse the repository at this point in the history
…#6395)

Remove deprecated config.Service.

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Oct 27, 2022
1 parent 3262fd8 commit 07603a0
Show file tree
Hide file tree
Showing 22 changed files with 356 additions and 501 deletions.
11 changes: 11 additions & 0 deletions .chloggen/mvunmarshaler.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: config

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove already deprecates `config.Service`.

# One or more tracking issues or pull requests related to the change
issues: [6395]
17 changes: 0 additions & 17 deletions config/moved_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@

package config // import "go.opentelemetry.io/collector/config"

import (
"go.opentelemetry.io/collector/service/telemetry"
)

// Service defines the configurable components of the service.
// Deprecated: [v0.52.0] Use service.ConfigService
type Service struct {
// Telemetry is the configuration for collector's own telemetry.
Telemetry telemetry.Config `mapstructure:"telemetry"`

// Extensions are the ordered list of extensions configured for the service.
Extensions []ComponentID `mapstructure:"extensions"`

// Pipelines are the set of data pipelines configured for the service.
Pipelines map[ComponentID]*Pipeline `mapstructure:"pipelines"`
}

// Pipeline defines a single pipeline.
// Deprecated: [v0.52.0] Use service.ConfigServicePipeline
type Pipeline struct {
Expand Down
13 changes: 12 additions & 1 deletion service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"

"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/service/telemetry"
)

var (
Expand Down Expand Up @@ -151,6 +152,16 @@ func (cfg *Config) validateService() error {
return nil
}

type ConfigService = config.Service
// ConfigService defines the configurable components of the service.
type ConfigService struct {
// Telemetry is the configuration for collector's own telemetry.
Telemetry telemetry.Config `mapstructure:"telemetry"`

// Extensions are the ordered list of extensions configured for the service.
Extensions []config.ComponentID `mapstructure:"extensions"`

// Pipelines are the set of data pipelines configured for the service.
Pipelines map[config.ComponentID]*ConfigServicePipeline `mapstructure:"pipelines"`
}

type ConfigServicePipeline = config.Pipeline
5 changes: 2 additions & 3 deletions service/config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"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/internal/configunmarshaler"
)

// ConfigProvider provides the service configuration.
Expand Down Expand Up @@ -105,8 +104,8 @@ func (cm *configProvider) Get(ctx context.Context, factories component.Factories
return nil, fmt.Errorf("cannot resolve the configuration: %w", err)
}

cfg, err := configunmarshaler.Unmarshal(conf, factories)
if err != nil {
var cfg *configSettings
if cfg, err = unmarshal(conf, factories); err != nil {
return nil, fmt.Errorf("cannot unmarshal the configuration: %w", err)
}

Expand Down
102 changes: 0 additions & 102 deletions service/internal/configunmarshaler/defaultunmarshaler.go

This file was deleted.

157 changes: 0 additions & 157 deletions service/internal/configunmarshaler/defaultunmarshaler_test.go

This file was deleted.

30 changes: 30 additions & 0 deletions service/internal/configunmarshaler/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

package configunmarshaler // import "go.opentelemetry.io/collector/service/internal/configunmarshaler"

import (
"fmt"
"reflect"

"go.opentelemetry.io/collector/config"
)

func errorUnknownType(component string, id config.ComponentID, factories []reflect.Value) error {
return fmt.Errorf("unknown %s type: %q for id: %q (valid values: %v)", component, id.Type(), id, factories)
}

func errorUnmarshalError(component string, id config.ComponentID, err error) error {
return fmt.Errorf("error reading %s configuration for %q: %w", component, id, err)
}

This file was deleted.

Loading

0 comments on commit 07603a0

Please sign in to comment.