Skip to content

Commit 81dfc4c

Browse files
authored
Merge pull request #802 from jetstack/list-cluster-resources
Add command for dumping resources which are watched by default
2 parents 6d79743 + b90a0ba commit 81dfc4c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

make/ngts/02_mod.mk

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,19 @@ ngts-generate:
6161
helm_chart_source_dir=deploy/charts/discovery-agent
6262

6363
shared_generate_targets += ngts-generate
64+
65+
.PHONY: list-discovery-resources
66+
## Dump all discovery-agent k8s-dynamic resource types to a markdown list
67+
## @category NGTS Discovery Agent
68+
list-discovery-resources: $(NEEDS_HELM) $(NEEDS_YQ)
69+
@# First, template out the chart using dummy values for the required values
70+
@# Then extract config.yaml, and extract all "k8s-dynamic" data gatherers
71+
@# Then print "- [group/]version resource" with the first letter of resource captialised in awk
72+
@$(HELM) template discovery-agent deploy/charts/discovery-agent \
73+
--set-string config.tsgID=1234123412 \
74+
--set config.clusterName=foo | \
75+
$(YQ) '.data."config.yaml"' | \
76+
$(YQ) '.data-gatherers[] | select(.kind == "k8s-dynamic") | .config.resource-type' -o json | \
77+
jq -r 'if .group then "\(.group)/\(.version) \(.resource)" else "\(.version) \(.resource)" end' | \
78+
awk '{$$NF = toupper(substr($$NF,1,1)) substr($$NF,2); print "- " $$0}' | \
79+
sort

0 commit comments

Comments
 (0)