// Code generated by applyconfiguration-gen. DO NOT EDIT.

package v1alpha1

import (
	v1 "k8s.io/api/core/v1"
)

// KubeStateMetricsConfigApplyConfiguration represents a declarative configuration of the KubeStateMetricsConfig type for use
// with apply.
//
// KubeStateMetricsConfig provides configuration options for the kube-state-metrics agent
// that runs in the `openshift-monitoring` namespace. kube-state-metrics generates metrics
// about the state of Kubernetes objects such as Deployments, Nodes, and Pods.
type KubeStateMetricsConfigApplyConfiguration struct {
	// nodeSelector defines the nodes on which the Pods are scheduled.
	// nodeSelector is optional.
	//
	// When omitted, this means the user has no opinion and the platform is left
	// to choose reasonable defaults. These defaults are subject to change over time.
	// The current default value is `kubernetes.io/os: linux`.
	// When specified, nodeSelector must contain at least 1 entry and must not contain more than 10 entries.
	NodeSelector map[string]string `json:"nodeSelector,omitempty"`
	// resources defines the compute resource requests and limits for the kube-state-metrics container.
	// This includes CPU, memory and HugePages constraints to help control scheduling and resource usage.
	// When not specified, defaults are used by the platform. Requests cannot exceed limits.
	// This field is optional.
	// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
	// This is a simplified API that maps to Kubernetes ResourceRequirements.
	// The current default values are:
	// resources:
	// - name: cpu
	// request: 4m
	// limit: null
	// - name: memory
	// request: 40Mi
	// limit: null
	// Maximum length for this list is 5.
	// Minimum length for this list is 1.
	// Each resource name must be unique within this list.
	Resources []ContainerResourceApplyConfiguration `json:"resources,omitempty"`
	// tolerations defines tolerations for the pods.
	// tolerations is optional.
	//
	// When omitted, no tolerations are applied. This default is subject to change over time.
	// When specified, tolerations must contain at least 1 entry and must not contain more than 10 entries.
	// Each toleration's operator, when specified, must be either "Exists" or "Equal".
	// Each toleration's effect, when specified, must be one of "NoSchedule", "PreferNoSchedule", or "NoExecute".
	// An empty or unset effect means match all effects.
	Tolerations []v1.Toleration `json:"tolerations,omitempty"`
	// topologySpreadConstraints defines rules for how kube-state-metrics Pods should be distributed
	// across topology domains such as zones, nodes, or other user-defined labels.
	// topologySpreadConstraints is optional.
	// This helps improve high availability and resource efficiency by avoiding placing
	// too many replicas in the same failure domain.
	//
	// This field maps directly to the `topologySpreadConstraints` field in the Pod spec.
	// When omitted, no topology spread constraints are applied. This default is subject to change over time.
	// When specified, topologySpreadConstraints must contain at least 1 entry and must not contain more than 10 entries.
	// Entries must have unique topologyKey and whenUnsatisfiable pairs.
	// Each entry's whenUnsatisfiable must be either "DoNotSchedule" or "ScheduleAnyway".
	// Each entry's maxSkew must be at least 1.
	// When minDomains is specified, it must be at least 1 and whenUnsatisfiable must be "DoNotSchedule".
	TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
	// additionalResourceLabels defines additional Kubernetes resource labels to expose as metrics
	// in kube-state-metrics.
	// Currently, only "Job" and "CronJob" resources are supported due to cardinality concerns.
	// Each entry specifies a resource name and a list of Kubernetes label names to expose.
	// Use "*" in the labels list to expose all labels for a given resource.
	// additionalResourceLabels is optional.
	// When omitted, no additional Kubernetes object labels are exposed as metrics
	// by kube-state-metrics beyond its built-in metric labels (e.g. namespace, job_name).
	// Use this field to opt in to exposing specific Kubernetes labels as metric labels
	// for the supported resource types.
	// Minimum length for this list is 1.
	// Maximum length for this list is 2.
	// Each resource name must be unique within this list.
	AdditionalResourceLabels []KubeStateMetricsResourceLabelsApplyConfiguration `json:"additionalResourceLabels,omitempty"`
}

// KubeStateMetricsConfigApplyConfiguration constructs a declarative configuration of the KubeStateMetricsConfig type for use with
// apply.
func KubeStateMetricsConfig() *KubeStateMetricsConfigApplyConfiguration {
	return &KubeStateMetricsConfigApplyConfiguration{}
}

// WithNodeSelector puts the entries into the NodeSelector field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, the entries provided by each call will be put on the NodeSelector field,
// overwriting an existing map entries in NodeSelector field with the same key.
func (b *KubeStateMetricsConfigApplyConfiguration) WithNodeSelector(entries map[string]string) *KubeStateMetricsConfigApplyConfiguration {
	if b.NodeSelector == nil && len(entries) > 0 {
		b.NodeSelector = make(map[string]string, len(entries))
	}
	for k, v := range entries {
		b.NodeSelector[k] = v
	}
	return b
}

// WithResources adds the given value to the Resources field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Resources field.
func (b *KubeStateMetricsConfigApplyConfiguration) WithResources(values ...*ContainerResourceApplyConfiguration) *KubeStateMetricsConfigApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithResources")
		}
		b.Resources = append(b.Resources, *values[i])
	}
	return b
}

// WithTolerations adds the given value to the Tolerations field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Tolerations field.
func (b *KubeStateMetricsConfigApplyConfiguration) WithTolerations(values ...v1.Toleration) *KubeStateMetricsConfigApplyConfiguration {
	for i := range values {
		b.Tolerations = append(b.Tolerations, values[i])
	}
	return b
}

// WithTopologySpreadConstraints adds the given value to the TopologySpreadConstraints field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the TopologySpreadConstraints field.
func (b *KubeStateMetricsConfigApplyConfiguration) WithTopologySpreadConstraints(values ...v1.TopologySpreadConstraint) *KubeStateMetricsConfigApplyConfiguration {
	for i := range values {
		b.TopologySpreadConstraints = append(b.TopologySpreadConstraints, values[i])
	}
	return b
}

// WithAdditionalResourceLabels adds the given value to the AdditionalResourceLabels field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the AdditionalResourceLabels field.
func (b *KubeStateMetricsConfigApplyConfiguration) WithAdditionalResourceLabels(values ...*KubeStateMetricsResourceLabelsApplyConfiguration) *KubeStateMetricsConfigApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithAdditionalResourceLabels")
		}
		b.AdditionalResourceLabels = append(b.AdditionalResourceLabels, *values[i])
	}
	return b
}
