Skip to content

Commit 3f44ad0

Browse files
authored
Merge pull request #2344 from mrueg/template-readme
docs: Template the README file
2 parents fa5eb67 + 97b10ea commit 3f44ad0

File tree

9 files changed

+2038
-16
lines changed

9 files changed

+2038
-16
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
make install-tools
107107
108-
- name: Check that all metrics are documented
108+
- name: Check that all metrics are documented and templates have no delta
109109
run: |
110110
make doccheck
111111

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ lint-fix: fix-markdown-format
5050
golangci-lint run --fix -v
5151

5252

53-
doccheck: generate
53+
doccheck: generate validate-template
5454
@echo "- Checking if the generated documentation is up to date..."
5555
@git diff --exit-code
5656
@echo "- Checking if the documentation is in sync with the code..."
@@ -87,6 +87,12 @@ lint-markdown-format:
8787
fix-markdown-format:
8888
${DOCKER_CLI} run -v "${PWD}:/workdir" davidanson/markdownlint-cli2:v${MARKDOWNLINT_CLI2_VERSION} --fix --config .markdownlint-cli2.jsonc
8989

90+
generate-template:
91+
gomplate -d config=./data.yaml --file README.md.tpl > README.md
92+
93+
validate-template: generate-template
94+
git diff --no-ext-diff --quiet --exit-code README.md
95+
9096
# Runs benchmark tests on the current git ref and the last release and compares
9197
# the two.
9298
test-benchmark-compare:
@@ -129,7 +135,7 @@ clean:
129135
e2e:
130136
./tests/e2e.sh
131137

132-
generate: build-local
138+
generate: build-local generate-template
133139
@echo ">> generating docs"
134140
@./scripts/generate-help-text.sh
135141
embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print`
@@ -172,4 +178,4 @@ install-promtool:
172178
@wget -qO- "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}.tar.gz" |\
173179
tar xvz --strip-components=1 prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}/promtool
174180

175-
.PHONY: all build build-local all-push all-container container container-* do-push-* sub-push-* push push-multi-arch test-unit test-rules test-benchmark-compare clean e2e validate-modules shellcheck licensecheck lint lint-fix generate embedmd
181+
.PHONY: all build build-local all-push all-container container container-* do-push-* sub-push-* push push-multi-arch test-unit test-rules test-benchmark-compare clean e2e validate-modules shellcheck licensecheck lint lint-fix generate generate-template validate-template embedmd

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ the raw metrics. Note that the metrics exposed on the `/metrics` endpoint
2929
reflect the current state of the Kubernetes cluster. When Kubernetes objects
3030
are deleted they are no longer visible on the `/metrics` endpoint.
3131

32+
> [!NOTE]
33+
> This README is generated from a [template](./README.md.tpl). Please make your changes there and run `make generate-template`.
34+
3235
## Table of Contents
3336

3437
* [Versioning](#versioning)

README.md.tpl

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.

RELEASE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Maintaining the release branches for older minor releases happens on a best effo
1717
* Bump the version in the `VERSION` file in the root of the repository.
1818
* Run `make examples`, which will re-generate all example manifests to use the new version.
1919
* Make a PR to update:
20-
* [Compatibility matrix](README.md#compatibility-matrix)
20+
* Update the [[`data.yaml`](data.yaml)
21+
* Run `make generate`, which will update the compatibility matrix in README.md
2122
* Changelog entry
2223
* Only include user relevant changes
2324
* Entries in the [`CHANGELOG.md`](CHANGELOG.md) are meant to be in this order:

data.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# List at max 5 releases here + the main branch
2+
compat:
3+
- version: "v2.7.0"
4+
kubernetes: "1.25"
5+
- version: "v2.8.2"
6+
kubernetes: "1.26"
7+
- version: "v2.9.2"
8+
kubernetes: "1.26"
9+
- version: "v2.10.1"
10+
kubernetes: "1.27"
11+
- version: "v2.11.0"
12+
kubernetes: "1.28"
13+
- version: "main"
14+
kubernetes: "1.29"

tools/go.mod

Lines changed: 129 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,153 @@
11
module k8s.io/kube-state-metrics/v2/tools
22

3-
go 1.19
3+
go 1.21
44

55
require (
66
github.com/brancz/gojsontoyaml v0.1.0
77
github.com/campoy/embedmd v1.0.0
88
github.com/google/go-jsonnet v0.20.0
9+
github.com/hairyhenderson/gomplate/v3 v3.11.7
910
github.com/jsonnet-bundler/jsonnet-bundler v0.5.1
1011
golang.org/x/perf v0.0.0-20231127181059-b53752263861
1112
)
1213

1314
require (
15+
cloud.google.com/go v0.110.7 // indirect
16+
cloud.google.com/go/compute v1.23.0 // indirect
17+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
18+
cloud.google.com/go/iam v1.1.1 // indirect
19+
cloud.google.com/go/storage v1.30.1 // indirect
20+
dario.cat/mergo v1.0.0 // indirect
21+
github.com/Masterminds/goutils v1.1.1 // indirect
22+
github.com/Microsoft/go-winio v0.6.1 // indirect
23+
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
24+
github.com/Shopify/ejson v1.3.3 // indirect
1425
github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 // indirect
1526
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
1627
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
28+
github.com/apparentlymart/go-cidr v1.1.0 // indirect
29+
github.com/armon/go-metrics v0.4.0 // indirect
30+
github.com/armon/go-radix v1.0.0 // indirect
31+
github.com/aws/aws-sdk-go v1.44.206 // indirect
32+
github.com/aws/aws-sdk-go-v2 v1.16.4 // indirect
33+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect
34+
github.com/aws/aws-sdk-go-v2/config v1.15.9 // indirect
35+
github.com/aws/aws-sdk-go-v2/credentials v1.12.4 // indirect
36+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.5 // indirect
37+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.14 // indirect
38+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.11 // indirect
39+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.5 // indirect
40+
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.12 // indirect
41+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.2 // indirect
42+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect
43+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.6 // indirect
44+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.5 // indirect
45+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.5 // indirect
46+
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.10 // indirect
47+
github.com/aws/aws-sdk-go-v2/service/sso v1.11.7 // indirect
48+
github.com/aws/aws-sdk-go-v2/service/sts v1.16.6 // indirect
49+
github.com/aws/smithy-go v1.11.2 // indirect
50+
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
51+
github.com/cloudflare/circl v1.3.7 // indirect
52+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
53+
github.com/docker/libkv v0.2.2-0.20180912205406-458977154600 // indirect
54+
github.com/dustin/gojson v0.0.0-20160307161227-2e71ec9dd5ad // indirect
55+
github.com/emirpasic/gods v1.18.1 // indirect
1756
github.com/fatih/color v1.13.0 // indirect
1857
github.com/ghodss/yaml v1.0.0 // indirect
58+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
59+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
60+
github.com/go-git/go-git/v5 v5.11.0 // indirect
61+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
62+
github.com/golang/protobuf v1.5.3 // indirect
63+
github.com/golang/snappy v0.0.4 // indirect
64+
github.com/google/s2a-go v0.1.4 // indirect
65+
github.com/google/uuid v1.4.0 // indirect
66+
github.com/google/wire v0.5.0 // indirect
67+
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
68+
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
69+
github.com/gosimple/slug v1.12.0 // indirect
70+
github.com/gosimple/unidecode v1.0.1 // indirect
71+
github.com/hairyhenderson/go-fsimpl v0.0.0-20220529183339-9deae3e35047 // indirect
72+
github.com/hairyhenderson/toml v0.4.2-0.20210923231440-40456b8e66cf // indirect
73+
github.com/hairyhenderson/yaml v0.0.0-20220618171115-2d35fca545ce // indirect
74+
github.com/hashicorp/consul/api v1.13.0 // indirect
75+
github.com/hashicorp/errwrap v1.1.0 // indirect
76+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
77+
github.com/hashicorp/go-hclog v1.2.0 // indirect
78+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
79+
github.com/hashicorp/go-multierror v1.1.1 // indirect
80+
github.com/hashicorp/go-plugin v1.4.4 // indirect
81+
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
82+
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
83+
github.com/hashicorp/go-secure-stdlib/mlock v0.1.2 // indirect
84+
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.5 // indirect
85+
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
86+
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
87+
github.com/hashicorp/go-uuid v1.0.3 // indirect
88+
github.com/hashicorp/go-version v1.5.0 // indirect
89+
github.com/hashicorp/golang-lru v0.5.4 // indirect
90+
github.com/hashicorp/hcl v1.0.0 // indirect
91+
github.com/hashicorp/serf v0.9.7 // indirect
92+
github.com/hashicorp/vault/api v1.6.0 // indirect
93+
github.com/hashicorp/vault/sdk v0.5.0 // indirect
94+
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
95+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
96+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
97+
github.com/jmespath/go-jmespath v0.4.0 // indirect
98+
github.com/joho/godotenv v1.4.0 // indirect
99+
github.com/kevinburke/ssh_config v1.2.0 // indirect
19100
github.com/mattn/go-colorable v0.1.12 // indirect
20101
github.com/mattn/go-isatty v0.0.14 // indirect
102+
github.com/mitchellh/copystructure v1.2.0 // indirect
103+
github.com/mitchellh/go-homedir v1.1.0 // indirect
104+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
105+
github.com/mitchellh/mapstructure v1.5.0 // indirect
106+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
107+
github.com/oklog/run v1.1.0 // indirect
108+
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
109+
github.com/pjbgf/sha1cd v0.3.0 // indirect
21110
github.com/pkg/errors v0.9.1 // indirect
22111
github.com/pmezard/go-difflib v1.0.0 // indirect
23-
golang.org/x/sys v0.15.0 // indirect
112+
github.com/rs/zerolog v1.26.1 // indirect
113+
github.com/ryanuber/go-glob v1.0.0 // indirect
114+
github.com/sergi/go-diff v1.2.0 // indirect
115+
github.com/skeema/knownhosts v1.2.1 // indirect
116+
github.com/spf13/afero v1.8.2 // indirect
117+
github.com/spf13/cobra v1.4.0 // indirect
118+
github.com/spf13/pflag v1.0.5 // indirect
119+
github.com/ugorji/go/codec v1.2.7 // indirect
120+
github.com/xanzy/ssh-agent v0.3.3 // indirect
121+
github.com/zealic/xignore v0.3.3 // indirect
122+
go.etcd.io/bbolt v1.3.6 // indirect
123+
go.opencensus.io v0.24.0 // indirect
124+
go.uber.org/atomic v1.9.0 // indirect
125+
go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect
126+
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
127+
gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect
128+
golang.org/x/crypto v0.18.0 // indirect
129+
golang.org/x/mod v0.12.0 // indirect
130+
golang.org/x/net v0.19.0 // indirect
131+
golang.org/x/oauth2 v0.15.0 // indirect
132+
golang.org/x/sync v0.3.0 // indirect
133+
golang.org/x/sys v0.16.0 // indirect
134+
golang.org/x/term v0.16.0 // indirect
135+
golang.org/x/text v0.14.0 // indirect
136+
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
137+
golang.org/x/tools v0.13.0 // indirect
138+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
139+
google.golang.org/api v0.126.0 // indirect
140+
google.golang.org/appengine v1.6.7 // indirect
141+
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
142+
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
143+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
144+
google.golang.org/grpc v1.59.0 // indirect
145+
google.golang.org/protobuf v1.31.0 // indirect
24146
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
147+
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
148+
gopkg.in/warnings.v0 v0.1.2 // indirect
25149
gopkg.in/yaml.v2 v2.4.0 // indirect
26-
sigs.k8s.io/yaml v1.1.0 // indirect
150+
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a // indirect
151+
k8s.io/client-go v0.24.1 // indirect
152+
sigs.k8s.io/yaml v1.2.0 // indirect
27153
)

0 commit comments

Comments
 (0)