Skip to content

Commit

Permalink
[mdatagen] use main as package for cmd types (open-telemetry#10130)
Browse files Browse the repository at this point in the history
This allows us to enabled package test generation for mdatagen itself
(and for telemetrygen in contrib)

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten authored and steves-canva committed Jun 13, 2024
1 parent 251542a commit 0bf40d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cmd/mdatagen/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

//go:generate mdatagen metadata.yaml

package main

import (
Expand Down Expand Up @@ -204,6 +206,9 @@ func templatize(tmplFile string, md metadata) *template.Template {
"isConnector": func() bool {
return md.Status.Class == "connector"
},
"isCommand": func() bool {
return md.Status.Class == "cmd"
},
"supportsLogs": func() bool {
for _, signals := range md.Status.Stability {
for _, s := range signals {
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ type: mdatagen

status:
class: cmd
stability:
alpha: [metrics]
codeowners:
active: [dmitryax]
2 changes: 1 addition & 1 deletion cmd/mdatagen/templates/package_test.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by mdatagen. DO NOT EDIT.

package {{ .Package }}
package {{ if isCommand -}}main{{ else }}{{ .Package }}{{- end }}

import (
"testing"
Expand Down

0 comments on commit 0bf40d3

Please sign in to comment.