( workspace *common.DevWorkspaceWithConfig, scheme *runtime.Scheme)
| 73 | } |
| 74 | |
| 75 | func getSpecRouting( |
| 76 | workspace *common.DevWorkspaceWithConfig, |
| 77 | scheme *runtime.Scheme) (*v1alpha1.DevWorkspaceRouting, error) { |
| 78 | |
| 79 | endpoints := map[string]v1alpha1.EndpointList{} |
| 80 | for _, component := range workspace.Spec.Template.Components { |
| 81 | if component.Container == nil { |
| 82 | continue |
| 83 | } |
| 84 | componentEndpoints := component.Container.Endpoints |
| 85 | if len(componentEndpoints) > 0 { |
| 86 | endpoints[component.Name] = append(endpoints[component.Name], conversion.ConvertAllDevfileEndpoints(componentEndpoints)...) |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | var annotations map[string]string |
| 91 | if val, ok := workspace.Annotations[constants.DevWorkspaceRestrictedAccessAnnotation]; ok { |
| 92 | annotations = maputils.Append(annotations, constants.DevWorkspaceRestrictedAccessAnnotation, val) |
| 93 | } |
| 94 | annotations = maputils.Append(annotations, constants.DevWorkspaceStartedStatusAnnotation, "true") |
| 95 | |
| 96 | // copy the annotations for the specific routingClass from the workspace object to the routing |
| 97 | expectedAnnotationPrefix := workspace.Spec.RoutingClass + constants.RoutingAnnotationInfix |
| 98 | for k, v := range workspace.GetAnnotations() { |
| 99 | if strings.HasPrefix(k, expectedAnnotationPrefix) { |
| 100 | annotations = maputils.Append(annotations, k, v) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | routingClass := workspace.Spec.RoutingClass |
| 105 | if routingClass == "" { |
| 106 | routingClass = workspace.Config.Routing.DefaultRoutingClass |
| 107 | } |
| 108 | |
| 109 | routing := &v1alpha1.DevWorkspaceRouting{ |
| 110 | ObjectMeta: metav1.ObjectMeta{ |
| 111 | Name: common.DevWorkspaceRoutingName(workspace.Status.DevWorkspaceId), |
| 112 | Namespace: workspace.Namespace, |
| 113 | Labels: map[string]string{ |
| 114 | constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId, |
| 115 | }, |
| 116 | Annotations: annotations, |
| 117 | }, |
| 118 | Spec: v1alpha1.DevWorkspaceRoutingSpec{ |
| 119 | DevWorkspaceId: workspace.Status.DevWorkspaceId, |
| 120 | RoutingClass: v1alpha1.DevWorkspaceRoutingClass(routingClass), |
| 121 | Endpoints: endpoints, |
| 122 | PodSelector: map[string]string{ |
| 123 | constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId, |
| 124 | }, |
| 125 | }, |
| 126 | } |
| 127 | err := controllerutil.SetControllerReference(workspace.DevWorkspace, routing, scheme) |
| 128 | if err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | |
| 132 | return routing, nil |
no test coverage detected