Skip to content

Commit b40bf35

Browse files
amisevsksleshchenko
andcommitted
Fix potential nil error in propagating annotations to routing
Signed-off-by: Angel Misevski <[email protected]> Co-authored-by: Serhii Leshchenko <[email protected]>
1 parent f6a1016 commit b40bf35

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

controllers/workspace/provision/routing.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
2121
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
22+
maputils "github.com/devfile/devworkspace-operator/internal/map"
2223
"github.com/devfile/devworkspace-operator/pkg/config"
2324
"github.com/google/go-cmp/cmp"
2425
"github.com/google/go-cmp/cmp/cmpopts"
@@ -144,15 +145,14 @@ func getSpecRouting(
144145

145146
var annotations map[string]string
146147
if val, ok := workspace.Annotations[config.WorkspaceRestrictedAccessAnnotation]; ok {
147-
annotations = map[string]string{}
148-
annotations[config.WorkspaceRestrictedAccessAnnotation] = val
148+
annotations = maputils.Append(annotations, config.WorkspaceRestrictedAccessAnnotation, val)
149149
}
150150

151151
// copy the annotations for the specific routingClass from the workspace object to the routing
152152
expectedAnnotationPrefix := workspace.Spec.RoutingClass + config.RoutingAnnotationInfix
153153
for k, v := range workspace.GetAnnotations() {
154154
if strings.HasPrefix(k, expectedAnnotationPrefix) {
155-
annotations[k] = v
155+
annotations = maputils.Append(annotations, k, v)
156156
}
157157
}
158158

0 commit comments

Comments
 (0)