rename buildStore to buildStores
This commit is contained in:
parent
acb7d1dd3c
commit
a6eb25e3c6
|
|
@ -67,7 +67,7 @@ type Builder struct {
|
|||
shardingMetrics *sharding.Metrics
|
||||
shard int32
|
||||
totalShards int
|
||||
buildStoreFunc ksmtypes.BuildStoreFunc
|
||||
buildStoresFunc ksmtypes.BuildStoresFunc
|
||||
allowLabelsList map[string][]string
|
||||
}
|
||||
|
||||
|
|
@ -136,14 +136,14 @@ func (b *Builder) WithAllowDenyList(l ksmtypes.AllowDenyLister) {
|
|||
b.allowDenyList = l
|
||||
}
|
||||
|
||||
// WithGenerateStoreFunc configures a custom generate store function
|
||||
func (b *Builder) WithGenerateStoreFunc(f ksmtypes.BuildStoreFunc) {
|
||||
b.buildStoreFunc = f
|
||||
// WithGenerateStoresFunc configures a custom generate store function
|
||||
func (b *Builder) WithGenerateStoresFunc(f ksmtypes.BuildStoresFunc) {
|
||||
b.buildStoresFunc = f
|
||||
}
|
||||
|
||||
// DefaultGenerateStoreFunc returns default buildStore function
|
||||
func (b *Builder) DefaultGenerateStoreFunc() ksmtypes.BuildStoreFunc {
|
||||
return b.buildStore
|
||||
// DefaultGenerateStoresFunc returns default buildStores function
|
||||
func (b *Builder) DefaultGenerateStoresFunc() ksmtypes.BuildStoresFunc {
|
||||
return b.buildStores
|
||||
}
|
||||
|
||||
// WithAllowLabels configures which labels can be returned for metrics
|
||||
|
|
@ -183,35 +183,35 @@ func (b *Builder) Build() []metricsstore.MetricsWriter {
|
|||
}
|
||||
|
||||
var availableStores = map[string]func(f *Builder) []*metricsstore.MetricsStore{
|
||||
"certificatesigningrequests": func(b *Builder) []*metricsstore.MetricsStore { return b.buildCsrStore() },
|
||||
"configmaps": func(b *Builder) []*metricsstore.MetricsStore { return b.buildConfigMapStore() },
|
||||
"cronjobs": func(b *Builder) []*metricsstore.MetricsStore { return b.buildCronJobStore() },
|
||||
"daemonsets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildDaemonSetStore() },
|
||||
"deployments": func(b *Builder) []*metricsstore.MetricsStore { return b.buildDeploymentStore() },
|
||||
"endpoints": func(b *Builder) []*metricsstore.MetricsStore { return b.buildEndpointsStore() },
|
||||
"horizontalpodautoscalers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildHPAStore() },
|
||||
"ingresses": func(b *Builder) []*metricsstore.MetricsStore { return b.buildIngressStore() },
|
||||
"jobs": func(b *Builder) []*metricsstore.MetricsStore { return b.buildJobStore() },
|
||||
"leases": func(b *Builder) []*metricsstore.MetricsStore { return b.buildLeases() },
|
||||
"limitranges": func(b *Builder) []*metricsstore.MetricsStore { return b.buildLimitRangeStore() },
|
||||
"mutatingwebhookconfigurations": func(b *Builder) []*metricsstore.MetricsStore { return b.buildMutatingWebhookConfigurationStore() },
|
||||
"namespaces": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNamespaceStore() },
|
||||
"networkpolicies": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNetworkPolicyStore() },
|
||||
"nodes": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNodeStore() },
|
||||
"persistentvolumeclaims": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPersistentVolumeClaimStore() },
|
||||
"persistentvolumes": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPersistentVolumeStore() },
|
||||
"poddisruptionbudgets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPodDisruptionBudgetStore() },
|
||||
"pods": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPodStore() },
|
||||
"replicasets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildReplicaSetStore() },
|
||||
"replicationcontrollers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildReplicationControllerStore() },
|
||||
"resourcequotas": func(b *Builder) []*metricsstore.MetricsStore { return b.buildResourceQuotaStore() },
|
||||
"secrets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildSecretStore() },
|
||||
"services": func(b *Builder) []*metricsstore.MetricsStore { return b.buildServiceStore() },
|
||||
"statefulsets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildStatefulSetStore() },
|
||||
"storageclasses": func(b *Builder) []*metricsstore.MetricsStore { return b.buildStorageClassStore() },
|
||||
"validatingwebhookconfigurations": func(b *Builder) []*metricsstore.MetricsStore { return b.buildValidatingWebhookConfigurationStore() },
|
||||
"volumeattachments": func(b *Builder) []*metricsstore.MetricsStore { return b.buildVolumeAttachmentStore() },
|
||||
"verticalpodautoscalers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildVPAStore() },
|
||||
"certificatesigningrequests": func(b *Builder) []*metricsstore.MetricsStore { return b.buildCsrStores() },
|
||||
"configmaps": func(b *Builder) []*metricsstore.MetricsStore { return b.buildConfigMapStores() },
|
||||
"cronjobs": func(b *Builder) []*metricsstore.MetricsStore { return b.buildCronJobStores() },
|
||||
"daemonsets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildDaemonSetStores() },
|
||||
"deployments": func(b *Builder) []*metricsstore.MetricsStore { return b.buildDeploymentStores() },
|
||||
"endpoints": func(b *Builder) []*metricsstore.MetricsStore { return b.buildEndpointsStores() },
|
||||
"horizontalpodautoscalers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildHPAStores() },
|
||||
"ingresses": func(b *Builder) []*metricsstore.MetricsStore { return b.buildIngressStores() },
|
||||
"jobs": func(b *Builder) []*metricsstore.MetricsStore { return b.buildJobStores() },
|
||||
"leases": func(b *Builder) []*metricsstore.MetricsStore { return b.buildLeasesStores() },
|
||||
"limitranges": func(b *Builder) []*metricsstore.MetricsStore { return b.buildLimitRangeStores() },
|
||||
"mutatingwebhookconfigurations": func(b *Builder) []*metricsstore.MetricsStore { return b.buildMutatingWebhookConfigurationStores() },
|
||||
"namespaces": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNamespaceStores() },
|
||||
"networkpolicies": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNetworkPolicyStores() },
|
||||
"nodes": func(b *Builder) []*metricsstore.MetricsStore { return b.buildNodeStores() },
|
||||
"persistentvolumeclaims": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPersistentVolumeClaimStores() },
|
||||
"persistentvolumes": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPersistentVolumeStores() },
|
||||
"poddisruptionbudgets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPodDisruptionBudgetStores() },
|
||||
"pods": func(b *Builder) []*metricsstore.MetricsStore { return b.buildPodStores() },
|
||||
"replicasets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildReplicaSetStores() },
|
||||
"replicationcontrollers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildReplicationControllerStores() },
|
||||
"resourcequotas": func(b *Builder) []*metricsstore.MetricsStore { return b.buildResourceQuotaStores() },
|
||||
"secrets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildSecretStores() },
|
||||
"services": func(b *Builder) []*metricsstore.MetricsStore { return b.buildServiceStores() },
|
||||
"statefulsets": func(b *Builder) []*metricsstore.MetricsStore { return b.buildStatefulSetStores() },
|
||||
"storageclasses": func(b *Builder) []*metricsstore.MetricsStore { return b.buildStorageClassStores() },
|
||||
"validatingwebhookconfigurations": func(b *Builder) []*metricsstore.MetricsStore { return b.buildValidatingWebhookConfigurationStores() },
|
||||
"volumeattachments": func(b *Builder) []*metricsstore.MetricsStore { return b.buildVolumeAttachmentStores() },
|
||||
"verticalpodautoscalers": func(b *Builder) []*metricsstore.MetricsStore { return b.buildVPAStores() },
|
||||
}
|
||||
|
||||
func resourceExists(name string) bool {
|
||||
|
|
@ -227,123 +227,123 @@ func availableResources() []string {
|
|||
return c
|
||||
}
|
||||
|
||||
func (b *Builder) buildConfigMapStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(configMapMetricFamilies, &v1.ConfigMap{}, createConfigMapListWatch)
|
||||
func (b *Builder) buildConfigMapStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(configMapMetricFamilies, &v1.ConfigMap{}, createConfigMapListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildCronJobStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(cronJobMetricFamilies(b.allowLabelsList["cronjobs"]), &batchv1beta1.CronJob{}, createCronJobListWatch)
|
||||
func (b *Builder) buildCronJobStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(cronJobMetricFamilies(b.allowLabelsList["cronjobs"]), &batchv1beta1.CronJob{}, createCronJobListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildDaemonSetStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(daemonSetMetricFamilies(b.allowLabelsList["daemonsets"]), &appsv1.DaemonSet{}, createDaemonSetListWatch)
|
||||
func (b *Builder) buildDaemonSetStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(daemonSetMetricFamilies(b.allowLabelsList["daemonsets"]), &appsv1.DaemonSet{}, createDaemonSetListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildDeploymentStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(deploymentMetricFamilies(b.allowLabelsList["deployments"]), &appsv1.Deployment{}, createDeploymentListWatch)
|
||||
func (b *Builder) buildDeploymentStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(deploymentMetricFamilies(b.allowLabelsList["deployments"]), &appsv1.Deployment{}, createDeploymentListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildEndpointsStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(endpointMetricFamilies(b.allowLabelsList["endpoints"]), &v1.Endpoints{}, createEndpointsListWatch)
|
||||
func (b *Builder) buildEndpointsStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(endpointMetricFamilies(b.allowLabelsList["endpoints"]), &v1.Endpoints{}, createEndpointsListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildHPAStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(hpaMetricFamilies(b.allowLabelsList["horizontalpodautoscalers"]), &autoscaling.HorizontalPodAutoscaler{}, createHPAListWatch)
|
||||
func (b *Builder) buildHPAStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(hpaMetricFamilies(b.allowLabelsList["horizontalpodautoscalers"]), &autoscaling.HorizontalPodAutoscaler{}, createHPAListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildIngressStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(ingressMetricFamilies(b.allowLabelsList["ingresses"]), &networkingv1.Ingress{}, createIngressListWatch)
|
||||
func (b *Builder) buildIngressStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(ingressMetricFamilies(b.allowLabelsList["ingresses"]), &networkingv1.Ingress{}, createIngressListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildJobStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(jobMetricFamilies(b.allowLabelsList["jobs"]), &batchv1.Job{}, createJobListWatch)
|
||||
func (b *Builder) buildJobStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(jobMetricFamilies(b.allowLabelsList["jobs"]), &batchv1.Job{}, createJobListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildLimitRangeStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(limitRangeMetricFamilies, &v1.LimitRange{}, createLimitRangeListWatch)
|
||||
func (b *Builder) buildLimitRangeStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(limitRangeMetricFamilies, &v1.LimitRange{}, createLimitRangeListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildMutatingWebhookConfigurationStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(mutatingWebhookConfigurationMetricFamilies, &admissionregistrationv1.MutatingWebhookConfiguration{}, createMutatingWebhookConfigurationListWatch)
|
||||
func (b *Builder) buildMutatingWebhookConfigurationStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(mutatingWebhookConfigurationMetricFamilies, &admissionregistrationv1.MutatingWebhookConfiguration{}, createMutatingWebhookConfigurationListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildNamespaceStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(namespaceMetricFamilies(b.allowLabelsList["namespaces"]), &v1.Namespace{}, createNamespaceListWatch)
|
||||
func (b *Builder) buildNamespaceStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(namespaceMetricFamilies(b.allowLabelsList["namespaces"]), &v1.Namespace{}, createNamespaceListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildNetworkPolicyStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(networkPolicyMetricFamilies(b.allowLabelsList["networkpolicies"]), &networkingv1.NetworkPolicy{}, createNetworkPolicyListWatch)
|
||||
func (b *Builder) buildNetworkPolicyStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(networkPolicyMetricFamilies(b.allowLabelsList["networkpolicies"]), &networkingv1.NetworkPolicy{}, createNetworkPolicyListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildNodeStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(nodeMetricFamilies(b.allowLabelsList["nodes"]), &v1.Node{}, createNodeListWatch)
|
||||
func (b *Builder) buildNodeStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(nodeMetricFamilies(b.allowLabelsList["nodes"]), &v1.Node{}, createNodeListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildPersistentVolumeClaimStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(persistentVolumeClaimMetricFamilies(b.allowLabelsList["persistentvolumeclaims"]), &v1.PersistentVolumeClaim{}, createPersistentVolumeClaimListWatch)
|
||||
func (b *Builder) buildPersistentVolumeClaimStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(persistentVolumeClaimMetricFamilies(b.allowLabelsList["persistentvolumeclaims"]), &v1.PersistentVolumeClaim{}, createPersistentVolumeClaimListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildPersistentVolumeStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(persistentVolumeMetricFamilies(b.allowLabelsList["persistentvolumes"]), &v1.PersistentVolume{}, createPersistentVolumeListWatch)
|
||||
func (b *Builder) buildPersistentVolumeStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(persistentVolumeMetricFamilies(b.allowLabelsList["persistentvolumes"]), &v1.PersistentVolume{}, createPersistentVolumeListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildPodDisruptionBudgetStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(podDisruptionBudgetMetricFamilies, &policy.PodDisruptionBudget{}, createPodDisruptionBudgetListWatch)
|
||||
func (b *Builder) buildPodDisruptionBudgetStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(podDisruptionBudgetMetricFamilies, &policy.PodDisruptionBudget{}, createPodDisruptionBudgetListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildReplicaSetStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(replicaSetMetricFamilies(b.allowLabelsList["replicasets"]), &appsv1.ReplicaSet{}, createReplicaSetListWatch)
|
||||
func (b *Builder) buildReplicaSetStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(replicaSetMetricFamilies(b.allowLabelsList["replicasets"]), &appsv1.ReplicaSet{}, createReplicaSetListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildReplicationControllerStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(replicationControllerMetricFamilies, &v1.ReplicationController{}, createReplicationControllerListWatch)
|
||||
func (b *Builder) buildReplicationControllerStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(replicationControllerMetricFamilies, &v1.ReplicationController{}, createReplicationControllerListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildResourceQuotaStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(resourceQuotaMetricFamilies, &v1.ResourceQuota{}, createResourceQuotaListWatch)
|
||||
func (b *Builder) buildResourceQuotaStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(resourceQuotaMetricFamilies, &v1.ResourceQuota{}, createResourceQuotaListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildSecretStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(secretMetricFamilies(b.allowLabelsList["secrets"]), &v1.Secret{}, createSecretListWatch)
|
||||
func (b *Builder) buildSecretStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(secretMetricFamilies(b.allowLabelsList["secrets"]), &v1.Secret{}, createSecretListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildServiceStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(serviceMetricFamilies(b.allowLabelsList["services"]), &v1.Service{}, createServiceListWatch)
|
||||
func (b *Builder) buildServiceStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(serviceMetricFamilies(b.allowLabelsList["services"]), &v1.Service{}, createServiceListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildStatefulSetStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(statefulSetMetricFamilies(b.allowLabelsList["statefulsets"]), &appsv1.StatefulSet{}, createStatefulSetListWatch)
|
||||
func (b *Builder) buildStatefulSetStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(statefulSetMetricFamilies(b.allowLabelsList["statefulsets"]), &appsv1.StatefulSet{}, createStatefulSetListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildStorageClassStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(storageClassMetricFamilies(b.allowLabelsList["storageclasses"]), &storagev1.StorageClass{}, createStorageClassListWatch)
|
||||
func (b *Builder) buildStorageClassStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(storageClassMetricFamilies(b.allowLabelsList["storageclasses"]), &storagev1.StorageClass{}, createStorageClassListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildPodStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(podMetricFamilies(b.allowLabelsList["pods"]), &v1.Pod{}, createPodListWatch)
|
||||
func (b *Builder) buildPodStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(podMetricFamilies(b.allowLabelsList["pods"]), &v1.Pod{}, createPodListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildCsrStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(csrMetricFamilies(b.allowLabelsList["certificatesigningrequests"]), &certv1.CertificateSigningRequest{}, createCSRListWatch)
|
||||
func (b *Builder) buildCsrStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(csrMetricFamilies(b.allowLabelsList["certificatesigningrequests"]), &certv1.CertificateSigningRequest{}, createCSRListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildValidatingWebhookConfigurationStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(validatingWebhookConfigurationMetricFamilies, &admissionregistrationv1.ValidatingWebhookConfiguration{}, createValidatingWebhookConfigurationListWatch)
|
||||
func (b *Builder) buildValidatingWebhookConfigurationStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(validatingWebhookConfigurationMetricFamilies, &admissionregistrationv1.ValidatingWebhookConfiguration{}, createValidatingWebhookConfigurationListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildVolumeAttachmentStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(volumeAttachmentMetricFamilies, &storagev1.VolumeAttachment{}, createVolumeAttachmentListWatch)
|
||||
func (b *Builder) buildVolumeAttachmentStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(volumeAttachmentMetricFamilies, &storagev1.VolumeAttachment{}, createVolumeAttachmentListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildVPAStore() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(vpaMetricFamilies(b.allowLabelsList["verticalpodautoscalers"]), &vpaautoscaling.VerticalPodAutoscaler{}, createVPAListWatchFunc(b.vpaClient))
|
||||
func (b *Builder) buildVPAStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(vpaMetricFamilies(b.allowLabelsList["verticalpodautoscalers"]), &vpaautoscaling.VerticalPodAutoscaler{}, createVPAListWatchFunc(b.vpaClient))
|
||||
}
|
||||
|
||||
func (b *Builder) buildLeases() []*metricsstore.MetricsStore {
|
||||
return b.buildStoreFunc(leaseMetricFamilies, &coordinationv1.Lease{}, createLeaseListWatch)
|
||||
func (b *Builder) buildLeasesStores() []*metricsstore.MetricsStore {
|
||||
return b.buildStoresFunc(leaseMetricFamilies, &coordinationv1.Lease{}, createLeaseListWatch)
|
||||
}
|
||||
|
||||
func (b *Builder) buildStore(
|
||||
func (b *Builder) buildStores(
|
||||
metricFamilies []generator.FamilyGenerator,
|
||||
expectedType interface{},
|
||||
listWatchFunc func(kubeClient clientset.Interface, ns string) cache.ListerWatcher,
|
||||
|
|
|
|||
2
main.go
2
main.go
|
|
@ -139,7 +139,7 @@ func main() {
|
|||
|
||||
storeBuilder.WithAllowDenyList(allowDenyList)
|
||||
|
||||
storeBuilder.WithGenerateStoreFunc(storeBuilder.DefaultGenerateStoreFunc())
|
||||
storeBuilder.WithGenerateStoresFunc(storeBuilder.DefaultGenerateStoresFunc())
|
||||
|
||||
proc.StartReaper()
|
||||
|
||||
|
|
|
|||
10
main_test.go
10
main_test.go
|
|
@ -67,7 +67,7 @@ func BenchmarkKubeStateMetrics(b *testing.B) {
|
|||
builder.WithSharding(0, 1)
|
||||
builder.WithContext(ctx)
|
||||
builder.WithNamespaces(options.DefaultNamespaces)
|
||||
builder.WithGenerateStoreFunc(builder.DefaultGenerateStoreFunc())
|
||||
builder.WithGenerateStoresFunc(builder.DefaultGenerateStoresFunc())
|
||||
|
||||
l, err := allowdenylist.New(map[string]struct{}{}, map[string]struct{}{})
|
||||
if err != nil {
|
||||
|
|
@ -132,7 +132,7 @@ func TestFullScrapeCycle(t *testing.T) {
|
|||
builder.WithEnabledResources(options.DefaultResources.AsSlice())
|
||||
builder.WithKubeClient(kubeClient)
|
||||
builder.WithNamespaces(options.DefaultNamespaces)
|
||||
builder.WithGenerateStoreFunc(builder.DefaultGenerateStoreFunc())
|
||||
builder.WithGenerateStoresFunc(builder.DefaultGenerateStoresFunc())
|
||||
|
||||
l, err := allowdenylist.New(map[string]struct{}{}, map[string]struct{}{})
|
||||
if err != nil {
|
||||
|
|
@ -412,7 +412,7 @@ func TestShardingEquivalenceScrapeCycle(t *testing.T) {
|
|||
unshardedBuilder.WithNamespaces(options.DefaultNamespaces)
|
||||
unshardedBuilder.WithAllowDenyList(l)
|
||||
unshardedBuilder.WithAllowLabels(map[string][]string{})
|
||||
unshardedBuilder.WithGenerateStoreFunc(unshardedBuilder.DefaultGenerateStoreFunc())
|
||||
unshardedBuilder.WithGenerateStoresFunc(unshardedBuilder.DefaultGenerateStoresFunc())
|
||||
|
||||
unshardedHandler := metricshandler.New(&options.Options{}, kubeClient, unshardedBuilder, false)
|
||||
unshardedHandler.ConfigureSharding(ctx, 0, 1)
|
||||
|
|
@ -425,7 +425,7 @@ func TestShardingEquivalenceScrapeCycle(t *testing.T) {
|
|||
shardedBuilder1.WithNamespaces(options.DefaultNamespaces)
|
||||
shardedBuilder1.WithAllowDenyList(l)
|
||||
shardedBuilder1.WithAllowLabels(map[string][]string{})
|
||||
shardedBuilder1.WithGenerateStoreFunc(shardedBuilder1.DefaultGenerateStoreFunc())
|
||||
shardedBuilder1.WithGenerateStoresFunc(shardedBuilder1.DefaultGenerateStoresFunc())
|
||||
|
||||
shardedHandler1 := metricshandler.New(&options.Options{}, kubeClient, shardedBuilder1, false)
|
||||
shardedHandler1.ConfigureSharding(ctx, 0, 2)
|
||||
|
|
@ -438,7 +438,7 @@ func TestShardingEquivalenceScrapeCycle(t *testing.T) {
|
|||
shardedBuilder2.WithNamespaces(options.DefaultNamespaces)
|
||||
shardedBuilder2.WithAllowDenyList(l)
|
||||
shardedBuilder2.WithAllowLabels(map[string][]string{})
|
||||
shardedBuilder2.WithGenerateStoreFunc(shardedBuilder2.DefaultGenerateStoreFunc())
|
||||
shardedBuilder2.WithGenerateStoresFunc(shardedBuilder2.DefaultGenerateStoresFunc())
|
||||
|
||||
shardedHandler2 := metricshandler.New(&options.Options{}, kubeClient, shardedBuilder2, false)
|
||||
shardedHandler2.ConfigureSharding(ctx, 1, 2)
|
||||
|
|
|
|||
|
|
@ -90,14 +90,14 @@ func (b *Builder) WithAllowLabels(l map[string][]string) {
|
|||
b.internal.WithAllowLabels(l)
|
||||
}
|
||||
|
||||
// WithGenerateStoreFunc configures a custom generate store function
|
||||
func (b *Builder) WithGenerateStoreFunc(f ksmtypes.BuildStoreFunc) {
|
||||
b.internal.WithGenerateStoreFunc(f)
|
||||
// WithGenerateStoresFunc configures a custom generate store function
|
||||
func (b *Builder) WithGenerateStoresFunc(f ksmtypes.BuildStoresFunc) {
|
||||
b.internal.WithGenerateStoresFunc(f)
|
||||
}
|
||||
|
||||
// DefaultGenerateStoreFunc returns default buildStore function
|
||||
func (b *Builder) DefaultGenerateStoreFunc() ksmtypes.BuildStoreFunc {
|
||||
return b.internal.DefaultGenerateStoreFunc()
|
||||
// DefaultGenerateStoresFunc returns default buildStore function
|
||||
func (b *Builder) DefaultGenerateStoresFunc() ksmtypes.BuildStoresFunc {
|
||||
return b.internal.DefaultGenerateStoresFunc()
|
||||
}
|
||||
|
||||
// Build initializes and registers all enabled stores.
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ type BuilderInterface interface {
|
|||
WithKubeClient(c clientset.Interface)
|
||||
WithVPAClient(c vpaclientset.Interface)
|
||||
WithAllowDenyList(l AllowDenyLister)
|
||||
WithGenerateStoreFunc(f BuildStoreFunc)
|
||||
WithAllowLabels(l map[string][]string)
|
||||
DefaultGenerateStoreFunc() BuildStoreFunc
|
||||
WithGenerateStoresFunc(f BuildStoresFunc)
|
||||
DefaultGenerateStoresFunc() BuildStoresFunc
|
||||
Build() []metricsstore.MetricsWriter
|
||||
}
|
||||
|
||||
// BuildStoreFunc function signature that is use to returns a list of metricsstore.MetricsStore
|
||||
type BuildStoreFunc func(metricFamilies []generator.FamilyGenerator,
|
||||
// BuildStoresFunc function signature that is use to returns a list of metricsstore.MetricsStore
|
||||
type BuildStoresFunc func(metricFamilies []generator.FamilyGenerator,
|
||||
expectedType interface{},
|
||||
listWatchFunc func(kubeClient clientset.Interface, ns string) cache.ListerWatcher,
|
||||
) []*metricsstore.MetricsStore
|
||||
|
|
|
|||
Loading…
Reference in New Issue