// ReplaceImage For Job, we can't replace the Job' image
// but create a job with dev container instead
ReplaceImage For Job, we can't replace the Job' image
but create a job with dev container instead
// ReplaceImage For Job we can ' t replace the Job ' image // but create a job with dev container instead
func (j *JobController) ReplaceImage(ctx context.Context, ops *model.DevStartOptions) error {
	j.Client.Context(ctx)
	originJob, err := j.Client.GetJobs(j.GetName())
	if err != nil {
		return err
	}
	generatedJob := &batchv1.Job{
		ObjectMeta: metav1.ObjectMeta{
			Name:   j.getGeneratedJobName(),
			Labels: map[string]string{_const.DevWorkloadIgnored: "true"},
		},
		Spec: batchv1.JobSpec{
			Selector: originJob.Spec.Selector,
			Template: originJob.Spec.Template,
		},
	}
	if generatedJob.Spec.Template.ObjectMeta.Labels != nil {
		delete(generatedJob.Spec.Template.ObjectMeta.Labels, "controller-uid")
		delete(generatedJob.Spec.Template.ObjectMeta.Labels, "job-name")
	}
	if generatedJob.Spec.Selector != nil && generatedJob.Spec.Selector.MatchLabels != nil {
		delete(generatedJob.Spec.Selector.MatchLabels, "controller-uid")
	}
	devContainer, sideCarContainer, devModeVolumes, err :=
		j.genContainersAndVolumes(&generatedJob.Spec.Template.Spec, ops.Container, ops.DevImage, ops.StorageClass, false)
	if err != nil {
		return err
	}
	patchDevContainerToPodSpec(&generatedJob.Spec.Template.Spec, ops.Container, devContainer, sideCarContainer, devModeVolumes)
	if _, err = j.Client.CreateJob(generatedJob); err != nil {
		return err
	}
	j.patchAfterDevContainerReplaced(ops.Container, generatedJob.Kind, generatedJob.Name)
	return waitingPodToBeReady(j.GetNocalhostDevContainerPod)
}
func ( j * JobController ) ReplaceImage ( ctx context . Context , ops * model . DevStartOptions ) error { j . Client . Context ( ctx ) originJob , err := j . Client . GetJobs ( j . GetName ( ) ) if err != nil { return err } generatedJob := & batchv1 . Job { ObjectMeta : metav1 . ObjectMeta { Name : j . getGeneratedJobName ( ) , Labels : map [ string ] string { _const . DevWorkloadIgnored : " " } , } , Spec : batchv1 . JobSpec { Selector : originJob . Spec . Selector , Template : originJob . Spec . Template , } , } if generatedJob . Spec . Template . ObjectMeta . Labels != nil { delete ( generatedJob . Spec . Template . ObjectMeta . Labels , " " ) delete ( generatedJob . Spec . Template . ObjectMeta . Labels , " " ) } if generatedJob . Spec . Selector != nil && generatedJob . Spec . Selector . MatchLabels != nil { delete ( generatedJob . Spec . Selector . MatchLabels , " " ) } devContainer , sideCarContainer , devModeVolumes , err := j . genContainersAndVolumes ( & generatedJob . Spec . Template . Spec , ops . Container , ops . DevImage , ops . StorageClass , false ) if err != nil { return err } patchDevContainerToPodSpec ( & generatedJob . Spec . Template . Spec , ops . Container , devContainer , sideCarContainer , devModeVolumes ) if _ , err = j . Client . CreateJob ( generatedJob ) ; err != nil { return err } j . patchAfterDevContainerReplaced ( ops . Container , generatedJob . Kind , generatedJob . Name ) return waitingPodToBeReady ( j . GetNocalhostDevContainerPod ) }
ReplaceImage For Job, we can't replace the Job' image
but create a job with dev container instead
ReplaceImage For Job we can ' t replace the Job ' image but create a job with dev container instead
// Create a Job from origin Job's spec // Create generated deployment