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

Replace path.Join method with filepath.Join method #6980

Merged
merged 10 commits into from
Feb 7, 2022
6 changes: 3 additions & 3 deletions cmd/configschema/docsgen/docsgen/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package docsgen

import (
"os"
"path"
"path/filepath"
"strings"
"testing"
"text/template"
Expand All @@ -39,7 +39,7 @@ import (

func TestWriteConfigDoc(t *testing.T) {
cfg := otlpreceiver.NewFactory().CreateDefaultConfig()
root := path.Join("..", "..", "..", "..")
root := filepath.Join("..", "..", "..", "..")
dr := configschema.NewDirResolver(root, configschema.DefaultModule)
outputFilename := ""
tmpl := testTemplate(t)
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestHandleCLI_All(t *testing.T) {
func testHandleCLI(t *testing.T, cs component.Factories, wr *fakeFilesystemWriter, args []string) {
stdoutWriter := &fakeIOWriter{}
tmpl := testTemplate(t)
dr := configschema.NewDirResolver(path.Join("..", "..", "..", ".."), configschema.DefaultModule)
dr := configschema.NewDirResolver(filepath.Join("..", "..", "..", ".."), configschema.DefaultModule)
handleCLI(cs, dr, tmpl, wr.writeFile, stdoutWriter, args...)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/configschema/docsgen/docsgen/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package docsgen
import (
"encoding/json"
"io/ioutil"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -35,7 +35,7 @@ func TestTableTemplate(t *testing.T) {
}

func testDataField(t *testing.T) *configschema.Field {
jsonBytes, err := ioutil.ReadFile(path.Join("testdata", "otlp-receiver.json"))
jsonBytes, err := ioutil.ReadFile(filepath.Join("testdata", "otlp-receiver.json"))
require.NoError(t, err)
field := configschema.Field{}
err = json.Unmarshal(jsonBytes, &field)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mdatagen/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package main

import (
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -107,7 +107,7 @@ func Test_loadMetadata(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := loadMetadata(path.Join("testdata", tt.yml))
got, err := loadMetadata(filepath.Join("testdata", tt.yml))
if tt.wantErr != "" {
require.Error(t, err)
require.EqualError(t, err, tt.wantErr)
Expand Down
10 changes: 5 additions & 5 deletions cmd/mdatagen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package main
import (
"io/ioutil"
"os"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -75,7 +75,7 @@ func Test_runContents(t *testing.T) {
require.NoError(t, os.RemoveAll(tmpdir))
})

metadataFile := path.Join(tmpdir, "metadata.yaml")
metadataFile := filepath.Join(tmpdir, "metadata.yaml")
require.NoError(t, ioutil.WriteFile(metadataFile, []byte(tt.args.yml), 0600))

err = run(metadataFile, tt.args.useExpGen)
Expand All @@ -85,13 +85,13 @@ func Test_runContents(t *testing.T) {
} else {
require.NoError(t, err)

genFilePath := path.Join(tmpdir, "internal/metadata/generated_metrics.go")
genFilePath := filepath.Join(tmpdir, "internal/metadata/generated_metrics.go")
if tt.args.useExpGen {
genFilePath = path.Join(tmpdir, "internal/metadata/generated_metrics_v2.go")
genFilePath = filepath.Join(tmpdir, "internal/metadata/generated_metrics_v2.go")
}
require.FileExists(t, genFilePath)

require.FileExists(t, path.Join(tmpdir, "documentation.md"))
require.FileExists(t, filepath.Join(tmpdir, "documentation.md"))
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions exporter/alibabacloudlogserviceexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package alibabacloudlogserviceexporter

import (
"context"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -32,7 +32,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package alibabacloudlogserviceexporter

import (
"context"
"path"
"path/filepath"
"testing"
"time"

Expand Down Expand Up @@ -72,7 +72,7 @@ func TestSTSTokenExporter(t *testing.T) {
Endpoint: "us-west-1.log.aliyuncs.com",
Project: "demo-project",
Logstore: "demo-logstore",
TokenFilePath: path.Join(".", "testdata", "config.yaml"),
TokenFilePath: filepath.Join("testdata", "config.yaml"),
})
assert.NoError(t, err)
require.NotNil(t, got)
Expand Down
12 changes: 6 additions & 6 deletions exporter/awscloudwatchlogsexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package awscloudwatchlogsexporter

import (
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -34,7 +34,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down Expand Up @@ -89,15 +89,15 @@ func TestFailedLoadConfig(t *testing.T) {
factory := NewFactory()
factories.Exporters[typeStr] = factory

_, err = servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "missing_required_field_1_config.yaml"), factories)
_, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "missing_required_field_1_config.yaml"), factories)
assert.EqualError(t, err, "exporter \"awscloudwatchlogs\" has invalid configuration: 'log_stream_name' must be set")

_, err = servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "missing_required_field_2_config.yaml"), factories)
_, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "missing_required_field_2_config.yaml"), factories)
assert.EqualError(t, err, "exporter \"awscloudwatchlogs\" has invalid configuration: 'log_group_name' must be set")

_, err = servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "invalid_queue_size.yaml"), factories)
_, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "invalid_queue_size.yaml"), factories)
assert.EqualError(t, err, "exporter \"awscloudwatchlogs\" has invalid configuration: 'sending_queue.queue_size' must be 1 or greater")

_, err = servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "invalid_queue_setting.yaml"), factories)
_, err = servicetest.LoadConfigAndValidate(filepath.Join("testdata", "invalid_queue_setting.yaml"), factories)
assert.EqualError(t, err, "error reading exporters configuration for \"awscloudwatchlogs\": 1 error(s) decoding:\n\n* 'sending_queue' has invalid keys: enabled, num_consumers")
}
4 changes: 2 additions & 2 deletions exporter/awsemfexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package awsemfexporter

import (
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -35,7 +35,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
6 changes: 3 additions & 3 deletions exporter/awsemfexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package awsemfexporter

import (
"context"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -39,7 +39,7 @@ func TestCreateTracesExporter(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)

ctx := context.Background()
Expand All @@ -53,7 +53,7 @@ func TestCreateMetricsExporter(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)

ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions exporter/awskinesisexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package awskinesisexporter

import (
"path"
"path/filepath"
"testing"
"time"

Expand All @@ -36,7 +36,7 @@ func TestDefaultConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "default.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "default.yaml"), factories)
require.NoError(t, err)
require.NotNil(t, cfg)

Expand Down Expand Up @@ -67,7 +67,7 @@ func TestConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[factory.Type()] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
4 changes: 2 additions & 2 deletions exporter/awsprometheusremotewriteexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package awsprometheusremotewriteexporter

import (
"path"
"path/filepath"
"testing"
"time"

Expand All @@ -38,7 +38,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
4 changes: 2 additions & 2 deletions exporter/awsxrayexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package awsxrayexporter

import (
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
6 changes: 3 additions & 3 deletions exporter/awsxrayexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package awsxrayexporter

import (
"context"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestCreateTracesExporter(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)

ctx := context.Background()
Expand All @@ -69,7 +69,7 @@ func TestCreateMetricsExporter(t *testing.T) {
require.NoError(t, err)
factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)
require.NoError(t, err)

ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuremonitorexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package azuremonitorexporter

import (
"path"
"path/filepath"
"testing"
"time"

Expand All @@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
4 changes: 2 additions & 2 deletions exporter/carbonexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package carbonexporter

import (
"context"
"path"
"path/filepath"
"testing"
"time"

Expand All @@ -33,7 +33,7 @@ func TestLoadConfig(t *testing.T) {

factory := NewFactory()
factories.Exporters[typeStr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "testdata", "config.yaml"), factories)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("testdata", "config.yaml"), factories)

require.NoError(t, err)
require.NotNil(t, cfg)
Expand Down
7 changes: 4 additions & 3 deletions exporter/coralogixexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package coralogixexporter // import "github.com/open-telemetry/opentelemetry-col

import (
"context"
"path"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -34,7 +34,8 @@ func TestLoadConfig(t *testing.T) {
factories, _ := componenttest.NopFactories()
factory := NewFactory()
factories.Exporters[typestr] = factory
cfg, err := servicetest.LoadConfigAndValidate(path.Join(".", "example", "config.yaml"), factories)
// t.Log("new exporter " + typestr)
cfg, err := servicetest.LoadConfigAndValidate(filepath.Join("example", "config.yaml"), factories)
require.NoError(t, err)
apiConfig := cfg.Exporters[config.NewComponentID(typestr)].(*Config)
err = apiConfig.Validate()
Expand Down Expand Up @@ -68,7 +69,7 @@ func TestExporter(t *testing.T) {
factories, _ := componenttest.NopFactories()
factory := NewFactory()
factories.Exporters[typestr] = factory
cfg, _ := servicetest.LoadConfigAndValidate(path.Join(".", "example", "config.yaml"), factories)
cfg, _ := servicetest.LoadConfigAndValidate(filepath.Join("example", "config.yaml"), factories)
apiConfig := cfg.Exporters[config.NewComponentID(typestr)].(*Config)
params := componenttest.NewNopExporterCreateSettings()
te := newCoralogixExporter(apiConfig, params)
Expand Down
Loading