/*
Copyright The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

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

package v1

import (
	resource "k8s.io/apimachinery/pkg/api/resource"
)

// NodeAllocatableOverheadApplyConfiguration represents a declarative configuration of the NodeAllocatableOverhead type for use
// with apply.
//
// NodeAllocatableOverhead defines auxiliary resource overheads incurred when allocating a device.
// Overheads can be specified as a fixed cost per pod referencing the claim, a variable cost per container reference, or both.
// Kubelet accounts for this overhead by adding it to both the pod-level and container-level cgroups of referencing containers.
type NodeAllocatableOverheadApplyConfiguration struct {
	// PerPod is overhead applied once per pod referencing the claim on this node.
	// This is a flat overhead incurred for every pod referencing the claim.
	PerPod *resource.Quantity `json:"perPod,omitempty"`
	// PerContainer is applied per container reference to the claim.
	// This models overhead scaling linearly with the number of containers actively using the device.
	// When both PerPod and PerContainer are specified, the total overhead allocated for each pod referencing
	// the claim is computed as:
	// Quantity = PerPod + (PerContainer * NumReferences)
	// Kubelet accounts for this overhead in cgroups:
	// - Pod-level cgroup (requests and limits): Kubelet adds PerPod + (PerContainer * NumReferences).
	// - Container-level cgroup (limits only): Kubelet adds PerPod + PerContainer for each referencing container.
	// This allows any single container to access the pod-level overhead, while the parent cgroup caps the total usage to account for PerPod exactly once.
	PerContainer *resource.Quantity `json:"perContainer,omitempty"`
}

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

// WithPerPod sets the PerPod field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PerPod field is set to the value of the last call.
func (b *NodeAllocatableOverheadApplyConfiguration) WithPerPod(value resource.Quantity) *NodeAllocatableOverheadApplyConfiguration {
	b.PerPod = &value
	return b
}

// WithPerContainer sets the PerContainer field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the PerContainer field is set to the value of the last call.
func (b *NodeAllocatableOverheadApplyConfiguration) WithPerContainer(value resource.Quantity) *NodeAllocatableOverheadApplyConfiguration {
	b.PerContainer = &value
	return b
}
