Skip to content

Commit da38bca

Browse files
committed
ci: validate component inventory
1 parent ed97697 commit da38bca

4 files changed

Lines changed: 156 additions & 88 deletions

File tree

Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ NRLICENSE := $(TOOLS_BIN_DIR)/nrlicense
1919

2020
DISTRIBUTIONS ?= "nrdot-collector,nrdot-collector-experimental"
2121

22-
ci: check manifests-check build build-fips version-check licenses-check
22+
ci: check manifests-check component-inventory-check build build-fips version-check licenses-check
2323
check: ensure-goreleaser-up-to-date
2424

2525
build: go ocb
@@ -42,9 +42,6 @@ goreleaser-verify: goreleaser
4242
ensure-goreleaser-up-to-date: generate-goreleaser
4343
@git diff -s --exit-code distributions/*/.goreleaser*.yaml || (echo "Check failed: The goreleaser templates have changed but the .goreleaser.yamls haven't. Run 'make generate-goreleaser' and update your PR." && exit 1)
4444

45-
validate-components:
46-
@./scripts/validate-components.sh
47-
4845
.PHONY: ocb
4946
ocb:
5047
ifeq (, $(shell command -v ocb 2>/dev/null))
@@ -185,4 +182,11 @@ manifests-check:
185182
echo "NRDOT Experimental manifest out of sync with Core. Diff:"; \
186183
echo "$${diff}"; \
187184
exit 1; \
188-
} || exit 0
185+
} || exit 0
186+
187+
# Check that each distro's component-inventory.yaml (if present) matches its manifest.yaml
188+
.PHONY: component-inventory-check
189+
component-inventory-check:
190+
@for distro in $$(echo ${DISTRIBUTIONS} | tr ',' ' ' | tr -d '"'); do \
191+
./scripts/validate-component-inventory.sh "$$distro" || exit 1; \
192+
done

distributions/nrdot-collector/component-inventory.md

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Component Inventory
2+
#
3+
# Maps each component in the `nrdot-collector` distribution to the use cases
4+
# that require it. As use cases evolve and begin to use components already
5+
# present in the distro, this list might become stale and need updating, so
6+
# it's not meant to be authoritative — it's best-effort context for maintainers.
7+
#
8+
# This file is validated against manifest.yaml by
9+
# scripts/validate-component-inventory.sh (run as part of `make ci`). Component
10+
# names must match the path suffix after /<category>/ in the manifest's gomod
11+
# value (e.g. `extension/observer/dockerobserver` -> `observer/dockerobserver`).
12+
#
13+
# Use-case legend:
14+
# Core - Core (not use-case specific)
15+
# Host - Host Monitoring
16+
# k8s - Kubernetes Monitoring
17+
# ATP - Host Monitoring with process metrics
18+
# Gateway - Gateway Mode
19+
# OHI - On-Host Integrations
20+
21+
receivers:
22+
dockerstatsreceiver: [OHI]
23+
elasticsearchreceiver: [OHI]
24+
filelogreceiver: [Host, k8s]
25+
hostmetricsreceiver: [Host, k8s, OHI]
26+
jmxreceiver: [OHI]
27+
k8seventsreceiver: [OHI, k8s]
28+
kafkametricsreceiver: [OHI]
29+
kubeletstatsreceiver: [OHI, k8s]
30+
nginxreceiver: [OHI]
31+
otlpreceiver: [Core]
32+
prometheusreceiver: [Gateway, k8s]
33+
rabbitmqreceiver: [OHI]
34+
receivercreator: [OHI]
35+
36+
processors:
37+
adaptivetelemetryprocessor: [ATP]
38+
attributesprocessor: [Core]
39+
batchprocessor: [Core]
40+
cumulativetodeltaprocessor: [Core]
41+
filterprocessor: [Core]
42+
groupbyattrsprocessor: [k8s, Gateway]
43+
k8sattributesprocessor: [k8s, ATP, OHI]
44+
memorylimiterprocessor: [Core]
45+
metricsgenerationprocessor: [k8s, ATP, OHI]
46+
metricstransformprocessor: [Core]
47+
resourcedetectionprocessor: [Core]
48+
resourceprocessor: [k8s, Gateway]
49+
spanprocessor: [Gateway]
50+
tailsamplingprocessor: [Gateway]
51+
transformprocessor: [Core]
52+
53+
exporters:
54+
debugexporter: [Core]
55+
loadbalancingexporter: [Gateway]
56+
otlpexporter: [Core]
57+
otlphttpexporter: [Core]
58+
59+
connectors:
60+
routingconnector: [Core]
61+
62+
extensions:
63+
healthcheckextension: [Core]
64+
observer/dockerobserver: [OHI]
65+
observer/hostobserver: [OHI]
66+
observer/k8sobserver: [OHI]
67+
68+
providers:
69+
envprovider: [Core]
70+
fileprovider: [Core]
71+
httpprovider: [Core]
72+
httpsprovider: [Core]
73+
yamlprovider: [Core]
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
# Validate that distributions/<distro>/component-inventory.yaml lists exactly
3+
# the components present in distributions/<distro>/manifest.yaml.
4+
#
5+
# Usage: scripts/validate-component-inventory.sh <distribution>
6+
#
7+
# Exits 0 if the inventory file does not exist (the check is opt-in per distro).
8+
# Exits 0 if every component category matches in both directions.
9+
# Exits 1 with a per-category diff when there is drift.
10+
11+
set -euo pipefail
12+
13+
if [[ $# -ne 1 ]]; then
14+
echo "usage: $0 <distribution>" >&2
15+
exit 2
16+
fi
17+
18+
DISTRO="$1"
19+
SRC_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
20+
DIR="${SRC_ROOT}/distributions/${DISTRO}"
21+
MANIFEST="${DIR}/manifest.yaml"
22+
INVENTORY="${DIR}/component-inventory.yaml"
23+
24+
if [[ ! -f "$INVENTORY" ]]; then
25+
echo "ℹ️ ${DISTRO}: no component-inventory.yaml, skipping check"
26+
exit 0
27+
fi
28+
29+
if [[ ! -f "$MANIFEST" ]]; then
30+
echo "${DISTRO}: manifest.yaml not found at ${MANIFEST}" >&2
31+
exit 1
32+
fi
33+
34+
# plural manifest section -> singular path segment used in gomod URLs
35+
CATEGORIES=(
36+
"receivers:receiver"
37+
"processors:processor"
38+
"exporters:exporter"
39+
"connectors:connector"
40+
"extensions:extension"
41+
"providers:provider"
42+
)
43+
44+
failed=0
45+
for entry in "${CATEGORIES[@]}"; do
46+
plural="${entry%%:*}"
47+
singular="${entry##*:}"
48+
49+
manifest_components=$(yq -r "
50+
.${plural}[]?.gomod
51+
| sub(\" v[0-9].*$\"; \"\")
52+
| sub(\".*/${singular}/\"; \"\")
53+
" "$MANIFEST" | sort -u)
54+
55+
inventory_components=$(yq -r "
56+
.${plural} // {} | keys | .[]
57+
" "$INVENTORY" | sort -u)
58+
59+
if ! diff_output=$(diff <(echo "$manifest_components") <(echo "$inventory_components")); then
60+
echo "${DISTRO} ${plural}: manifest and inventory disagree"
61+
echo "$diff_output" | sed 's/^/ /'
62+
failed=1
63+
fi
64+
done
65+
66+
if [[ $failed -eq 1 ]]; then
67+
echo
68+
echo " Manifest: ${MANIFEST}"
69+
echo " Inventory: ${INVENTORY}"
70+
echo " '<' lines are only in the manifest; '>' lines are only in the inventory."
71+
exit 1
72+
fi
73+
74+
echo "${DISTRO}: component inventory matches manifest"

0 commit comments

Comments
 (0)