mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-11 09:30:13 -04:00
The Kubernetes SD Discovery struct held the clientset as a kubernetes.Interface field. Boxing the concrete *kubernetes.Clientset into an interface marks it <UsedInIface>, so the Go linker conservatively retains every API-group accessor and, transitively, every resource client and its apply configurations, even though discovery only touches the core, apps, batch, discovery and networking v1 groups. Wrap the clientset in an adapter that captures only the used API-group accessors as method-value closures and exposes them through a narrow k8sClient interface. The concrete clientset now lives only inside closure contexts, which reflection cannot traverse, so dead-code elimination drops the unused groups. The fake clientset still satisfies the narrow interface, so tests are unchanged. This trims about 10 MB from each of the prometheus and promtool binaries. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| client.go | ||
| endpoints.go | ||
| endpoints_test.go | ||
| endpointslice.go | ||
| endpointslice_test.go | ||
| ingress.go | ||
| ingress_test.go | ||
| kubernetes.go | ||
| kubernetes_test.go | ||
| metrics.go | ||
| node.go | ||
| node_test.go | ||
| pod.go | ||
| pod_test.go | ||
| service.go | ||
| service_test.go | ||