func SetDefaults_XGBoostJob(xgbJob *XGBoostJob) {
	setDefaults_XGBoostJobSpec(&xgbJob.Spec)
	setTypeNames_XGBoostJob(xgbJob)
	for _, spec := range xgbJob.Spec.XGBReplicaSpecs {
		enableFallbackToLogsOnErrorTerminationMessagePolicy(&spec.Template.Spec)
		setDefaults_XGBoostJobReplicas(spec)
		setDefaults_XGBoostJobPort(&spec.Template.Spec)
	}
	if features.KubeDLFeatureGates.Enabled(features.DAGScheduling) {
		setDefaultXGBoostDAGConditions(xgbJob)
	}
	if xgbJob.Kind == "" {
		xgbJob.Kind = XGBoostJobKind
	}
	if xgbJob.APIVersion == "" {
		xgbJob.APIVersion = GroupVersion.String()
	}
}
SetDefaults_XGBoostJob sets any unspecified values to defaults.
package v1alpha1
import (
	"github.com/alibaba/kubedl/pkg/features"
	"strings"
	v1 "github.com/alibaba/kubedl/pkg/job_controller/api/v1"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/utils/pointer"
)
func setDefaults_XGBoostJobSpec(spec *XGBoostJobSpec) {
	if spec.RunPolicy.CleanPodPolicy == nil {
		policy := XGBoostJobDefaultCleanPodPolicy
		spec.RunPolicy.CleanPodPolicy = &policy
	}
	if spec.RunPolicy.TTLSecondsAfterFinished == nil {
		ttl := XGBoostJobDefaultTTLseconds
		spec.RunPolicy.TTLSecondsAfterFinished = &ttl
	}
}
func setDefaults_XGBoostJobPort(spec *corev1.PodSpec) {
	index := 0
	for i, container := range spec.Containers {
		if container.Name == XGBoostJobDefaultContainerName {
			index = i
			break
		}
	}
	hasJobPort := false
	for _, port := range spec.Containers[index].Ports {
		if port.Name == XGBoostJobDefaultContainerPortName {
			hasJobPort = true
			break
		}
	}
	if !hasJobPort {
		spec.Containers[index].Ports = append(spec.Containers[index].Ports, corev1.ContainerPort{
			Name:          XGBoostJobDefaultContainerPortName,
			ContainerPort: XGBoostJobDefaultPort,
		})
	}
}
func setTypeNames_XGBoostJob(xgbJob *XGBoostJob) {
	setTypeName_XGBoostJob(xgbJob, XGBoostReplicaTypeMaster)
	setTypeName_XGBoostJob(xgbJob, XGBoostReplicaTypeWorker)
}
func setTypeName_XGBoostJob(xgbJob *XGBoostJob, typ v1.ReplicaType) {
	for t := range xgbJob.Spec.XGBReplicaSpecs {
		if strings.EqualFold(string(t), string(typ)) && t != typ {
			spec := xgbJob.Spec.XGBReplicaSpecs[t]
			delete(xgbJob.Spec.XGBReplicaSpecs, t)
			xgbJob.Spec.XGBReplicaSpecs[typ] = spec
			return
		}
	}
}
func setDefaults_XGBoostJobReplicas(spec *v1.ReplicaSpec) {
	if spec.Replicas == nil {
		spec.Replicas = pointer.Int32Ptr(1)
	}
}
func setDefaultXGBoostDAGConditions(job *XGBoostJob) {
	if job.Spec.XGBReplicaSpecs[XGBoostReplicaTypeMaster] != nil &&
		job.Spec.XGBReplicaSpecs[XGBoostReplicaTypeWorker] != nil {
		job.Spec.XGBReplicaSpecs[XGBoostReplicaTypeWorker].DependOn = []v1.DAGCondition{
			{Upstream: XGBoostReplicaTypeMaster, OnPhase: corev1.PodRunning},
		}
	}
}