Skip to content

Commit 8e7efa2

Browse files
authored
Remove deprecated generated_component_telemetry_test file from being generated and delete it. (#12068)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent da5b68a commit 8e7efa2

12 files changed

+49
-795
lines changed

.chloggen/rm-dep-mdatagen.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove deprecated generated_component_telemetry_test file from being generated and delete it.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12068]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

cmd/mdatagen/internal/command.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"go/format"
11+
"io/fs"
1112
"os"
1213
"path/filepath"
1314
"regexp"
@@ -109,13 +110,14 @@ func run(ymlPath string) error {
109110
}
110111
}
111112

112-
toGenerate := map[string]string{}
113+
// TODO: Remove this after version v0.122.0 when all the deprecated code should be deleted.
114+
// https://github.com/open-telemetry/opentelemetry-collector/issues/12067
115+
if err = os.Remove(filepath.Join(ymlDir, "generated_component_telemetry_test.go")); err != nil && !errors.Is(err, fs.ErrNotExist) {
116+
return fmt.Errorf("unable to remove generated file \"generated_component_telemetry_test.go\": %w", err)
117+
}
113118

119+
toGenerate := map[string]string{}
114120
if len(md.Telemetry.Metrics) != 0 { // if there are telemetry metrics, generate telemetry specific files
115-
if err = generateFile(filepath.Join(tmplDir, "component_telemetry_test.go.tmpl"),
116-
filepath.Join(ymlDir, "generated_component_telemetry_test.go"), md, packageName); err != nil {
117-
return err
118-
}
119121
toGenerate[filepath.Join(tmplDir, "telemetry.go.tmpl")] = filepath.Join(codeDir, "generated_telemetry.go")
120122
toGenerate[filepath.Join(tmplDir, "telemetry_test.go.tmpl")] = filepath.Join(codeDir, "generated_telemetry_test.go")
121123
toGenerate[filepath.Join(tmplDir, "telemetrytest.go.tmpl")] = filepath.Join(testDir, "generated_telemetrytest.go")
@@ -405,7 +407,7 @@ func inlineReplace(tmplFile string, outputFile string, md Metadata, start string
405407
}
406408

407409
func generateFile(tmplFile string, outputFile string, md Metadata, goPackage string) error {
408-
if err := os.Remove(outputFile); err != nil && !errors.Is(err, os.ErrNotExist) {
410+
if err := os.Remove(outputFile); err != nil && !errors.Is(err, fs.ErrNotExist) {
409411
return fmt.Errorf("unable to remove generated file %q: %w", outputFile, err)
410412
}
411413

cmd/mdatagen/internal/embedded_templates_test.go

+16-17
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@ func TestEnsureTemplatesLoaded(t *testing.T) {
2121

2222
var (
2323
templateFiles = map[string]struct{}{
24-
path.Join(rootDir, "component_test.go.tmpl"): {},
25-
path.Join(rootDir, "component_telemetry_test.go.tmpl"): {},
26-
path.Join(rootDir, "documentation.md.tmpl"): {},
27-
path.Join(rootDir, "metrics.go.tmpl"): {},
28-
path.Join(rootDir, "metrics_test.go.tmpl"): {},
29-
path.Join(rootDir, "resource.go.tmpl"): {},
30-
path.Join(rootDir, "resource_test.go.tmpl"): {},
31-
path.Join(rootDir, "config.go.tmpl"): {},
32-
path.Join(rootDir, "config_test.go.tmpl"): {},
33-
path.Join(rootDir, "package_test.go.tmpl"): {},
34-
path.Join(rootDir, "readme.md.tmpl"): {},
35-
path.Join(rootDir, "status.go.tmpl"): {},
36-
path.Join(rootDir, "telemetry.go.tmpl"): {},
37-
path.Join(rootDir, "telemetry_test.go.tmpl"): {},
38-
path.Join(rootDir, "testdata", "config.yaml.tmpl"): {},
39-
path.Join(rootDir, "telemetrytest.go.tmpl"): {},
40-
path.Join(rootDir, "telemetrytest_test.go.tmpl"): {},
24+
path.Join(rootDir, "component_test.go.tmpl"): {},
25+
path.Join(rootDir, "documentation.md.tmpl"): {},
26+
path.Join(rootDir, "metrics.go.tmpl"): {},
27+
path.Join(rootDir, "metrics_test.go.tmpl"): {},
28+
path.Join(rootDir, "resource.go.tmpl"): {},
29+
path.Join(rootDir, "resource_test.go.tmpl"): {},
30+
path.Join(rootDir, "config.go.tmpl"): {},
31+
path.Join(rootDir, "config_test.go.tmpl"): {},
32+
path.Join(rootDir, "package_test.go.tmpl"): {},
33+
path.Join(rootDir, "readme.md.tmpl"): {},
34+
path.Join(rootDir, "status.go.tmpl"): {},
35+
path.Join(rootDir, "telemetry.go.tmpl"): {},
36+
path.Join(rootDir, "telemetry_test.go.tmpl"): {},
37+
path.Join(rootDir, "testdata", "config.yaml.tmpl"): {},
38+
path.Join(rootDir, "telemetrytest.go.tmpl"): {},
39+
path.Join(rootDir, "telemetrytest_test.go.tmpl"): {},
4140
}
4241
count = 0
4342
)

cmd/mdatagen/internal/samplereceiver/generated_component_telemetry_test.go

-86
This file was deleted.

cmd/mdatagen/internal/templates/component_telemetry_test.go.tmpl

-93
This file was deleted.

exporter/exporterhelper/generated_component_telemetry_test.go

-86
This file was deleted.

0 commit comments

Comments
 (0)