( workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI)
| 34 | ) |
| 35 | |
| 36 | func SyncRoutingToCluster( |
| 37 | workspace *common.DevWorkspaceWithConfig, |
| 38 | clusterAPI sync.ClusterAPI) (*v1alpha1.PodAdditions, map[string]v1alpha1.ExposedEndpointList, string, error) { |
| 39 | |
| 40 | specRouting, err := getSpecRouting(workspace, clusterAPI.Scheme) |
| 41 | if err != nil { |
| 42 | return nil, nil, "", err |
| 43 | } |
| 44 | |
| 45 | clusterObj, err := sync.SyncObjectWithCluster(specRouting, clusterAPI) |
| 46 | if err != nil { |
| 47 | return nil, nil, "", dwerrors.WrapSyncError(err) |
| 48 | } |
| 49 | |
| 50 | clusterRouting := clusterObj.(*v1alpha1.DevWorkspaceRouting) |
| 51 | statusMsg := clusterRouting.Status.Message |
| 52 | if clusterRouting.Status.Phase == v1alpha1.RoutingFailed { |
| 53 | return nil, nil, statusMsg, &dwerrors.FailError{Message: statusMsg} |
| 54 | } |
| 55 | if clusterRouting.Status.Phase != v1alpha1.RoutingReady { |
| 56 | return nil, nil, statusMsg, &dwerrors.RetryError{Message: statusMsg, RequeueAfter: 5 * time.Second} |
| 57 | } |
| 58 | |
| 59 | // Configure securityContext for pod additions, for example che-gateway container |
| 60 | // https://github.com/eclipse-che/che/issues/22747 |
| 61 | if clusterRouting.Status.PodAdditions != nil && |
| 62 | workspace.Config.Workspace != nil && |
| 63 | workspace.Config.Workspace.ContainerSecurityContext != nil { |
| 64 | |
| 65 | for i, container := range clusterRouting.Status.PodAdditions.Containers { |
| 66 | if container.SecurityContext == nil { |
| 67 | clusterRouting.Status.PodAdditions.Containers[i].SecurityContext = workspace.Config.Workspace.ContainerSecurityContext |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return clusterRouting.Status.PodAdditions, clusterRouting.Status.ExposedEndpoints, statusMsg, nil |
| 73 | } |
| 74 | |
| 75 | func getSpecRouting( |
| 76 | workspace *common.DevWorkspaceWithConfig, |
nothing calls this directly
no test coverage detected