func setDefaults_XDLJobPort(spec *corev1.PodSpec) {
	index := 0
	for i, container := range spec.Containers {
		if container.Name == XDLJobDefaultContainerName {
			index = i
			break
		}
	}
	hasXDLJobPort := false
	for _, port := range spec.Containers[index].Ports {
		if port.Name == XDLJobDefaultContainerPortName {
			hasXDLJobPort = true
			break
		}
	}
	if !hasXDLJobPort {
		spec.Containers[index].Ports = append(spec.Containers[index].Ports, corev1.ContainerPort{
			Name:          XDLJobDefaultContainerPortName,
			ContainerPort: XDLJobDefaultPort,
		})
	}
}
setDefaults_XDLJobPort sets the default ports for xdl container.
package v1alpha1
import (
	"strings"
	v1 "github.com/alibaba/kubedl/pkg/job_controller/api/v1"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/utils/pointer"
)
func setDefaults_XDLJobSpec(spec *XDLJobSpec) {
	if spec.RunPolicy.CleanPodPolicy == nil {
		running := v1.CleanPodPolicyRunning
		spec.RunPolicy.CleanPodPolicy = &running
	}
	if spec.MinFinishWorkerNum == nil && spec.MinFinishWorkerPercentage == nil {
		spec.MinFinishWorkerPercentage = pointer.Int32Ptr(XDLJobDefaultMinFinishWorkRate)
	}
	if spec.BackoffLimit == nil {
		spec.BackoffLimit = pointer.Int32Ptr(XDLJobDefaultBackoffLimit)
	}
}