Skip to content

Commit

Permalink
[mdatagen]: Add otlp as supported distribution (#11527)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Oct 23, 2024
1 parent 1a5cb64 commit 7a52d7c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
25 changes: 25 additions & 0 deletions .chloggen/add-otlp-distro.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: enhancement

# 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: Add otlp as supported distribution

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

# (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: [user]
6 changes: 2 additions & 4 deletions cmd/mdatagen/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ func templatize(tmplFile string, md Metadata) *template.Template {
}
return result
},
"inc": func(i int) int { return i + 1 },
"distroURL": func(name string) string {
return Distros[name]
},
"inc": func(i int) int { return i + 1 },
"distroURL": distroURL,
"isExporter": func() bool {
return md.Status.Class == "exporter"
},
Expand Down
20 changes: 14 additions & 6 deletions cmd/mdatagen/internal/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ import (
"go.opentelemetry.io/collector/component"
)

// Distros is a collection of distributions that can be referenced in the metadata.yaml files.
// distroURL returns the collection of distributions that can be referenced in the metadata.yaml files.
// The rules below apply to every distribution added to this list:
// - The distribution is open source and maintained by the OpenTelemetry project.
// - The link must point to a publicly accessible repository.
var Distros = map[string]string{
"core": "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol",
"contrib": "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib",
"k8s": "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s",
"otlp": "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-otlp",
func distroURL(name string) string {
switch name {
case "core":
return "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol"
case "contrib":
return "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib"
case "k8s":
return "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s"
case "otlp":
return "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-otlp"
default:
return ""
}
}

type Codeowners struct {
Expand Down
33 changes: 33 additions & 0 deletions cmd/mdatagen/internal/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ import (
"github.com/stretchr/testify/assert"
)

func TestDistroURL(t *testing.T) {
tests := []struct {
input string
output string
}{
{
input: "core",
output: "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol",
},
{
input: "contrib",
output: "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib",
},
{
input: "k8s",
output: "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s",
},
{
input: "otlp",
output: "https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-otlp",
},
{
input: "not_found",
output: "",
},
}
for _, test := range tests {
t.Run(test.input, func(t *testing.T) {
assert.Equal(t, test.output, distroURL(test.input))
})
}
}

func TestSortedDistributions(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 7a52d7c

Please sign in to comment.