Skip to content

Commit

Permalink
listcomponents: introduce new internal tool to list components (#129)
Browse files Browse the repository at this point in the history
This tool lists all registered components with their stability.
  • Loading branch information
rfratto authored Apr 5, 2024
1 parent 33a9a9d commit b5a2fbf
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions internal/cmd/listcomponents/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Command listcomponents dumps the list of known Alloy components with their
// stability.
package main

import (
"fmt"
"os"
"sort"
"strconv"
"text/tabwriter"

"github.com/grafana/alloy/internal/component"

_ "github.com/grafana/alloy/internal/component/all" // Import all component definitions
)

func main() {
components := component.AllNames()
sort.Strings(components)

tw := tabwriter.NewWriter(os.Stdout, 0, 8, 0, '\t', 0)
defer func() { _ = tw.Flush() }()

for _, name := range components {
reg, ok := component.Get(name)
if !ok {
// Not possible, but we'll ignore it anyway.
continue
}

stability, _ := strconv.Unquote(reg.Stability.String())
fmt.Fprintf(tw, "%s\t%s\n", reg.Name, stability)
}
}

0 comments on commit b5a2fbf

Please sign in to comment.