// ReplaceImage For DaemonSet, we don't replace the DaemonSet' image
// but create a deployment with dev container instead
ReplaceImage For DaemonSet, we don't replace the DaemonSet' image
but create a deployment with dev container instead
// ReplaceImage For DaemonSet we don ' t replace the DaemonSet ' image // but create a deployment with dev container instead
func (d *DuplicateDaemonSetController) ReplaceImage(ctx context.Context, ops *model.DevStartOptions) error {
	d.Client.Context(ctx)
	ds, err := d.Client.GetDaemonSet(d.GetName())
	if err != nil {
		return err
	}
	labelsMap, err := d.getDuplicateLabelsMap()
	if err != nil {
		return err
	}
	generatedDeployment := &v1.Deployment{
		ObjectMeta: metav1.ObjectMeta{
			Name:   d.getDuplicateResourceName(),
			Labels: labelsMap,
		},
		Spec: v1.DeploymentSpec{
			Template: ds.Spec.Template,
		},
	}
	generatedDeployment.Spec.Selector = &metav1.LabelSelector{MatchLabels: labelsMap}
	generatedDeployment.Spec.Template.Labels = labelsMap
	generatedDeployment.ResourceVersion = ""
	generatedDeployment.Spec.Template.Spec.NodeName = ""
	devContainer, sideCarContainer, devModeVolumes, err :=
		d.genContainersAndVolumes(&generatedDeployment.Spec.Template.Spec, ops.Container, ops.DevImage, ops.StorageClass, true)
	if err != nil {
		return err
	}
	patchDevContainerToPodSpec(&generatedDeployment.Spec.Template.Spec, ops.Container, devContainer, sideCarContainer, devModeVolumes)
	if _, err = d.Client.CreateDeploymentAndWait(generatedDeployment); err != nil {
		return err
	}
	d.patchAfterDevContainerReplaced(ops.Container, generatedDeployment.Kind, generatedDeployment.Name)
	return waitingPodToBeReady(d.GetNocalhostDevContainerPod)
}
func ( d * DuplicateDaemonSetController ) ReplaceImage ( ctx context . Context , ops * model . DevStartOptions ) error { d . Client . Context ( ctx ) ds , err := d . Client . GetDaemonSet ( d . GetName ( ) ) if err != nil { return err } labelsMap , err := d . getDuplicateLabelsMap ( ) if err != nil { return err } generatedDeployment := & v1 . Deployment { ObjectMeta : metav1 . ObjectMeta { Name : d . getDuplicateResourceName ( ) , Labels : labelsMap , } , Spec : v1 . DeploymentSpec { Template : ds . Spec . Template , } , } generatedDeployment . Spec . Selector = & metav1 . LabelSelector { MatchLabels : labelsMap } generatedDeployment . Spec . Template . Labels = labelsMap generatedDeployment . ResourceVersion = " " generatedDeployment . Spec . Template . Spec . NodeName = " " devContainer , sideCarContainer , devModeVolumes , err := d . genContainersAndVolumes ( & generatedDeployment . Spec . Template . Spec , ops . Container , ops . DevImage , ops . StorageClass , true ) if err != nil { return err } patchDevContainerToPodSpec ( & generatedDeployment . Spec . Template . Spec , ops . Container , devContainer , sideCarContainer , devModeVolumes ) if _ , err = d . Client . CreateDeploymentAndWait ( generatedDeployment ) ; err != nil { return err } d . patchAfterDevContainerReplaced ( ops . Container , generatedDeployment . Kind , generatedDeployment . Name ) return waitingPodToBeReady ( d . GetNocalhostDevContainerPod ) }
ReplaceImage For DaemonSet, we don't replace the DaemonSet' image
but create a deployment with dev container instead
ReplaceImage For DaemonSet we don ' t replace the DaemonSet ' image but create a deployment with dev container instead
// Create a deployment from DaemonSet spec // Create generated deployment