Skip to content

Commit

Permalink
Remove deprecated generated_component_telemetry_test file from being …
Browse files Browse the repository at this point in the history
…generated and delete it. (#12068)

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Jan 10, 2025
1 parent da5b68a commit 8e7efa2
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 795 deletions.
25 changes: 25 additions & 0 deletions .chloggen/rm-dep-mdatagen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# 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: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Remove deprecated generated_component_telemetry_test file from being generated and delete it.

# One or more tracking issues or pull requests related to the change
issues: [12068]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [api]
14 changes: 8 additions & 6 deletions cmd/mdatagen/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"go/format"
"io/fs"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -109,13 +110,14 @@ func run(ymlPath string) error {
}
}

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

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

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

Expand Down
33 changes: 16 additions & 17 deletions cmd/mdatagen/internal/embedded_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,22 @@ func TestEnsureTemplatesLoaded(t *testing.T) {

var (
templateFiles = map[string]struct{}{
path.Join(rootDir, "component_test.go.tmpl"): {},
path.Join(rootDir, "component_telemetry_test.go.tmpl"): {},
path.Join(rootDir, "documentation.md.tmpl"): {},
path.Join(rootDir, "metrics.go.tmpl"): {},
path.Join(rootDir, "metrics_test.go.tmpl"): {},
path.Join(rootDir, "resource.go.tmpl"): {},
path.Join(rootDir, "resource_test.go.tmpl"): {},
path.Join(rootDir, "config.go.tmpl"): {},
path.Join(rootDir, "config_test.go.tmpl"): {},
path.Join(rootDir, "package_test.go.tmpl"): {},
path.Join(rootDir, "readme.md.tmpl"): {},
path.Join(rootDir, "status.go.tmpl"): {},
path.Join(rootDir, "telemetry.go.tmpl"): {},
path.Join(rootDir, "telemetry_test.go.tmpl"): {},
path.Join(rootDir, "testdata", "config.yaml.tmpl"): {},
path.Join(rootDir, "telemetrytest.go.tmpl"): {},
path.Join(rootDir, "telemetrytest_test.go.tmpl"): {},
path.Join(rootDir, "component_test.go.tmpl"): {},
path.Join(rootDir, "documentation.md.tmpl"): {},
path.Join(rootDir, "metrics.go.tmpl"): {},
path.Join(rootDir, "metrics_test.go.tmpl"): {},
path.Join(rootDir, "resource.go.tmpl"): {},
path.Join(rootDir, "resource_test.go.tmpl"): {},
path.Join(rootDir, "config.go.tmpl"): {},
path.Join(rootDir, "config_test.go.tmpl"): {},
path.Join(rootDir, "package_test.go.tmpl"): {},
path.Join(rootDir, "readme.md.tmpl"): {},
path.Join(rootDir, "status.go.tmpl"): {},
path.Join(rootDir, "telemetry.go.tmpl"): {},
path.Join(rootDir, "telemetry_test.go.tmpl"): {},
path.Join(rootDir, "testdata", "config.yaml.tmpl"): {},
path.Join(rootDir, "telemetrytest.go.tmpl"): {},
path.Join(rootDir, "telemetrytest_test.go.tmpl"): {},
}
count = 0
)
Expand Down

This file was deleted.

93 changes: 0 additions & 93 deletions cmd/mdatagen/internal/templates/component_telemetry_test.go.tmpl

This file was deleted.

86 changes: 0 additions & 86 deletions exporter/exporterhelper/generated_component_telemetry_test.go

This file was deleted.

Loading

0 comments on commit 8e7efa2

Please sign in to comment.