diff --git a/controllers/workspace/provision/routing.go b/controllers/workspace/provision/routing.go index 9f0b62836..3483d79e0 100644 --- a/controllers/workspace/provision/routing.go +++ b/controllers/workspace/provision/routing.go @@ -15,6 +15,7 @@ package provision import ( "context" "fmt" + "strings" devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2" "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1" @@ -147,6 +148,14 @@ func getSpecRouting( annotations[config.WorkspaceRestrictedAccessAnnotation] = val } + // copy the annotations for the specific routingClass from the workspace object to the routing + expectedAnnotationPrefix := workspace.Spec.RoutingClass + config.RoutingAnnotationInfix + for k, v := range workspace.GetAnnotations() { + if strings.HasPrefix(k, expectedAnnotationPrefix) { + annotations[k] = v + } + } + routing := &v1alpha1.WorkspaceRouting{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("routing-%s", workspace.Status.WorkspaceId), diff --git a/pkg/config/constants.go b/pkg/config/constants.go index beefa02d2..5f8ac3a5e 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -70,6 +70,10 @@ const ( // PVCCleanupPodMemoryLimit is the memory limit used for PVC clean up pods PVCCleanupPodMemoryLimit = "32Mi" + + // RoutingAnnotationInfix is the infix of the annotations of DevWorkspace that are passed down as annotation to the WorkspaceRouting objects. + // The full annotation name is supposed to be ".routing.controller.devfile.io/" + RoutingAnnotationInfix = ".routing.controller.devfile.io/" ) // Constants for che-rest-apis