Skip to content

Commit

Permalink
Move service/parserprovider package to config/configmapprovider (open…
Browse files Browse the repository at this point in the history
  • Loading branch information
mx-psi authored Oct 29, 2021
1 parent caf69e6 commit ac6f16f
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## 🛑 Breaking changes 🛑

- Move `service/parserprovider` package to `config/configmapprovider` (#4206)

## v0.38.0 Beta

## 🛑 Breaking changes 🛑
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider
package configmapprovider

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider
package configmapprovider

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider
package configmapprovider

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider
package configmapprovider

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package parserprovider // import "go.opentelemetry.io/collector/service/parserprovider"
package configmapprovider // import "go.opentelemetry.io/collector/config/configmapprovider"

import (
"go.opentelemetry.io/collector/config"
Expand Down
4 changes: 2 additions & 2 deletions config/configtest/configtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configmapprovider"
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/service/parserprovider"
)

// The regular expression for valid config field tag.
Expand All @@ -35,7 +35,7 @@ var configFieldTagRegExp = regexp.MustCompile("^[a-z0-9][a-z0-9_]*$")
// LoadConfig loads a config from file, and does NOT validate the configuration.
func LoadConfig(fileName string, factories component.Factories) (*config.Config, error) {
// Read yaml config from file
cp, err := parserprovider.NewExpandMapProvider(parserprovider.NewFileMapProvider(fileName)).Retrieve(context.Background())
cp, err := configmapprovider.NewExpandMapProvider(configmapprovider.NewFileMapProvider(fileName)).Retrieve(context.Background())
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/configmapprovider"
"go.opentelemetry.io/collector/config/configunmarshaler"
"go.opentelemetry.io/collector/internal/testutil"
"go.opentelemetry.io/collector/service/defaultcomponents"
"go.opentelemetry.io/collector/service/internal/builder"
"go.opentelemetry.io/collector/service/internal/extensions"
"go.opentelemetry.io/collector/service/parserprovider"
)

const configStr = `
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestCollector_StartAsGoRoutine(t *testing.T) {
set := CollectorSettings{
BuildInfo: component.NewDefaultBuildInfo(),
Factories: factories,
ConfigMapProvider: parserprovider.NewInMemoryMapProvider(strings.NewReader(configStr)),
ConfigMapProvider: configmapprovider.NewInMemoryMapProvider(strings.NewReader(configStr)),
}
col, err := New(set)
require.NoError(t, err)
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestCollector_Start(t *testing.T) {
col, err := New(CollectorSettings{
BuildInfo: component.NewDefaultBuildInfo(),
Factories: factories,
ConfigMapProvider: parserprovider.NewFileMapProvider("testdata/otelcol-config.yaml"),
ConfigMapProvider: configmapprovider.NewFileMapProvider("testdata/otelcol-config.yaml"),
LoggingOptions: []zap.Option{zap.Hooks(hook)},
})
require.NoError(t, err)
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestCollector_ReportError(t *testing.T) {
col, err := New(CollectorSettings{
BuildInfo: component.NewDefaultBuildInfo(),
Factories: factories,
ConfigMapProvider: parserprovider.NewFileMapProvider("testdata/otelcol-config.yaml"),
ConfigMapProvider: configmapprovider.NewFileMapProvider("testdata/otelcol-config.yaml"),
})
require.NoError(t, err)

Expand Down Expand Up @@ -302,7 +302,7 @@ func TestCollector_reloadService(t *testing.T) {
},
{
name: "retire_service_ok_load_ok",
parserProvider: parserprovider.NewInMemoryMapProvider(strings.NewReader(configStr)),
parserProvider: configmapprovider.NewInMemoryMapProvider(strings.NewReader(configStr)),
service: &service{
telemetry: componenttest.NewNopTelemetrySettings(),
builtExporters: builder.Exporters{},
Expand Down
4 changes: 2 additions & 2 deletions service/collector_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"golang.org/x/sys/windows/svc"
"golang.org/x/sys/windows/svc/eventlog"

"go.opentelemetry.io/collector/service/parserprovider"
"go.opentelemetry.io/collector/config/configmapprovider"
)

type WindowsService struct {
Expand Down Expand Up @@ -133,7 +133,7 @@ func openEventLog(serviceName string) (*eventlog.Log, error) {

func newWithWindowsEventLogCore(set CollectorSettings, elog *eventlog.Log) (*Collector, error) {
if set.ConfigMapProvider == nil {
set.ConfigMapProvider = parserprovider.NewDefaultMapProvider(getConfigFlag(), getSetFlag())
set.ConfigMapProvider = configmapprovider.NewDefaultMapProvider(getConfigFlag(), getSetFlag())
}
set.LoggingOptions = append(
set.LoggingOptions,
Expand Down
4 changes: 2 additions & 2 deletions service/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package service // import "go.opentelemetry.io/collector/service"
import (
"github.com/spf13/cobra"

"go.opentelemetry.io/collector/service/parserprovider"
"go.opentelemetry.io/collector/config/configmapprovider"
)

// NewCommand constructs a new cobra.Command using the given Collector.
Expand All @@ -29,7 +29,7 @@ func NewCommand(set CollectorSettings) *cobra.Command {
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if set.ConfigMapProvider == nil {
set.ConfigMapProvider = parserprovider.NewDefaultMapProvider(getConfigFlag(), getSetFlag())
set.ConfigMapProvider = configmapprovider.NewDefaultMapProvider(getConfigFlag(), getSetFlag())
}
col, err := New(set)
if err != nil {
Expand Down

0 comments on commit ac6f16f

Please sign in to comment.