/*
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 v1beta2

import (
	resourcev1beta2 "k8s.io/api/resource/v1beta2"
)

// DeviceDerivedAttributeApplyConfiguration represents a declarative configuration of the DeviceDerivedAttribute type for use
// with apply.
//
// DeviceDerivedAttribute defines a derived attribute computed via CEL.
type DeviceDerivedAttributeApplyConfiguration struct {
	// Name is the identifier for this derived attribute, used in constraints.
	//
	// It must be a DNS subdomain followed by a slash ("/") followed by a C identifier
	// (e.g. "example.com/numaNode" or "derived/numaNode").
	//
	// If the chosen name matches an existing physical attribute from a driver,
	// the derived attribute's expression will shadow the physical attribute,
	// and its evaluated value will be used in constraints instead. When the goal
	// is to define a derived attribute that is only used within the ResourceClaim
	// and not meant to shadow an existing attribute, use a domain prefix that
	// no DRA driver should be using (e.g. "derived/myAttribute").
	//
	// It is not valid to define a derived attribute that isn't used in at least
	// one constraint.
	Name *resourcev1beta2.FullyQualifiedName `json:"name,omitempty"`
	// Expression is a CEL expression evaluated against each candidate device.
	// The expression must evaluate to a primitive scalar (string, integer,
	// boolean, or semver) or a list of these scalars ([]string, []int64,
	// []bool, []semver) to act as a virtual grouping key. Any other return type
	// is an error and causes CEL evaluation for the device to fail.
	//
	// The expression's input is an object named "device", which carries the
	// same properties as in a CELDeviceSelector.
	//
	// When pod scheduling encounters CEL runtime errors (such as looking
	// up an attribute that isn't defined) for some devices, it will abort
	// allocation and fail scheduling for the Pod. Surfacing evaluation
	// errors immediately prevents silent topology matching failures that are
	// extremely hard to detect. A robust expression should, for example, check
	// for the existence of attributes before referencing them to avoid
	// runtime evaluation errors.
	//
	// The expression gets evaluated after a device has passed the other
	// selector expressions for the request in which this expression is used.
	// This allows writing expressions that are tailored towards the specific
	// devices being requested (for example, by assuming the device is from a
	// certain vendor and skipping those checks).
	//
	// The length of the expression must be smaller or equal to 10 Ki. The
	// cost of evaluating it is also limited based on the estimated number
	// of logical steps; the combined cost of all derived attributes in a
	// claim is capped by a shared CEL cost budget.
	Expression *string `json:"expression,omitempty"`
}

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

// WithName sets the Name 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 Name field is set to the value of the last call.
func (b *DeviceDerivedAttributeApplyConfiguration) WithName(value resourcev1beta2.FullyQualifiedName) *DeviceDerivedAttributeApplyConfiguration {
	b.Name = &value
	return b
}

// WithExpression sets the Expression 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 Expression field is set to the value of the last call.
func (b *DeviceDerivedAttributeApplyConfiguration) WithExpression(value string) *DeviceDerivedAttributeApplyConfiguration {
	b.Expression = &value
	return b
}
