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

[cmd/githubgen] add distribution reports #29697

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/add_distribution_owners.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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. filelogreceiver)
component: githubgen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds a set of distribution reports that can be used to notify distribution maintainers of any changes to distributions.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [28628]

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

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# 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: []
15 changes: 15 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ testbed/ @open-telemetry/collect
testbed/mockdatareceivers/mockawsxrayreceiver/ @open-telemetry/collector-contrib-approvers @wangzlei @srprash
testbed/mockdatasenders/mockdatadogagentexporter/ @open-telemetry/collector-contrib-approvers @boostchicken

#####################################################
#
# List of distribution maintainers for OpenTelemetry Collector Contrib
#
#####################################################
reports/distributions/core.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/contrib.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/aws.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/grafana.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/observiq.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/redhat.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/splunk.yaml @open-telemetry/collector-contrib-approvers atoulme dmitryax hughesjj rfitzpatrick
reports/distributions/sumo.yaml @open-telemetry/collector-contrib-approvers
reports/distributions/liatrio.yaml @open-telemetry/collector-contrib-approvers


## UNMAINTAINED components

4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ jobs:
run: |
make genoteltestbedcol
git diff -s --exit-code || (echo 'Generated code is out of date, please run "make genoteltestbedcol" and commit the changes in this PR.' && exit 1)
- name: Gen distributions
run: |
make gendistributions
git diff -s --exit-code || (echo 'Generated code is out of date, please run "make gendistributions" and commit the changes in this PR.' && exit 1)
- name: CodeGen
run: |
make -j2 generate
Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,18 @@ mdatagen-test:
cd cmd/mdatagen && $(GOCMD) generate ./...
cd cmd/mdatagen && $(GOCMD) test ./...

.PHONY: gengithub
gengithub:
.PHONY: githubgen-install
githubgen-install:
cd cmd/githubgen && $(GOCMD) install .

.PHONY: gengithub
gengithub: githubgen-install
githubgen

.PHONY: gendistributions
gendistributions: githubgen-install
githubgen distributions

.PHONY: update-codeowners
update-codeowners: gengithub generate

Expand Down
2 changes: 1 addition & 1 deletion cmd/githubgen/allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ agoallikmaa
architjugran
asaharn
billmeyer
braydonk
emreyalvac
keep94
kiranmayib
Expand All @@ -22,3 +21,4 @@ am-kinetica
mcube8
sokoide
zdaratom
braydonk
atoulme marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions cmd/githubgen/codeowners.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ const codeownersHeader = `# Code generated by githubgen. DO NOT EDIT.
* @open-telemetry/collector-contrib-approvers
`

const distributionCodeownersHeader = `
#####################################################
#
# List of distribution maintainers for OpenTelemetry Collector Contrib
#
#####################################################
`

type codeownersGenerator struct {
}

Expand Down Expand Up @@ -140,6 +148,17 @@ LOOP:
}
}

codeowners += distributionCodeownersHeader
longestName := 0
for _, dist := range data.distributions {
if longestName < len(dist.Name) {
longestName = len(dist.Name)
}
}
for _, dist := range data.distributions {
codeowners += fmt.Sprintf("reports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers %s\n", dist.Name, strings.Repeat(" ", longestName-len(dist.Name)), strings.Join(dist.Maintainers, " "))
}

err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0600)
if err != nil {
return err
Expand Down
63 changes: 63 additions & 0 deletions cmd/githubgen/distributions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package main

import (
"fmt"
"os"
"path/filepath"
"sort"

"gopkg.in/yaml.v3"
)

type distributionsGenerator struct {
}

type distOutput struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Maintainers []string `yaml:"maintainers"`
Components map[string][]string `yaml:"components"`
}

func (cg distributionsGenerator) generate(data *githubData) error {
for _, dist := range data.distributions {
components := map[string][]string{}
for _, c := range data.components {
inDistro := false
for _, componentDistro := range c.Status.Distributions {
if dist.Name == componentDistro {
inDistro = true
break
}
}
if inDistro {
array, ok := components[c.Status.Class]
if !ok {
array = []string{}
}
components[c.Status.Class] = append(array, c.Type)
}
}
for _, comps := range components {
sort.Strings(comps)
}
output := distOutput{
Name: dist.Name,
URL: dist.URL,
Maintainers: dist.Maintainers,
Components: components,
}
b, err := yaml.Marshal(output)
if err != nil {
return nil
}
err = os.WriteFile(filepath.Join("reports", "distributions", fmt.Sprintf("%s.yaml", dist.Name)), b, 0600)
if err != nil {
return nil
}
}
return nil
}
2 changes: 1 addition & 1 deletion cmd/githubgen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.20
require (
github.com/google/go-github/v53 v53.2.0
go.opentelemetry.io/collector/confmap v0.91.0
gopkg.in/yaml.v3 v3.0.1
)

require (
Expand All @@ -27,5 +28,4 @@ require (
golang.org/x/sys v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
23 changes: 23 additions & 0 deletions cmd/githubgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"fmt"
"io/fs"
"log"
"os"
"path/filepath"
"sort"

"go.opentelemetry.io/collector/confmap/provider/fileprovider"
"gopkg.in/yaml.v3"
)

const unmaintainedStatus = "unmaintained"
Expand All @@ -25,6 +27,7 @@ type generator interface {
// .github/CODEOWNERS
// .github/ALLOWLIST
// .github/ISSUE_TEMPLATES/*.yaml (list of components)
// reports/distributions/*
func main() {
folder := flag.String("folder", ".", "folder investigated for codeowners")
allowlistFilePath := flag.String("allowlist", "cmd/githubgen/allowlist.txt", "path to a file containing an allowlist of members outside the OpenTelemetry organization")
Expand All @@ -36,6 +39,8 @@ func main() {
generators = append(generators, issueTemplatesGenerator{})
case "codeowners":
generators = append(generators, codeownersGenerator{})
case "distributions":
atoulme marked this conversation as resolved.
Show resolved Hide resolved
generators = append(generators, distributionsGenerator{})
default:
panic(fmt.Sprintf("Unknown generator: %s", arg))
}
Expand Down Expand Up @@ -71,12 +76,19 @@ type metadata struct {
Status *Status `mapstructure:"status"`
}

type distributionData struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Maintainers []string `yaml:"maintainers,omitempty"`
}

type githubData struct {
folders []string
codeowners []string
allowlistFilePath string
maxLength int
components map[string]metadata
distributions []distributionData
}

func loadMetadata(filePath string) (metadata, error) {
Expand Down Expand Up @@ -147,12 +159,23 @@ func run(folder string, allowlistFilePath string, generators []generator) error
}
sort.Strings(codeownersList)

var distributions []distributionData
dd, err := os.ReadFile(filepath.Join(folder, "distributions.yaml"))
if err != nil {
return err
}
err = yaml.Unmarshal(dd, &distributions)
if err != nil {
return err
}

data := &githubData{
folders: foldersList,
codeowners: codeownersList,
allowlistFilePath: allowlistFilePath,
maxLength: maxLength,
components: components,
distributions: distributions,
}

for _, g := range generators {
Expand Down
27 changes: 27 additions & 0 deletions distributions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# A 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 must be open source.
# - The link must point to a publicly accessible repository.
- name: core
url: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
- name: contrib
url: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
- name: aws
url: https://github.com/aws-observability/aws-otel-collector
- name: grafana
url: https://github.com/grafana/agent
- name: observiq
url: https://github.com/observIQ/observiq-otel-collector
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The observIQ distribution is now at https://github.com/observIQ/bindplane-agent, the original link will redirect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go ahead and open a PR to fix, and feel free to add yourself as maintainer so you can keep on top of this type of changes moving forward, thanks!

- name: redhat
url: https://github.com/os-observability/redhat-opentelemetry-collector
- name: splunk
url: https://github.com/signalfx/splunk-otel-collector
maintainers:
- atoulme
- dmitryax
- hughesjj
- rfitzpatrick
- name: sumo
url: https://github.com/SumoLogic/sumologic-otel-collector
- name: liatrio
url: https://github.com/liatrio/liatrio-otel-collector
46 changes: 46 additions & 0 deletions reports/distributions/aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: aws
url: https://github.com/aws-observability/aws-otel-collector
maintainers: []
components:
exporter:
- awsemf
- awsxray
- datadog
- dynatrace
- file
- kafka
- loadbalancing
- logzio
- prometheus
- prometheusremotewrite
- sapm
- signalfx
extension:
- awsproxy
- ecs_observer
- health_check
- pprof
- sigv4auth
processor:
- attributes
- cumulativetodelta
- deltatorate
- experimental_metricsgeneration
- filter
- groupbytrace
- k8sattributes
- metricstransform
- probabilistic_sampler
- resource
- resourcedetection
- span
- tail_sampling
receiver:
- awscontainerinsightreceiver
- awsecscontainermetrics
- awsxray
- jaeger
- kafka
- prometheus
- statsd
- zipkin
Loading