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

import (
	schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
)

// CompositePodGroupTemplateApplyConfiguration represents a declarative configuration of the CompositePodGroupTemplate type for use
// with apply.
//
// CompositePodGroupTemplate represents a template for a CompositePodGroup with a scheduling policy.
type CompositePodGroupTemplateApplyConfiguration struct {
	// name is a unique identifier for the CompositePodGroupTemplate within the Workload.
	// It must be a DNS label. This field is required.
	Name *string `json:"name,omitempty"`
	// schedulingPolicy defines the scheduling policy for this template.
	SchedulingPolicy *CompositePodGroupSchedulingPolicyApplyConfiguration `json:"schedulingPolicy,omitempty"`
	// schedulingConstraints defines optional scheduling constraints (e.g. topology) for this CompositePodGroupTemplate.
	// This field is immutable.
	SchedulingConstraints *CompositePodGroupSchedulingConstraintsApplyConfiguration `json:"schedulingConstraints,omitempty"`
	// disruptionMode defines the mode in which a given CompositePodGroup can be disrupted.
	// One of Single, All.
	// This field is immutable.
	DisruptionMode *CompositeDisruptionModeApplyConfiguration `json:"disruptionMode,omitempty"`
	// priorityClassName indicates the priority that should be considered when scheduling
	// a composite pod group created from this template. If no priority class is specified,
	// admission control can set this to the global default priority class if it exists.
	// Otherwise, composite pod groups created from this template will have the priority set
	// to zero.
	// This field is immutable.
	PriorityClassName *string `json:"priorityClassName,omitempty"`
	// priority is the value of priority of composite pod groups created from this template.
	// Various system components use this field to find the priority of the composite pod group.
	// When Priority Admission Controller is enabled, it prevents users from setting this field.
	// The admission controller populates this field from PriorityClassName.
	// The higher the value, the higher the priority.
	// This field is immutable.
	Priority *int32 `json:"priority,omitempty"`
	// preemptionPolicy is the Policy for preempting pods/podgroups with lower priority.
	// One of Never, PreemptLowerPriority.
	// This field is immutable.
	// This field is available only when the PodGroupPreemptionPolicy feature gate is enabled.
	PreemptionPolicy *schedulingv1alpha3.PreemptionPolicy `json:"preemptionPolicy,omitempty"`
	// podGroupTemplates is the list of templates for children PodGroups.
	// The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates
	// or PodGroupTemplates must be set.
	PodGroupTemplates []PodGroupTemplateApplyConfiguration `json:"podGroupTemplates,omitempty"`
	// compositePodGroupTemplates is the list of templates for children CompositePodGroups.
	// The maximum number of templates is 8. At least one entry in CompositePodGroupTemplates
	// or PodGroupTemplates must be set.
	CompositePodGroupTemplates []CompositePodGroupTemplateApplyConfiguration `json:"compositePodGroupTemplates,omitempty"`
}

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

// 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 *CompositePodGroupTemplateApplyConfiguration) WithName(value string) *CompositePodGroupTemplateApplyConfiguration {
	b.Name = &value
	return b
}

// WithSchedulingPolicy sets the SchedulingPolicy 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 SchedulingPolicy field is set to the value of the last call.
func (b *CompositePodGroupTemplateApplyConfiguration) WithSchedulingPolicy(value *CompositePodGroupSchedulingPolicyApplyConfiguration) *CompositePodGroupTemplateApplyConfiguration {
	b.SchedulingPolicy = value
	return b
}

// WithSchedulingConstraints sets the SchedulingConstraints 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 SchedulingConstraints field is set to the value of the last call.
func (b *CompositePodGroupTemplateApplyConfiguration) WithSchedulingConstraints(value *CompositePodGroupSchedulingConstraintsApplyConfiguration) *CompositePodGroupTemplateApplyConfiguration {
	b.SchedulingConstraints = value
	return b
}

// WithDisruptionMode sets the DisruptionMode 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 DisruptionMode field is set to the value of the last call.
func (b *CompositePodGroupTemplateApplyConfiguration) WithDisruptionMode(value *CompositeDisruptionModeApplyConfiguration) *CompositePodGroupTemplateApplyConfiguration {
	b.DisruptionMode = value
	return b
}

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

// WithPriority sets the Priority 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 Priority field is set to the value of the last call.
func (b *CompositePodGroupTemplateApplyConfiguration) WithPriority(value int32) *CompositePodGroupTemplateApplyConfiguration {
	b.Priority = &value
	return b
}

// WithPreemptionPolicy sets the PreemptionPolicy 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 PreemptionPolicy field is set to the value of the last call.
func (b *CompositePodGroupTemplateApplyConfiguration) WithPreemptionPolicy(value schedulingv1alpha3.PreemptionPolicy) *CompositePodGroupTemplateApplyConfiguration {
	b.PreemptionPolicy = &value
	return b
}

// WithPodGroupTemplates adds the given value to the PodGroupTemplates 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 PodGroupTemplates field.
func (b *CompositePodGroupTemplateApplyConfiguration) WithPodGroupTemplates(values ...*PodGroupTemplateApplyConfiguration) *CompositePodGroupTemplateApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithPodGroupTemplates")
		}
		b.PodGroupTemplates = append(b.PodGroupTemplates, *values[i])
	}
	return b
}

// WithCompositePodGroupTemplates adds the given value to the CompositePodGroupTemplates 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 CompositePodGroupTemplates field.
func (b *CompositePodGroupTemplateApplyConfiguration) WithCompositePodGroupTemplates(values ...*CompositePodGroupTemplateApplyConfiguration) *CompositePodGroupTemplateApplyConfiguration {
	for i := range values {
		if values[i] == nil {
			panic("nil value passed to WithCompositePodGroupTemplates")
		}
		b.CompositePodGroupTemplates = append(b.CompositePodGroupTemplates, *values[i])
	}
	return b
}
