( workspace *common.DevWorkspaceWithConfig, podAdditionsList []v1alpha1.PodAdditions, saName string, podTolerations []corev1.Toleration, nodeSelector map[string]string, scheme *runtime.Scheme)
| 129 | } |
| 130 | |
| 131 | func getSpecDeployment( |
| 132 | workspace *common.DevWorkspaceWithConfig, |
| 133 | podAdditionsList []v1alpha1.PodAdditions, |
| 134 | saName string, |
| 135 | podTolerations []corev1.Toleration, |
| 136 | nodeSelector map[string]string, |
| 137 | scheme *runtime.Scheme) (*appsv1.Deployment, error) { |
| 138 | replicas := int32(1) |
| 139 | terminationGracePeriod := int64(10) |
| 140 | |
| 141 | podAdditions, err := mergePodAdditions(podAdditionsList) |
| 142 | if err != nil { |
| 143 | return nil, err |
| 144 | } |
| 145 | |
| 146 | for idx := range podAdditions.Containers { |
| 147 | podAdditions.Containers[idx].VolumeMounts = append(podAdditions.Containers[idx].VolumeMounts, podAdditions.VolumeMounts...) |
| 148 | } |
| 149 | for idx := range podAdditions.InitContainers { |
| 150 | podAdditions.InitContainers[idx].VolumeMounts = append(podAdditions.InitContainers[idx].VolumeMounts, podAdditions.VolumeMounts...) |
| 151 | } |
| 152 | |
| 153 | labels := map[string]string{} |
| 154 | labels[constants.DevWorkspaceIDLabel] = workspace.Status.DevWorkspaceId |
| 155 | labels[constants.DevWorkspaceNameLabel] = workspace.Name |
| 156 | |
| 157 | annotations, err := getAdditionalDeploymentAnnotations(workspace) |
| 158 | if err != nil { |
| 159 | return nil, err |
| 160 | } |
| 161 | |
| 162 | deploymentStrategy := appsv1.DeploymentStrategy{ |
| 163 | Type: workspace.Config.Workspace.DeploymentStrategy, |
| 164 | } |
| 165 | if workspace.Config.Workspace.DeploymentStrategy == appsv1.RollingUpdateDeploymentStrategyType { |
| 166 | deploymentStrategy.RollingUpdate = &appsv1.RollingUpdateDeployment{ |
| 167 | MaxUnavailable: &constants.RollingUpdateMaxUnavailable, |
| 168 | MaxSurge: &constants.RollingUpdateMaximumSurge, |
| 169 | } |
| 170 | } |
| 171 | progressDeadlineSeconds, err := getProgressDeadlineSeconds(workspace.Config) |
| 172 | if err != nil { |
| 173 | return nil, err |
| 174 | } |
| 175 | |
| 176 | deployment := &appsv1.Deployment{ |
| 177 | ObjectMeta: metav1.ObjectMeta{ |
| 178 | Name: common.DeploymentName(workspace.Status.DevWorkspaceId), |
| 179 | Namespace: workspace.Namespace, |
| 180 | Labels: labels, |
| 181 | Annotations: annotations, |
| 182 | }, |
| 183 | Spec: appsv1.DeploymentSpec{ |
| 184 | Replicas: &replicas, |
| 185 | Selector: &metav1.LabelSelector{ |
| 186 | MatchLabels: map[string]string{ |
| 187 | constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId, |
| 188 | }, |
no test coverage detected